Page 1 of 1

Scheduled Downtime

Posted: Wed Oct 20, 2021 4:19 am
by vishal313
Hi All,

I need to know how can I find history about which nodes were configured for Scheduled Downtime in last one month or so.
We have Nagios XI 5.8.5.


Regards
Vishal Dhote

Re: Scheduled Downtime

Posted: Wed Oct 20, 2021 3:17 pm
by ssax
There isn't currently a downtime history in the web interface, I have previously submitted a feature request for this but it hasn't been implemented yet.

You should be able to run this command I constructed for you to get that information, it will show the downtime history for the last month:

Code: Select all

mysql -uroot -pnagiosxi nagios -e "SELECT IF(nagios_downtimehistory.downtime_type = 2, 'host', 'service') as 'downtime_type', IF(nagios_downtimehistory.downtime_type = 2, host_objects.name1, service_objects.name1) AS 'host_name', IF(nagios_downtimehistory.downtime_type = 2, '', service_objects.name2) AS 'service_desc', nagios_downtimehistory.author_name, nagios_downtimehistory.comment_data, nagios_downtimehistory.actual_start_time FROM nagios_downtimehistory LEFT JOIN nagios_objects AS host_objects ON host_objects.object_id = nagios_downtimehistory.object_id AND nagios_downtimehistory.downtime_type = 2 LEFT JOIN nagios_objects AS service_objects ON service_objects.object_id = nagios_downtimehistory.object_id AND nagios_downtimehistory.downtime_type = 1 WHERE nagios_downtimehistory.actual_start_time BETWEEN DATE_FORMAT(NOW() - INTERVAL 1 MONTH, '\%Y-\%m-01 00:00:00') AND NOW() AND nagios_downtimehistory.was_cancelled = 0"
Or if you want it to go to a CSV file:

Code: Select all

mysql -uroot -pnagiosxi nagios -e "SELECT IF(nagios_downtimehistory.downtime_type = 2, 'host', 'service') as 'downtime_type', IF(nagios_downtimehistory.downtime_type = 2, host_objects.name1, service_objects.name1) AS 'host_name', IF(nagios_downtimehistory.downtime_type = 2, '', service_objects.name2) AS 'service_desc', nagios_downtimehistory.author_name, nagios_downtimehistory.comment_data, nagios_downtimehistory.actual_start_time FROM nagios_downtimehistory LEFT JOIN nagios_objects AS host_objects ON host_objects.object_id = nagios_downtimehistory.object_id AND nagios_downtimehistory.downtime_type = 2 LEFT JOIN nagios_objects AS service_objects ON service_objects.object_id = nagios_downtimehistory.object_id AND nagios_downtimehistory.downtime_type = 1 WHERE nagios_downtimehistory.actual_start_time BETWEEN DATE_FORMAT(NOW() - INTERVAL 1 MONTH, '\%Y-\%m-01 00:00:00') AND NOW() AND nagios_downtimehistory.was_cancelled = 0 INTO OUTFILE '/tmp/downtime_for_the_last_month.csv' FIELDS TERMINATED BY ',' ENCLOSED BY '\"' LINES TERMINATED BY '\n';"
You would find it here:

Code: Select all

/tmp/downtime_for_the_last_month.csv
OR here:

Code: Select all

ls -l /tmp/systemd-private-*-mariadb.service-*/tmp/downtime_for_the_last_month.csv