Max Comment History Age

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
lucasari
Posts: 15
Joined: Tue Aug 13, 2019 4:26 am

Max Comment History Age

Post by lucasari »

Hi,

we have the need to delete every comment on services and host 3 days after they have been created.
we found the option "Max Comment History Age" in Admin -> Performance Settings -> Databases. If we set this option to 3, will it actually delete the comments after 3 days have passed from the creation?
if so, how often and when is the housekeeping job being run?

regards,
Luca
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Max Comment History Age

Post by ssax »

Yes, the option you found is to set the retention/cleanup on the nagios_commenthistory table. If you set it to 3 it should delete everything older than 3 days which gets kicked off by the dbmaint cron job:

Code: Select all

cat /etc/cron.d/nagiosxi
Which by default runs every 5 minutes:

Code: Select all

*/5 * * * * nagios /usr/bin/php -q /usr/local/nagiosxi/cron/dbmaint.php >> /usr/local/nagiosxi/var/dbmaint.log 2>&1
lucasari
Posts: 15
Joined: Tue Aug 13, 2019 4:26 am

Re: Max Comment History Age

Post by lucasari »

we are having some issues with getting the comments removed after using this function.
in fact, we set the retention to 10 minutes, but we are still seeing comments that are much older. they do not get deleted.

how can we make sure the comments older than a certain amount of time get deleted? is there any command we can run to achieve this?
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Max Comment History Age

Post by ssax »

The DB maint process should clean them up, please attach this file:

Code: Select all

/usr/local/nagiosxi/cron/dbmaint.php
You should be able to run this command (which will delete everything older than 6 months) to manually clean it up:

Code: Select all

mysql -uroot -pnagiosxi -h 127.0.0.1 -B nagios -e 'DELETE FROM nagios_commenthistory WHERE entry_time <= (NOW() - INTERVAL 6 MONTH);'
To delete all older than 10 minutes you would do this:

Code: Select all

mysql -uroot -pnagiosxi -h 127.0.0.1 -B nagios -e 'DELETE FROM nagios_commenthistory WHERE entry_time <= (NOW() - INTERVAL 10 MINUTE);'
Locked