-1

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

masteraravind
  • 45
  • 1
  • 1
  • 4
  • So...what sort of problem are you having? How have you tried to solve it so far? – larsks Sep 09 '17 at 12:10
  • Read [reading-and-writing-files-with-python](http://www.pythonforbeginners.com/filehandling/reading-and-writing-files-with-python), and [string.find(...](http://www.pythonforbeginners.com/python-strings/strings-built-in-methods) – stovfl Sep 09 '17 at 14:08
  • Nope. still checking on this. – masteraravind Sep 09 '17 at 19:12

1 Answers1

0

In terms of the REST API problems, go ahead and create a new thread please.

For parsing status.dat from the old Icinga1/Nagios world, you can look into the following tools or scripts available for Nagios:

https://pypi.python.org/pypi/NagParser/0.0.19 https://codereview.stackexchange.com/questions/48664/nagios-status-dat-to-dict-could-it-be-better https://gist.github.com/koemu/5553394

How to parse nagios status.dat file?

dnsmichi
  • 466
  • 3
  • 11