NAGIOS | poor mans report scripting

You wanna report some stuff to nagios the easy way? Try this.

Nagios server side:

Install netcat.

Run a eternal loop script:

# while true; do nc -l -p <THE_PORT_YOU_WANNA_LISTEN_TO> >> /var/nagios/rw/nagios.cmd; done&

Client side:

Install netcat.

Drop your info to the NAGIOS server with something like:

# echo -e "[$(date +%s)] PROCESS_SERVICE_CHECK_RESULT;<NAGIOSCONFIG_SERVER_NAME>;<NAGIOSCONFIG_SERVICE_NAME>;<RESULT_0_or_1_or_2>;<YOUR_IMPORTANT_MESSAGE>"  | nc -q 0 nagios.MYDOMAIN.MYTLD <THE_PORT_THE_SERVER_IS_LISTENING>

Attention: PROCESS_SERVICE_CHECK_RESULT is not a variable but a hard coded string.

Example for a warning:
# echo -e "[$(date +%s)] PROCESS_SERVICE_CHECK_RESULT;MyServer;MyServersService;1;I have to warn you."  | nc -q 0 nagios.myserver.mytld 65432

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.