[Nagiosplug-devel] check_dns.c

Awais Ahmad awais at eurobell.net
Tue Sep 30 08:22:03 CEST 2003


Hi,

Does anyone see any utility in rewriting check_dns.c to use gethostbyname(),
instead of nslookup?. 
Also, is just just querying for an A record really enough functionality for
a plugin which checks name servers?

Cheers

Awais

-----Original Message-----
From: Voon, Ton [mailto:Ton.Voon at egg.com]
Sent: Tuesday, September 30, 2003 8:55 AM
To: 'Karl DeBisschop'
Cc: NagiosPlug Devel
Subject: RE: [Nagiosplug-devel] RFC: OS specific ifdefs in main plugin
cod e


> -----Original Message-----
> From: Karl DeBisschop [mailto:karl at debisschop.net] 
> Sent: Tuesday, September 30, 2003 5:58 AM
> To: Ton Voon
> Cc: NagiosPlug Devel
> Subject: Re: [Nagiosplug-devel] RFC: OS specific ifdefs in 
> main plugin code
> 
> 
> On Mon, 2003-09-29 at 10:46, Voon, Ton wrote:
> > Hi! Wanted to get some opinions on the latest development 
> of the plugins.
> > 
> > I'm starting to use OS specific ifdefs to get system data and I was
> > wondering if this is the right way to go. The latest 
> version of check_swap.c
> > has ifdefs for Solaris and AIX as they have different ways 
> for checking
> > swap. It could have been done via ./configure, but there 
> are too many
> > different possibilities (for instance, need to run 
> different switches for
> > individual partition checks versus a summary of swap). 
> > 
> > If it was done via ./configure, you'd also need to set 
> flags to say whether
> > to ignore first lines (some have header info, others 
> don't), work out
> > different format responses (some return megabytes, some 
> return free, some
> > return percentage).
> > 
> > I think all this is easier done within the code itself. Is this bad?
> 
> What I don't like is use of targets like #ifdef _AIX or #ifdef sun --
> for instance, SGI IRIX also has a swap command with very 
> similar syntax.
> Except it is in /sbin instead of /usr/sbin. It's not at all obvious to
> me why we needs sun-specific code, but not IRIX-specific code (or more
> to the point, why can't we write generic code that tests whether the
> swap command accepts the '-s' switch, and forgo the #ifdef sun.

The reason for the sun specific code is that swap -l does not report
"allocated but not used" swap, thus giving "wrong" results on free
(available) swap. This is only available with swap -s. There was a thread on
this about 9 months back.

The trouble with IRIX which "also has a swap command with very similar
syntax" is that the syntax is similar but not the same. So we would have to
have ./configure work in parsing the output differently. But sometimes it is
more than just the sscanf order: there is also if there is a header line, if
the syntax returns MBs or bytes or percentage, if the results are for free,
used or total.

I guess these could be abstracted out to a generic function, but then the
parameters to this function will probably need to be written very
"code-like", so why not use code?

> 
> To use things like #ifdef sun, unless absolutely needed, would seem to
> require perfect knowlege of all Uinx-like OS's in use, and perfect
> knowlege of those extensions that do not yet exist.
> 
> Often, this is a symptom that there is a basic problem. In fact, we
> really see this issue in 3 plugins: check_ping, check_procs, and
> check_swap.
> 
> From my point of view, we should be using a C API in POSIX for these
> functions, rather than trying to parse comannd-line utilities.

I agree, but these are not always readily available hence the hackery.
Eventually, I guess nagiosplug is basically a command-line way of getting a
common result from all OSes.

> 
> Certainly we can write a check_icmp, and probably should. If we can
> identify an apporpriate API for swap and procs, we should do the same
> for them. If not, I am much more ready to accept OS-specific 
> ifdefs for
> procs than I am for swap. There are only a handful of swap variants.

I only have Solaris, AIX and Darwin knowledge and they all handle swap
differently (Darwin doesn't even preallocated swap space - it just
dynamically grows).

check_procs doesn't have any ifdefs, maybe because the abstration is
better/easier. Even so, I've had to add in extra variables to ./configure
like number of columns to get round some inconsistencies (AIX's ps does not
have an RSS field).

> AFAICT, if there ar n varieties of Unix, there must be n+1 
> varieties of
> the ps command.
> 

If we continue with the ifdef method, in future we could abstract out as we
understand the different cases better.

Ton


This private and confidential e-mail has been sent to you by Egg.
The Egg group of companies includes Egg Banking plc
(registered no. 2999842), Egg Financial Products Ltd (registered
no. 3319027) and Egg Investments Ltd (registered no. 3403963) which
carries out investment business on behalf of Egg and is regulated
by the Financial Services Authority.  
Registered in England and Wales. Registered offices: 1 Waterhouse Square,
138-142 Holborn, London EC1N 2NA.
If you are not the intended recipient of this e-mail and have
received it in error, please notify the sender by replying with
'received in error' as the subject and then delete it from your
mailbox.



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Nagiosplug-devel mailing list
Nagiosplug-devel at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagiosplug-devel
::: Please include plugins version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null




More information about the Devel mailing list