output: use symbolic exit values for nagios commands

And ensure the exit values are set no matter how user will limit output.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
Sami Kerola 2014-03-24 21:56:34 +00:00
parent 5454ab7086
commit eb55946595
2 changed files with 15 additions and 3 deletions

View file

@ -191,6 +191,13 @@ enum limbits {
BIT3 = 0x4
};
/*! \def STATE_OK
* \brief Nagios alarm exit value.
*/
#define STATE_OK 0
#define STATE_WARNING 1
#define STATE_CRITICAL 2
/* Global variables */
/* \var prefix_length Length of each prefix. */
int prefix_length[2][NUM_OF_PREFIX];

View file

@ -1070,16 +1070,21 @@ int output_alarming(void)
shared_p++;
}
}
if (sc || rc)
ret_val = STATE_CRITICAL;
else if (sw || rw)
ret_val = STATE_WARNING;
else
ret_val = STATE_OK;
if ((0 < rc && config.output_limit[1] & BIT1) || (0 < sc && config.output_limit[1] & BIT2)) {
ret_val = 2;
fprintf(outfile, "CRITICAL: %s:",
program_name);
} else if ((0 < rw && config.output_limit[1] & BIT1) || (0 < sw && config.output_limit[1] & BIT2)) {
ret_val = 1;
fprintf(outfile, "WARNING: %s:",
program_name);
} else {
ret_val = 0;
if (config.output_limit[1] & BIT3)
fprintf(outfile, "OK:");
else