diff options
author | varac <varacanero@zeromail.org> | 2014-02-06 13:45:36 +0100 |
---|---|---|
committer | varac <varacanero@zeromail.org> | 2014-02-06 13:45:36 +0100 |
commit | 26feb4a5b58badf97abd5fffffc8ebf6a0b341f3 (patch) | |
tree | 50884d2fba44468598fb29afe690e67431c2f510 | |
parent | e7f0f34656cd8722c2dc40ade8e4578adecd7b0e (diff) |
added check_bigcouch_errors.sh
-rwxr-xr-x | tests/check_bigcouch_errors.sh | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/check_bigcouch_errors.sh b/tests/check_bigcouch_errors.sh new file mode 100755 index 0000000..21cadb1 --- /dev/null +++ b/tests/check_bigcouch_errors.sh @@ -0,0 +1,46 @@ +#!/bin/bash + + +WARN=10 +CRIT=20 +LOG='/opt/bigcouch/var/log/bigcouch.log' + +# for debugging: zgrep through old logs +#LOG=/opt/bigcouch/var/log/bigcouch.log.1.gz +#errors=`zcat $LOG | grep 'error' | sed 's/\[.*\] //' | sort` + +errors=`grep 'error' $LOG | sed 's/\[.*\] //' | sort ` +errors_uniq=`echo -e "$errors" | uniq` + +total=`echo -e "$errors" | grep -v '^$' | wc -l` + +if [ $total -lt $WARN ] +then + echo -n "OK" + exitcode=0 +else + if [ $total -le $CRIT ] + then + echo -n "Warning" + exitcode=1 + else + echo -n "Critical" + exitcode=2 + fi +fi + +echo -n ": $total errors in total in $LOG." + +if [ ! $total -eq 0 ] +then + + echo -e "$errors_uniq" | while read -r line + do + count=`echo -e "$errors" | grep "$line" | wc -l` + echo -n " $count occurrences of \"$line\"." + done +fi + +echo + +exit $exitcode |