Usage: cronlog_parserin [-hvl] [-f ]
h : print this help message
v : print version
l : long output
f : file
Description:
Per default cronlog_parserin reads a solaris cron log file from STDIN and
parses it for Errors which are identified by the string "rc=" and prints
them in one line to STDOUT:
cat /var/cron/log | cronlog_parserin
tofu001 rc=255 CMD: /opt/SUNWfoo/bin/send_trigger_message.sh > /dev/null 2>&1
Count error records and print a summary:
cat /var/cron/log | cronlog_parserin | sort | uniq -c
2 root rc=1 CMD: /opt/VRTSvcs/bin/start_resource xgdq90 Marginskript euclqsv1
1 root rc=1 CMD: [ -x /usr/sbin/rtc ] && /usr/sbin/rtc -c > /dev/null 2>&1
8 tofu001 rc=255 CMD: /opt/SUNWfoo/bin/send_trigger_message.sh > /dev/null 2>&1
Print a long and detailed output:
cat /var/cron/log | cronlog_parserin -l
CMD: /opt/SUNWfoo/bin/send_trigger_message.sh > /dev/null 2>&1
tofu001 25965 c Thu Oct 25 09:40:00 2007
tofu001 25965 c Thu Oct 25 09:40:00 2007 rc=255
Read from file:
cronlog_parserin -l -f /var/cron/log
Handle very large log files:
Sometimes the cron log file has not been rotated since installation. Handling very
huge logfiles will take a lot of time!
If you want to see the latest error records of your cron log file only, write a small
shell script around the cronlog_parserin:
#!/bin/bash
# search for the first match of "Oct", save line number in $a:
a=`cat -n /var/cron/log |grep "Oct"|head -1|awk '{print $1}'`
# count up lines, save into $b:
b=`wc -l cron.log.2007|awk '{print $1}'`
# because the first CMD line does not include a date string:
a=$(($a - 1))
# calculate the number of lines
c=$(($b - $a))
# pipe only wanted lines into cronlog_parserin:
tail -$c cron.log.2007 | cronlog_parserin
Rotate your cron log file!
Hint:
If you had a grep -A available under solaris you would not need this script 8-/
Have Fun!
sylvia
echo "die_scripterinAT1ooo1.de"|sed 's/AT/@/' # ;-)