Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

How to access Nagios Availability-Report files to retrieve "UP Time Percent" and so other information about Hosts and Services?

I know It can be accessed through Nagios CGI but I want to use it on a custom interface. Can I use those CGI Script to achieve what I want?

share|improve this question
    
Which custom interface are you using? –  Epaphus Dec 29 '12 at 21:18
    
Thank you. I wrote one in PHP myself. actually It's just something to fulfill my needs. –  Super Mario Dec 29 '12 at 21:35
add comment

1 Answer

up vote 4 down vote accepted

Looks like the Nagios Availability-Report is generated using the cgi-bin/avail.cgi script looking at the source code for the cgi script it reads the nagios log files and generates the reports on the fly.

You could either pass the arguments to the avail.cgi script or you could parse the nagios.log file and the archives which on my system is located in nagios/var/archives to generate your own reports.

A report for all host groups for the last 7 days with first assumed state as up/ok would look like the following

http://nagios/cgi-bin/avail.cgi?show_log_entries=&hostgroup=all&timeperiod=last7days&smon=12&sday=1&syear=2012&shour=0&smin=0&ssec=0&emon=12&eday=31&eyear=2012&ehour=24&emin=0&esec=0&rpttimeperiod=&assumeinitialstates=yes&assumestateretention=yes&assumestatesduringnotrunning=yes&includesoftstates=no&initialassumedhoststate=3&initialassumedservicestate=6&backtrack=4

Just as another thought, you could download the CGI script source code and edit it so the output matches your requirement and then compile the CGI and use it.

share|improve this answer
    
Thanks, You mean using the command line options? How can I get the exact value? –  Super Mario Dec 31 '12 at 8:21
    
I mean via a web request, you would then either have to just display the web page the script returns or do some thing which would pull out the data you need so that it can be in the same style as the custom UI. You can get the values by going direct to the script in a web browser as all the options look to be passed as a get request. –  Epaphus Dec 31 '12 at 11:33
    
updated answer. –  Epaphus Dec 31 '12 at 11:39
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.