Fwd: Fwd: Nagios core patches for External Command support in Cygwin

Tevfik Karagulle tevfik.karagulle at gmail.com
Wed Feb 16 15:34:07 CET 2011


---------- Forwarded message ----------
From: Tevfik Karagulle <tevfik.karagulle at gmail.com>
Date: Wed, Feb 16, 2011 at 2:25 PM
Subject: Re: [Nagios-devel] Fwd: Nagios core patches for External Command
support in Cygwin
To: Thomas Guyot-Sionnest <dermoth at aei.ca>


Hi Thomas,

There are more than 2000 downloads of Nagwin 1.0.1 containing the patch so
far and it seems that it works as expected: I haven't heard any issue
regarding the processing of external commands.

As you've suggested before, this patch can be implemented as a feature
rather than a part of Cygwin porting. Naming of the feature:
'use-plain-files-for-external-commands' ? Is it too long ?
'plain-files-for-external' ?

The CYGWIN file is then a very short one:
An experimental patch addressing problems with named pipes on Cygwin is
activated for building on Cygwin.

Attached you can find the README for the patch. Feedback is welcome! Patches
are available at
http://sourceforge.net/projects/sereds/files/Nagios/nagwin/1.0.1/

Just let me know if you need more !!

Best regards
Tevfik


On Fri, Jan 28, 2011 at 4:58 AM, Thomas Guyot-Sionnest <dermoth at aei.ca>wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On 11-01-27 10:31 PM, Tevfik Karagulle wrote:
> > Hi,
> >
> > Sounds good. I have already made some optimizations and it seems to work
> > as expected.
> >
> > Updated patch is now a part of the recently released Nagwin 1.0.1.
> > Source code is also available from Nagwin download address.
> >
> > I will wait one week or so to see how it performs. As you suggested, it
> > is better to implement it as a feature.
> >
> > Regarding documentation, what are your expectations :-) ? Any examples
> > or guidelines that can help ?
>
> For now, a "CYGWIN" file in the root dir where we can add instructions
> on building/using under cygwin will do. I'll make it cleat this is
> experimental...
>
> Your command pipe replacement should be documented in enough details for
> someone comfortable with Nagios to be able to use it (i.e. control
> Nagios with it) without reading the code.
>
> Thanks
>
> - --
> Thomas
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAk1CPvsACgkQ6dZ+Kt5BchZlxQCgsIBxrlUB1xCBJe2jl+vTAEWa
> +zIAn0NsuRLLD8ymu/8PSPLLXXUA9DOX
> =DQfo
> -----END PGP SIGNATURE-----
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.monitoring-lists.org/archive/developers/attachments/20110216/396b99a6/attachment.html>
-------------- next part --------------
NAGIOS PATCH for EXTERNAL COMMAND INTERFACE VIA PLAIN FILES
February 2011

1. BACKGROUND

Nagios' external command interface is heavily based on named pipes.
During porting of Nagios to the Cygwin platform, it's been observed
that the current named pipe implementation in Cygwin is somewhat
broken and unstable. This fact is also verified by Cygwin developers
(See http://cygwin.com/ml/cygwin/2010-08/msg00459.html for more info).

Several approaches have been evaluated to overcome the problem, and a
simple scheme based on 'one-plain-file-for-each-external-command' is 
chosen. The basic motivation behind this decision is to use something
that works well at all circumtances (file system/directories).
This is not perfect/sleek/state-of-art solution, but it should be more
than enough for environments with average load and use of external
commands.

The scheme itself is not dependent on Cygwin and can be used
on other platforms as well.

2. DESIGN

2.1. Creation

Every time Nagios receives an external command via the external command
interface, a plain file containing the command itself is created.
The format of the file name is as follows:

   nagios.cmd.nnnnnnnnnnnnnnnnnnnn

where 'nnnnnnnnnnnnnnnnnnnn' is 20-digit timestamp in milliseconds:

2.2. Processing

Every time Nagios wants to process external commands, it scans the
external-commands directory and puts up to 512 files to an internal
array. Entries in that array will then be sorted in ascending order
by the built-in quick sort function. If there is enough room in the
external commands buffer, each file is read, the content is submitted
as an external command before the file itself is deleted.

In all circumstances, Nagios will release the memory used for file
entries back to the system.

3. IMPLEMENTATION

Nagios external command interface CGI ('cmd.cgi') is patched to produce
file names according to the format used in that approach.

'utils.c' is patched for processing of external commands.

If sysadmins/developers want to send their external commands directly,
they can use the C-code below, to produce a file name according to the
format used in that approach:

>>C-CODE
#include <stdlib.h>
#include <sys/time.h>
....
struct timeval time_of_day;
char command_file_plain[MAX_FILENAME_LENGTH];
....
gettimeofday(&time_of_day, NULL);
/* create a file name by using time of day in millisecs as postfix 
preceded by a dot, largest 64-bit number can be represented by 20 
decimal digits  */
(void) sprintf (command_file_plain, "%s.%020lu", command_file, 
   (long) (time_of_day.tv_sec * 1000 + time_of_day.tv_usec / 1000));
>>C-CODE

-------------- next part --------------
------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
-------------- next part --------------
_______________________________________________
Nagios-devel mailing list
Nagios-devel at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-devel


More information about the Developers mailing list