Problem with perfdata file in Nagios 2.9?

Thomas Guyot-Sionnest dermoth at aei.ca
Sat Apr 14 04:53:02 CEST 2007


On 13/04/07 10:17 PM, william(at)elan.net wrote:
> 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.

The FD is reopened only after running the perfdata command. If you don't
define one, the FD is never reopened (Useful for pipes only).

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

That would be worse. For optimal performances you should do something
like this:

http://www.control-alt-del.org/code/NPDaemon/

NOTE: The code there is not up to date. Please mail me directly for the
latest version.

You can also use that for OCHP/OCSP:

http://www.nagioscommunity.org/wiki/index.php/OCP_Daemon

It would certainly be possible to do both at the same time (i.e. merging
NPDaemon and OCP_Daemon).

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

That's exactly what you can do with service_perfdata_file_mode=a, just
that it's the perf data processing script that "rotate" the log.

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

That wouldn't be faster than NPDaemon and with NPDaemon you have remote
access to the data as well.

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