Menu

#3 Pull nsc nagios data from commandline for use in scripts/app

open
nobody
None
5
2005-05-24
2005-05-24
No

Running the command:

nsc --summarize (or -s)

This would make nsc load status.log, parse it,
summarize it, print a number of lines to stdout and
then exit. Curses would not be startet.

The output would be something like:

OK: Services crit/warn/other/ack/ok: 0/0/1/1/65
DOWN: Hosts down/unreach/ack/up: 2/0/0/14
(and then a detailed list of failed services & hosts,
all the red, yellow, etc. stuff)

The '.' terminates the list, which can be fed to head:

nsc -s | head -1

or sed:

nsc -s | sed -e '1,2d' #skip summaries, only
details

After the summary output, nsc will exit with an
appropriate status code, so that the caller easily can
determine if everything is fine or if services or hosts
are down.

Exit codes after --summarize:

0: All services OK, all hosts UP
1: Program error or such
2: Acknowledged problems exists
4: Warnings
8: Errors

Also consider:

nsc --summarize --continous=15

Which would make nsc loop and print the summary every
15 seconds until killed. This is pretty much the same
functionality as 'top -b'. A line with '.' or something
would be usefull to let the caller know that the end of
the list have been reached.

Discussion


Log in to post a comment.

Auth0 Logo