Access to status.log via a Perl script

Andreas Ericsson ae at op5.se
Tue Sep 6 17:58:57 CEST 2005


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).

-- 
Andreas Ericsson                   andreas.ericsson at op5.se
OP5 AB                             www.op5.se
Lead Developer


-------------------------------------------------------
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