Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/343.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 正在分析ICINGA status.dat文件_Python_Linux_Bash_Nagios - Fatal编程技术网

Python 正在分析ICINGA status.dat文件

Python 正在分析ICINGA status.dat文件,python,linux,bash,nagios,Python,Linux,Bash,Nagios,我有一个需要解析的文件,我正试图从ICINGA2中列出停机时间。ICINGA的API未按预期工作,并且未显示服务和主机文件的完整停机列表 文件名-status.dat programstatus { host_name=demoserver.example.com check_command=check_hostalive! icinga_pid=85822 daemon_mode=1 program_start=1504843660 active_

我有一个需要解析的文件,我正试图从ICINGA2中列出停机时间。ICINGA的API未按预期工作,并且未显示服务和主机文件的完整停机列表

文件名-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
    }
如果我们注意到上面文件的最后一行,我必须查找“scheduled\u downtime\u depth=2”行。如果该值不是零,则必须获取服务和主机模板前两行中的主机名和服务名


感谢

关于REST API问题,请继续创建一个新线程

要解析旧Icinga1/Nagios世界中的status.dat,您可以查看适用于Nagios的以下工具或脚本:


那么……你有什么问题?到目前为止,你是如何试图解决这个问题的?阅读,没有。还在查这个。