File tree 1 file changed +6
-4
lines changed
1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change 4
4
# in the Cassandra system.log.
5
5
#
6
6
# Author Erick Ramirez, 2015 Mar 31
7
+ # Updated by Erick Ramirez, 2015 Aug 20 - changed the way date/time is getting tokenized to account for variations in log entries
7
8
#
8
9
9
- # q=ParNew
10
- # for node in *; do echo "===== $node ====="; log=$node/system-20150317.log; for x in `grep "$q" $log | awk '{print $4}' | cut -d: -f1 | sort -u`; do y=`grep "$q" $log | grep -c "2015-03-17 $x:"`; echo "${x}:00 - $y"; done; echo ""; done
11
-
12
10
# validate arguments
13
11
if [ " $# " -ne 2 ]
14
12
then
15
13
echo " ERROR - Usage: ` basename $0 ` <query_string> <system_log>"
16
14
exit 1
15
+ elif [ ! -r $2 ]
16
+ then
17
+ echo " ERROR - Log file [$2 ] not readable"
18
+ exit 2
17
19
else
18
20
query_string=" $1 "
19
21
system_log=" $2 "
20
22
fi
21
23
22
24
# obtain the unique list of hours where there's a match in the log
23
- grep " $query_string " $system_log | awk ' {print $3, $4} ' | cut -d: -f1 | sort -u | while read hour
25
+ grep " $query_string " $system_log | sed -e ' s/.* \([0-9]*-[0-9]*-[0-9]* [0-9]*\):.*/\1/ ' | sort -u | while read hour
24
26
do
25
27
# count number of occurences of query_string for given hour
26
28
count=` grep " $query_string " $system_log | grep -c " $hour :" `
You can’t perform that action at this time.
0 commit comments