30-Apr-2014

NRPE on OpenVMS

I have a pretty extensive Nagios setup here, that monitors everything from network links, OpenVMS services, Windows server availability, and Linux.

Because I haven't installed NRPE on Windows as I don't manage those boxes, some people in the Windows Team have recently been looking at Microsoft's SCOM product. I thought I better demo NRPE, at least on OpenVMS.

I got the OpenVMS NRPE kit, but this code seems to be fairly old (no IA64 references). But as all the code was there, it appeared to build just fine on IA64.

Unfortunately, there are a couple of "gotchas" in the kit, both in the documentation, and in the implementation. First, let's fix a bug in the code that of course only rears its head when you set the DEBUG flag in NRPE.CFG to 1 (which you want to do when you are initially configuring the service).

The bug is in the CUSTOM.C module. Replace this source:

void syslog(int priority, char *message, ...){
        char buffer[MAX_INPUT_BUFFER];
        va_list arguments;

        va_start(arguments, message);

        sprintf(buffer, message, va_arg(arguments, char *));
        printf("%d: %s\n", priority, buffer);

        va_end(arguments);
}

With this:

void syslog(int priority, char *message, ...){
        char buffer[MAX_INPUT_BUFFER];
        va_list arguments;

        va_start(arguments, message);

        vsprintf(buffer, message, arguments);
        printf("%d: %s\n", priority, buffer);

        va_end(arguments);
}

This prevents an access violation if there are no optional arguments (the result of a va_arg on nonexistent arguments is undefined in the C specification).

The other unfortunate bit is a combination of the documentation, that advises you to create logical names containing a dollar sign (which is generally not recommended); and omissions in the configuration file.

Because the documentation tells you to create a logical containing a dollar sign, you have to specify command definitions that will be examined for macro substitution with an escaped dollar sign ($$) as the dollar sign is the macro introducer in Nagios.

If you look in the NRPE.CFG file supplied in the kit, you will see this is commands such as

command[check_test]=@nrpe$$scripts:check_test.com

But just below this is

command[check_cpu]=@nrpe$scripts:check_system.com CPU

which only supplies a single dollar sign. Because of this, the macro processor assumes you've carelessly left a trailing dollar sign off and supplies you with one. The command finally executed is

@nrpe$scripts:check_system.com CPU$

which doesn't work.

To fix, simply add the extra dollar sign in the NRPE.CFG file (or better yet, ignore the documentation and don't use a dollar sign in your logical names at all).

Posted at April 30, 2014 5:14 PM
Tag Set:

Comments are closed