nagios api

Andreas Ericsson ae at op5.se
Tue Mar 30 16:37:25 CEST 2004


Tony Sceats wrote:
> So, I suppose I have 1 question and one
> suggestion.. the first question is does Nagios have an API, and is it
> documented anywhere? If so, I suppose it would be in C or C++ ? 

Sort of. You can use cgiutils.c and the xodata stuff in the cgi and 
xodata subdirectories of Nagios.
The code is however in a semi-miserable state (it does pretty much what 
it's supposed to, but configuration variables are in-line, 90% of the 
variables are declared global, optimisations are left to the compiler 
and memory management is a bit sketchy).

It's not documented anywhere except for rather extensive commentary 
within the code itself. You might want to try the 'indent' program on it 
if you want to try following the logic around without suffering 
brain-damage.

> 
> The reason I ask is that I a while
> ago now I wrote a cgi script that will list all the hosts currently
> monitored with nagios.. it does this by parsing the relevant config files,
> and will display this list as series of options.. for each host selected it
> will put a comment in nagios by writing to the named pipe file

Sounds kinda useful, I guess. But with a script you won't be able to 
access a C API without intermittent programs anyway.

> And I suppose a related question would be how would one acknowledge
> things and schedule downtime for this list? Is there a way to do this
> via the named pipe file used for comments mentioned above? 
> 
Read the documentation. It's explained properly there.
You can find it at www.nagios.org

> The suggestion I have is really for some of the plugins, I'm not sure if
> this is the right place to put this... But anyway, it would be nice if they
> supported an option to specify a source address. 

If you're talking about spoofing, you've ended up at the wrong list 
(spoofing requires access to raw sockets, which means non-root users 
can't use them). If it's something else, you might want to clarify that 
a bit.

> I have already patched
> check_http to do this (well, in fact I modified netutils.c), although
> I did this dodgely, as I hard coded the IP (I was extremely short of
> time to do this by the time it was considered to be the only option
> forward). 

Bad Thing, no matter how short on time you are.

> During the course of going over the code it was seen clearly
> that a lot of the plugins would require to be patched as the change had
> to be made to the my_connect function in netutils..

Or you could have copied the my_connect() function to a copy of the 
check_http plugin souce and modified the copied function.

> 
> Tony Sceats

-- 
Mvh / Best Regards
Sourcerer / Andreas Ericsson
OP5 AB
+46 (0)733 709032
andreas.ericsson at op5.se


-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click




More information about the Developers mailing list