I have a file which I needed to parse, I am trying to make a list of downtimes from ICINGA2. THE API from ICINGA is not working as expected and it is not showing a complete list of downtime list of services and hosts file.
Filename - status.dat
programstatus {
host_name=demoserver.example.com
check_command=check_hostalive!
icinga_pid=85822
daemon_mode=1
program_start=1504843660
active_host_checks_enabled=1
passive_host_checks_enabled=1
active_service_checks_enabled=1
passive_service_checks_enabled=1
check_service_freshness=1
check_host_freshness=1
enable_notifications=1
enable_event_handlers=1
enable_flap_detection=1
enable_failure_prediction=0
process_performance_data=1
active_scheduled_host_check_stats=1,5,15
passive_host_check_stats=0,0,0
active_scheduled_service_check_stats=12,60,180
passive_service_check_stats=0,0,0
next_downtime_id=18
next_comment_id=4
scheduled_downtime_depth=2
}
IF we notice in the above file in the last line, the I have to look for the line "scheduled_downtime_depth=2". If the value is anything apart from Zero , i have to get the host name and service name which is present in the first two lines of the service and host template.
Thanks