[Nagiosplug-devel] RFC: OS specific ifdefs in main plugin code

Karl DeBisschop karl at debisschop.net
Mon Sep 29 22:00:03 CEST 2003


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.

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.

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.
AFAICT, if there ar n varieties of Unix, there must be n+1 varieties of
the ps command.

--
Karl

--
Karl





More information about the Devel mailing list