parsing tac.cgi output

Páll Guðjón Sigurðsson palli at ok.is
Thu Jan 3 12:09:00 CET 2013


Hi andy,

as for the tac.cgi i think your best bet is to parse the html. 

Alternatively if you have pynag installed on the nagios server you can use this script:

import pynag.Parsers
s = pynag.Parsers.status()
s.parse()

all_services = s.data['servicestatus']
unhandled_problems = [service for service in all_services if service['current_state'] != '0' and service['problem_has_been_acknowledged'] == '0' ]

print len(unhandled_problems)



If your script is not running on the nagios server itself, consider using mklivestatus to get the total number of problems (either shell script or pynag)

Kind regards,
Pall Sigurdsson


----- Original Message -----
From: "Andy Moran" <amoran at apple.com>
To: "Nagios Users List" <nagios-users at lists.sourceforge.net>
Sent: Wednesday, January 2, 2013 7:00:41 PM
Subject: [Nagios-users] parsing tac.cgi output


Does tac.cgi have a way to output JSON or XML or another machine-parsable output?

Specifically I'm looking to have an external script query the number of un-acknowledged critical problems in the nagios cluster. 


Apologies if this has been asked before. 

Cheers!

--Andy

------------------------------------------------------------------------------
Master Java SE, Java EE, Eclipse, Spring, Hibernate, JavaScript, jQuery
and much more. Keep your Java skills current with LearnJavaNow -
200+ hours of step-by-step video tutorials by Java experts.
SALE $49.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122612 
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null

------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122712
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null





More information about the Users mailing list