Access to status.log via a Perl script

Lyle Giese lyle at lcrcomputer.net
Tue Sep 6 19:06:32 CEST 2005


Andreas Ericsson wrote:

> Lyle Giese wrote:
>
>> I am working on building one of the traffic light project for 
>> Nagios.  (specifically 
>> http://www.nagiosexchange.org/Wiki_Home.wiki.0.html?&tx_drwiki_pi1%5Bkeyword%5D=NagiosTLight 
>> )
>>
>> I have one quick question for the experts here.  It looks like 
>> Juilian got his status via status.cgi and parsed the resulting 
>> webpage that comes back.  I have a small configuration and want to 
>> pull status from status.log file and then customize the status.  I 
>> have most of it written.
>>
>> The question I have is about status.log.  I am writting a small perl 
>> script and opening status.log read-only, read it into an array and 
>> promptly close it.  Will that cause any problems with Nagios?  What 
>> happens if Nagios wants to write to it at the same time this script 
>> is reading status.log?
>>
>
> You'll end up with either an incomplete read, or Nagios will beat you 
> to it and write the data before you have time to read it. Nothing else 
> should happen.
>
> If, on the other hand, you're using Nagios 2.0 you should be reading 
> status.dat instead, since it contains the most recent info. That file 
> is not appended to. Instead, nagios creates a temporary file and 
> renames it when it's done writing. The GUI does exactly what you're 
> suggesting, and no problems have been reported due to that (although 
> the gui mmap()'s the file readonly rather than opening it and reading 
> it. I'm not sure that option is available in perl).
>
Juilian's script seemed to only read the status of a host from what I 
could piece together.  I wanted to customize the traffic light in that 
for instance on host A, if service http is down, I want that to be a red 
on the traffic light, but if ftp was down on the same host, that would 
rate a yellow. Basicaly, customizing the traffic light based on what the 
importance of a certain service is in the scheme of our operations.

You seem to indicate that I can read the GUI in the same manner, but I 
was unable to find any real docs on status.cgi(I am currently running 
v1.1 of Nagios) to find the options I could pass to it to get back the 
info I want access to.  And I am not a great programmer either.

An incomplete read could cause the status to change to green and then on 
the next read back to yellow or red as the case maybe, but neither would 
be of that great of importance in the operations here.

Thanks,
Lyle


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
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