-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtail-flowd
More file actions
executable file
·61 lines (54 loc) · 1.14 KB
/
tail-flowd
File metadata and controls
executable file
·61 lines (54 loc) · 1.14 KB
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
#!/usr/bin/env bash
#
# Synopsis:
# Tail (gnu) multiple schema/*/log/flowd-<Dow>.log files
# Usage:
# tail-flowd
# 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"
START_DIR=$(pwd)
cd $SCHEMA || die "cd $SCHEMA failed: exit status=$?"
case $# in
0)
DIRs=.
DEPTH=1
;;
1)
# special case when script started in schema dir
if [ "$1" = . ]; then
LOG=$START_DIR/log
test -d $LOG || die "log dir does not exist: $LOG"
LOG=$LOG/flowd-$(date +'%a').log
exec tail -F $LOG
fi
;& # fall through
*)
# insure all schema directories exist
for D in $@; do
test -d $D || die "no schema dir: $(pwd)/$D"
done
DIRs=$@
DEPTH=0
esac
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
)