schedule a service check
HOST_NAME=www.example.com SERVICE_NAME=APT /usr/bin/printf "[%lu] SCHEDULE_FORCED_SVC_CHECK;%s;%s;%s\n" $(date +%s) "${HOST_NAME}" "${SERVICE_NAME}" $(date +%s) | tee -a "${NAGIOS_CMD_SOCKET}"
schedule a host check
NAGIOS_CMD_SOCKET=/var/lib/icinga/rw/icinga.cmd /usr/bin/printf "[%lu] SCHEDULE_HOST_CHECK;%s;%s\n" \ $(date +%s) \ "host_name" \ $(date +%s) | tee -a $NAGIOS_CMD_SOCKET curl -d "cmd_typ=7&host=www.example.com&service=APT&force_check&btnSubmit=Commit" "http://monitoring.example.com/cgi-bin/icinga/cmd.cgi" -u 'foo:bar'
Schedule downtime
https://assets.nagios.com/downloads/nagioscore/docs/externalcmds/cmdinfo.php?command_id=118
HOST=www.example.com STARTDATE=$(date +%s) ENDDATE=$(($(date +%s) + 7200)) printf "[%lu] SCHEDULE_HOST_DOWNTIME;${HOST};${STARTDATE};${ENDDATE};0;0;7200;rundeck;Deployment" ${STARTDATE} > /data/icinga/var/rw/icinga.cmd
Schedule downtime for specific services
IFS=$(echo -en "\n\b") STARTDATE=$(date +%s) ENDDATE=$(date +%s -d "next monday 12:00:00") DURATION=$((${ENDDATE} - ${STARTDATE})) KNOWN_ISSUES=" srv1-dev,Swap Usage srv3-prod,Hardware " for ISSUE in ${KNOWN_ISSUES}; do HOST=$(echo ${ISSUE} | cut -d"," -f1) SERVICE="$(echo ${ISSUE} | cut -d"," -f2)" echo "HOST: ${HOST}" echo "SERVICE: ${SERVICE}" printf "[%lu] SCHEDULE_SVC_DOWNTIME;${HOST};${SERVICE};${STARTDATE};${ENDDATE};0;0;${DURATION};SysAdmin1;FixMe" ${STARTDATE} > /data/icinga/var/rw/icinga.cmd sleep 1 done
Links
http://www.box293.com/guides/tricks/nagios-command-pipe-and-cgis
https://icinga.com/docs/icinga1/latest/en/cgiparams.html
https://stackoverflow.com/questions/6842683/how-to-set-downtime-for-any-specific-nagios-host-for-certain-time-from-commandli