1 nagios.cfg:
2 ===========
4 obsess_over_services=1
5 ocsp_command=ocsp2out
6 obsess_over_hosts=1
7 ochp_command=ochp2out
10 commands:
11 =========
13 define command {
14 command_name ocsp2out
15 command_line echo >>/tmp/nagixsc.spool/new/$TIMET$ LASTSERVICECHECK::$LASTSERVICECHECK$ HOSTNAME::\'$HOSTNAME$\' SERVICEDESC::\'$SERVICEDESC$\' SERVICESTATEID::$SERVICESTATEID$ SERVICEOUTPUT::\'$SERVICEOUTPUT$\' LONGSERVICEOUTPUT::\'$LONGSERVICEOUTPUT$\'
16 }
18 define command {
19 command_name ochp2out
20 command_line echo >>/tmp/nagixsc.spool/new/$TIMET$ LASTHOSTCHECK::$LASTHOSTCHECK$ HOSTNAME::\'$HOSTNAME$\' HOSTSTATEID::$HOSTSTATEID$ HOSTOUTPUT::\'$HOSTOUTPUT$\' LONGHOSTOUTPUT::\'$LONGHOSTOUTPUT$\'
21 }
24 Advantages/benefits:
25 ====================
27 - Do NOT start a shell to analyse the return-code and then format a string
28 using "printf" as documented in the original documentation.
29 - Block the Nagios process for a minimum amount of time. The original script
30 calls "send_nsca" directly, thus blocking Nagios until the NSCA network
31 packet has been sent (which might include a timeout in case the server is
32 unreachable). Here, we only write a single spool-file from the shell started
33 by Nagios.
34 - Send multiple check results at once. Nagios writes multiple check results
35 basically at the same time. While NSCA uses one network connection for every
36 single one of those (which requires a TCP handshake, etc. for each of them),
37 Nag(ix)SC creates a single XML file from all entries in the spool file.
38 - A separate, stand-alone process ("obsess_daemon.py") takes care of sending
39 the XML file.
42 Caveats:
43 ========
45 - "obsess_daeon.py" is not a real daemon yet. Start it in a terminal (and
46 watch the debugging output).
47 - Watch what's going on:
48 % cd /tmp/nagixsc.spool
49 % watch -n2 "cat */*[0-9] | wc -l; (for F in xmlout/*; do
50 ~/src/nagixsc/nagixsc_read_xml.py -f \$F; done) | grep -c RetCode"