I've removed a few senstive bits, but he is a really easy way to check if:
A) A log file has been touched in the last 10 minutes
B) That in the last 30 lines of the log file some expected text has been logged
It's not great, but it's better than nothing:
#!/bin/bash
LOG_FILE=$(find /shared/logs -name "*.log" -mmin -30)
LOG_FILE_CHECK=$(find /shared/logs -name "*.log" -mmin -10 | wc -l)
LOG_FILE_RET=$(tail -30 $LOG_FILE | grep "retrieved" | wc -l)
LOG_FILE_FINISH=$(tail -30 $LOG_FILE | grep "job finished" | wc -l)
if [ $LOG_FILE_CHECK -ne 0 ] && [ $LOG_FILE_RET -ne 0 ] && [ $LOG_FILE_FINISH -ne 0 ] ; then
echo "OK - running"
exit 0
else echo "CRIT - not running"
exit 2
fi
No comments:
Post a Comment