-
Notifications
You must be signed in to change notification settings - Fork 3
/
kylo-tail
31 lines (28 loc) · 869 Bytes
/
kylo-tail
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
#!/bin/bash
dir=/opt/kylo/script/kylo-tail.d
opts="-Fn100"
# Check which OS is being used.
if [ -f /etc/redhat-release ]; then
dir=$dir/redhat
elif [ -f /etc/debian-release ]; then
dir=$dir/debian
else
echo "kylo-tail: cannot determine log file paths for this OS, exiting."; exit 1
fi
if [ "$1" == "-h" ]; then
# need man pages.
echo "kylo-tail: using no parameters, all logs are tailed. Using one or more parameters, it tails those logs. For example, kylo-tail nifi will only display nifi logs."; exit 1
fi
if [ "$1" == "-l" ]; then
ls $dir | cut -d- -f2; exit 1
fi
if [ -z "$1" ]; then
tail $opts $(eval echo $(cat $dir/*)) 2>/dev/null
else
if [ "$#" -eq 1 ]; then
tail $opts $(eval echo $(cat $dir/*$1)) 2>/dev/null
else
args=$(IFS=","; echo "$*")
tail $opts $(cat $(eval echo $dir/*{$args})) 2>/dev/null
fi
fi