(socat is like netcat on steroids, a very useful thing)
process_remote_command is a basic filter that currently drops all lines not containing SCHEDULE_HOST_DOWNTIME. It expects an external command in the proper forward then prints it to the command file.
On a host, I run:
echo “$COMMAND;$HOST;$START;$END;$FIXED;$TRIGGER;$DURATION;$AUTHOR;$COMMENT” | socat -u STDIN TCP:nagiosserver:5668
What this allows me to do is add a downtime remotely. If I have a server that is set to reboot nightly via a cron, I can add commands to that cronjob script to automatically schedule downtime for that host.
#Convert start and end times in seconds since epoch, in UTC local time
START=date --date="$START" +%s
END=date --date="$END" +%s
#Fixed will start and end precisely at the times given if FIXED=1. Otherwise, it starts somewhere BETWEEN start #and end times and last for DURATION seconds. Nagios will start the timer when it sees the host go down #and suspend notifications until the DURATION is reached
FIXED=0
#Trigger ID. Nagios will trigger this downtime if another downtime happens (Trigger ID = ID of the other downtime)
TRIGGER=0