Monitor if RANCID grabbed all configuration files successfully
From Internetworkpro
Below is a script which can be scheduled as a cronjob (after rancid runs nightly - before the next day), and it updates an html with a pass string (OK) or a fail string (fail), based on RANCID grabbing all configuration files. If RANCID fails, the monitor will show fail because the html file with have been changed from OK to fail.
#!/bin/bash
#change to rancid logging directory, and grep the current days log file for a rancid success
cd /var/log/rancid
grep "All routers sucessfully completed." *$(date +%Y%m%d)*
#if grep finds the rancid success update a file with a pass or fail string for ipmonitor to check
if [ $? -eq 1 ] ; then
echo "fail" > /var/www/syslog/rancidmonitor.html
elif [ $? -eq 2 ] ; then
echo "fail" > /var/www/syslog/rancidmonitor.html
else
echo "OK" > /var/www/syslog/rancidmonitor.html
fi
#sent OK string to html file so a monitoring application can search for OK
</source>
[[Category:Scripts]][[Category:Bash]]

