Problem with perfdata file in Nagios 2.9?

william(at)elan.net william at elan.net
Sat Apr 14 04:17:01 CEST 2007


This is not entirely optimal when for each write nagios has to open a
file again rather then being able to keep old fd and file open.

Have you guys though of doing some other way, perhaps reading and
parsing status.dat file directly (looking for 'performance_data' in
there). Would there be good reasons it would not work well?

Also what about having nagios write performance data into a file but
rotate it once/day [or hour for larger setup], in this case it would
shift to nagios performance processing program to keep track of where
it was last time, but I think this is better for large setup?

Also would there be an interest in people seeing a patch that as an
option changes so that nagios sends performance data through UDP 
(you can also do that with external command like 'nc', but that's
extra process being open each time)?

On Thu, 12 Apr 2007, Thomas Guyot-Sionnest wrote:

> On 12/04/07 11:58 AM, Frost, Mark {PBG} wrote:
>> Hello.  I recently posted to the Nagios-users list about an issue that
>> seems to have cropped up since I moved to 2.9.
>>
>> I use Nagiosgraph 0.8.2.  My nagios.cfg file has the following
>> configuration options:
>>
>> 	process_performance_data=1
>> 	service_perfdata_file_mode=a
>> 	service_perfdata_file_processing_interval=30
>
> There was a bug in 2.8 and earlier were perfdata_file_mode=a were
> writing and perfdata_file_mode=w were appending. change it to "w" and
> you'll get the old behavior.
>
> My understanding is that you never remove the file in your perfdata
> processing script so that in 2.8, when told to write, the file was
> truncated when Nagios was reopening it. The correct fix is to remove the
> file before returning back to nagios.
>
> For better performance I'd suggest something like this:
>
> open(PERFDATA, "<$perfdata_file") or die;
> if ((my $test=fork) == 0) {
>  # Do something useful here
>  close (PERFDATA);
>  exit (0);
> } elsif ($test > 0) {
>  # Fork forked, remove file and return
>  unlink ($perfdata_file);
>  close (PERFDATA);
>  exit (0);
> } else {
>  # Something went wrong! Don't remove the file, Nagios
>  # will keep appending to it.
>  close (PERFDATA);
>  exit (1);
> }
>
> This will open the file, remove it and return immediately to nagios
> while the forked process will continue processing the file. Since the
> file is already opened when it is unlinked the new file won't interfere
> with the one opened by the forked process.
>
> Thomas
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys-and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Nagios-devel mailing list
> Nagios-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/nagios-devel

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV




More information about the Developers mailing list