Preventative Maintenance
Posted: Tue Aug 11, 2015 4:11 pm
I’m working in a relatively large environment (~2000 hosts, ~7000 services from 40 remote Nagios XI sites). Every now and then on the Nagios XI server that receives passive results from the remote sites, the /usr/local/nagios/var/spool/checkresults fills up with files to the point that Nagios (at least the UI) crashes. From what I read on these forums, something got corrupted in one of the databases or a service stopped running. What would be the repercussions of creating a cron job that runs a script with the lines below every midnight on the server that collects passive data? Any other recommendations on how to do a sort of preventative maintenance?
service nagiosxi stop
service nagios stop
service ndo2db stop
service npcd stop
service mysqld stop
# Remove checkresults older than 1 hour
for NAME in `find /usr/local/nagios/var/spool/checkresults -maxdepth 1 –type f –mmin +60`;do rm –f $NAME; done
# Remove perfdata older than 1 hour
for NAME in `find /usr/local/nagios/var/spool/perfdata -maxdepth 1 –type f –mmin +60`;do rm –f $NAME; done
# Repair databases
/usr/local/nagiosxi/scripts/repairmysql.sh nagios
/usr/local/nagiosxi/scripts/repairmysql.sh mysql
service mysqld start
service npcd start
service ndo2db start
# Sleep for 10 seconds to ensure ndo2db is up
sleep 10
service nagios start
service nagiosxi stop
I'm using Nagios XI version 2012R2.9 on a RHEL 6 (64-bit) VM. I can't upgrade since this is the version that the program requirements were verified against. Another thread mentioned a cron job (/usr/local/nagiosxi/cron/dbmaint.php ), but it does not show up as a cron job in my installation. I only have sysstat.php, eventman.php, perfdataproc.php, and freedproc.php running. I do see dbmaint.php in /usr/local/nagiosxi/cron though.
service nagiosxi stop
service nagios stop
service ndo2db stop
service npcd stop
service mysqld stop
# Remove checkresults older than 1 hour
for NAME in `find /usr/local/nagios/var/spool/checkresults -maxdepth 1 –type f –mmin +60`;do rm –f $NAME; done
# Remove perfdata older than 1 hour
for NAME in `find /usr/local/nagios/var/spool/perfdata -maxdepth 1 –type f –mmin +60`;do rm –f $NAME; done
# Repair databases
/usr/local/nagiosxi/scripts/repairmysql.sh nagios
/usr/local/nagiosxi/scripts/repairmysql.sh mysql
service mysqld start
service npcd start
service ndo2db start
# Sleep for 10 seconds to ensure ndo2db is up
sleep 10
service nagios start
service nagiosxi stop
I'm using Nagios XI version 2012R2.9 on a RHEL 6 (64-bit) VM. I can't upgrade since this is the version that the program requirements were verified against. Another thread mentioned a cron job (/usr/local/nagiosxi/cron/dbmaint.php ), but it does not show up as a cron job in my installation. I only have sysstat.php, eventman.php, perfdataproc.php, and freedproc.php running. I do see dbmaint.php in /usr/local/nagiosxi/cron though.