提取nagios可用性报告

时间:2017-10-03 14:05:17

标签: python shell cgi nagios nagiosxi

我试图从nagios(Nagios®Core™4.0.8)中提取nagios可用性报告数据一周(7天)并以csv格式获得输出。

以下是查询后端/传递为avail.cgi的参数的URL:

https://username:password@nagioshostname/nagios/cgi-bin/avail.cgi?show_log_entries=&servicegroup=services1&timeperiod=last7days&smon=8&sday=1&syear=2017&shour=0&smin=0&ssec=0&emon=8&eday=3&eyear=2017&ehour=24&emin=0&esec=0&rpttimeperiod=24x7&assumeinitialstates=yes&assumestateretention=yes&assumestatesduringnotrunning=yes&includesoftstates=no&initialassumedhoststate=3&initialassumedservicestate=0&backtrack=4&csvoutput=1

以上网址没有返回我的数据与avail.cgi,最终有html&响应。

<BR><BR>
<DIV ALIGN=CENTER CLASS='dataTitle'>Servicegroup 'services1' Host State Breakdowns:</DIV>
<DIV ALIGN=CENTER>
<TABLE BORDER=0 CLASS='data'>
<TR><TH CLASS='data'>Host</TH><TH CLASS='data'>% Time Up</TH><TH CLASS='data'>% Time Down</TH><TH CLASS='data'>% Time Unreachable</TH><TH CLASS='data'>% Time Undetermined</TH></TR>
<tr CLASS='dataOdd'><td CLASS='dataOdd'><a href='avail.cgi?host=server1.amaze.com%3A1717&show_log_entries&t1=1506233939&t2=1506838739&backtrack=4&assumestateretention=yes&assumeinitialstates=yes&assumestatesduringnotrunning=yes&initialassumedhoststate=3&initialassumedservicestate=0&show_log_entries&showscheduleddowntime=yes&rpttimeperiod=24x7'>server1.amaze.com1717</a></td><td CLASS='hostUP'>100.000% (100.000%)</td><td CLASS='hostDOWN'>0.000% (0.000%)</td><td CLASS='hostUNREACHABLE'>0.000% (0.000%)</td><td class='dataOdd'>0.000%</td></tr>
<tr CLASS='dataEven'><td CLASS='dataEven'><a href='avail.cgi?host=server2.amaze.com%3A1717&show_log_entries&t1=1506233939&t2=1506838739&backtrack=4&assumestateretention=yes&assumeinitialstates=yes&assumestatesduringnotrunning=yes&initialassumedhoststate=3&initialassumedservicestate=0&show_log_entries&showscheduleddowntime=yes&rpttimeperiod=24x7'>server2.amaze.com</a></td><td CLASS='hostUP'>100.000% (100.000%)</td><td CLASS='hostDOWN'>0.000% (0.000%)</td><td CLASS='hostUNREACHABLE'>0.000% (0.000%)</td><td class='dataEven'>0.000%</td></tr>
<tr CLASS='dataOdd'><td CLASS='dataOdd'><a href='avail.cgi?host=server3.amaze.com%3A1717&show_log_entries&t1=1506233939&t2=1506838739&backtrack=4&assumestateretention=yes&assumeinitialstates=yes&assumestatesduringnotrunning=yes&initialassumedhoststate=3&initialassumedservicestate=0&show_log_entries&showscheduleddowntime=yes&rpttimeperiod=24x7'>server3.amaze.com</a></td><td CLASS='hostUP'>100.000% (100.000%)</td><td CLASS='hostDOWN'>0.000% (0.000%)</td><td CLASS='hostUNREACHABLE'>0.000% (0.000%)</td><td class='dataOdd'>0.000%</td></tr>
<tr CLASS='dataEven'><td CLASS='dataEven'><a href='avail.cgi?host=server4.amaze.com%3A1717&show_log_entries&t1=1506233939&t2=1506838739&backtrack=4&assumestateretention=yes&assumeinitialstates=yes&assumestatesduringnotrunning=yes&initialassumedhoststate=3&initialassumedservicestate=0&show_log_entries&showscheduleddowntime=yes&rpttimeperiod=24x7'>server4.amaze.com</a></td><td CLASS='hostUP'>100.000% (100.000%)</td><td CLASS='hostDOWN'>0.000% (0.000%)</td><td CLASS='hostUNREACHABLE'>0.000% (0.000%)</td><td class='dataEven'>0.000%</td></tr>

除了这个html输出之外,有没有办法获得csv格式或json的数据? 我知道如果我在浏览器中查询相同的内容,它会在正确的HTML页面中显示结果,但我的进一步用例是不同的,我想从这里评估数据,所以我需要这种格式的报告,以后我可以操作根据需要使用语言(例如: - python)。

1 个答案:

答案 0 :(得分:0)

https://username:password@nagioshostname/nagios/jsonquery.html

选择&#34;归档JSON CGI&#34;然后设置&#34;查询&#34;到&#34;可用性&#34;。

有很多选项可供具体使用。

享受:)