-
Notifications
You must be signed in to change notification settings - Fork 1
/
flowd-stat
executable file
·63 lines (51 loc) · 1.04 KB
/
flowd-stat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env bash
#
# Synopsis:
# Summarize today's flowd activity, particulaly faults.
#
PROG=flowd-stat
STALE_MMIN=2
die()
{
echo "$PROG: ERROR: $@" >&1
exit 1
}
test -n "$SETSPACE_ROOT" || die 'env var not defined: SETSPACE_ROOT'
cd $SETSPACE_ROOT || die "cd $SETSPACE_ROOT failed: exit status=$?"
. etc/profile
TODAY_LOG=$(echo flowd-$(date +%a)).log
do_stat()
{
LOG=schema/$1/log/$TODAY_LOG
echo $1: $TODAY_LOG
# does the log file exist?
if [ ! -e $LOG ]; then
echo " No log file - is flowd $1 running?"
return
fi
test -r $LOG || die "flowd log not readable: $LOG"
# has the log been touched recenty?
IS_STALE=$(find $LOG -mmin -$STALE_MMIN)
test $? || die "find $LOG failed: exit status=$?"
if [ "$IS_STALE" = '' ]; then
echo " Log not changed in $STALE_MMIN minutes - " \
"is flowd $1 running?"
return
fi
egrep ': (ERROR|WARN): ' $LOG | while read L; do
echo " $L"
done
}
case $# in
0)
find-schema | while read SCH; do
do_stat $SCH
done
;;
*)
while [ -n "$1" ]; do
do_stat $1
shift
done
;;
esac