check_many plugin

Posted by dermoth on 9 June 2009 - 6:38pm in

Overview

This proposal is for a simple plugin wrapper allowing aggregation and serialisation of multiple checks.

Problem

There is no easy way to configure a single nagios service that aggregates multiple results together. Taking for example a standard "check_nagios" between servers, how can such checks be extended to cover additional components? Usually it involves writing a custom shell wrapper around them, of configuring all the checks separately and using check_cluster to aggregate them. There ought to be a better way...

Proposal

Written in C, check_many would be a fairly simple and fast solution for this issue. The idea is a plugin that takes checks commands from STDIN; one command per line. It would run them and aggregate them according to processing preferences as configures in the plugin arguments.

Check Options

The following options can be used to control plugin processing (grouped by category):

Command Parsing


-s, --shell=<always|never|auto>
Specify when a shell should be invoked for executing commands. "always" invokes the shell for every command, "never" forces commands to to executed directly, and "auto" (default) invokes the shell only is shell meta-characters are present in the check command.
Unless -d (--delimiter) is specified, any whitespace is used for separating arguments.

-d, --delimiter=CHARACTER
Delimiter to use for separating command arguments when shell is not used. Implies --shell=never and is mutually exclusive with any other shell option. Standard backslash escapes are allowed, except "\n".

Note: Should we allow strings as delimiters?

Processing Option


-P, --process=<all|first-fail|first-ok>
By default, all command are processed and the worst state is returned ("all"). "first-fail" stops at the first non-ok check and return it, while first-ok stops at the first successful check and return it. The latter two overrides --status and --output option and return the plugins's instead.

-f, --file=FILE
Read checks form FILE instead of STDIN

Output Options


--output=<normal|oneline|status&gt
"normal" outputs Nangios v3+ multi-line result, first line being a summary of the checks performed, "oneline" squeezes everything in a single line, and "status" returns only a status line". This option has no effect with --process=first-fail|first-ok

Note: How about allowing Nth result?

Examples

Aggregate multiple checks together:


echo -e "/path/check_http -H www.example.com\n/path/check_http -H www.example.com -p 443" | /path/check_many

Get list of checks from a file:

/path/check_many <~nagios/multiple_checks.txt
/path/check_many -f /home/nagios/multiple_checks.txt

Using a delimiter:

echo -e '/path/check_foo:-H:example.com\n/path/check_bar:-H:example.com:-s:$some string with "shell-intrepretable" characters;' | /path/check_many -d:

Comment viewing options
Select your preferred way to display the comments and click "Save settings" to activate your changes.
Hi Thomas, kind of deja vu:

Hi Thomas,

kind of deja vu: some of your ideas are already realized in check_multi:
http://my-plugin.de/check_multi.

But that one is written in Perl, which allows to specify flexible expressions in order to evaluate the child plugin's results and determine the final status.

Cheers,
-Matthias

Posted by mflacke on 19 June 2009 - 9:40pm
I see this was written in

I see this was written in 09, can you write an updated post regarding this? - Aaron Kocourek

Posted by Aaron Kocourek on 19 June 2011 - 5:24am