-
Notifications
You must be signed in to change notification settings - Fork 1
/
tail-flowd
executable file
·48 lines (41 loc) · 927 Bytes
/
tail-flowd
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
#!/usr/bin/env bash
#
# Synopsis:
# Tail (gnu) all the schema/*/log/flowd-<Dow>.log files
# Usage:
# tail-flowd
# tail-flowd jsonorg prefixio
# Note:
# Only works up until midnight of local day.
#
# Only works if schemas in dir $SETSPACE_ROOT/schema.
#
die()
{
echo "ERROR: $@" >&2
exit 1
}
test -n "$SETSPACE_ROOT" || die "env var not defined: SETSPACE_ROOT"
SCHEMA=$SETSPACE_ROOT/schema
test -e $SCHEMA || die "directory does not exist: $SCHEMA"
cd $SCHEMA || die "cd $SCHEMA failed: exit status=$?"
if [ $# = 0 ]; then
DIRs=.
DEPTH=1
else
# insure all schema directories exist
for D in $@; do
test -d $D || die "schema directory does not exist: $(pwd)/$D"
done
DIRs=$@
DEPTH=0
fi
SCHEMAS=$(
find $DIRs -mindepth $DEPTH -maxdepth $DEPTH -type d -print |
sort |
sed 's/^\.\///'
)
tail -f $(
find $(find $SCHEMAS -mindepth 1 -maxdepth 1 -type d -name log )\
-name flowd-$(date +'%a').log
)