diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2014-10-22 14:09:54 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2014-10-22 14:09:54 +1300 |
commit | 4b8167c725c31a36a3ee5c7733522ca9ded015d6 (patch) | |
tree | 069f69963a8c57b3239b1a7e4f3540d40c6911f1 /nfc | |
parent | Thank Inspire Net (diff) | |
download | nagscripts-4b8167c725c31a36a3ee5c7733522ca9ded015d6.tar.gz nagscripts-4b8167c725c31a36a3ee5c7733522ca9ded015d6.zip |
Whoops, those are meant to be symlinks
Diffstat (limited to 'nfc')
l---------[-rwxr-xr-x] | nfc | 78 |
1 files changed, 1 insertions, 77 deletions
@@ -1,77 +1 @@ -#!/usr/bin/env bash - -# -# nagios-force-check(1) -- Force an immediate check of a nominated host or -# service. -# -# $ nac <host>[/<service>] -# -# Author: Tom Ryder <tom@sanctum.geek.nz> -# Copyright: 2014 Sanctum -# - -# Name self -self=nagios-force-check - -# Usage printing function -usage() { - printf 'USAGE: %s [-n] <host[/service]>\n' "$self" -} - -# Handle options, just -h help at the moment -OPTIND=1 -while getopts 'h' opt ; do - case "$opt" in - h) - usage - exit 0 - ;; - '?') - usage >&2 - exit 1 - ;; - esac -done -shift "$((OPTIND-1))" - -# Bail if no arguments left; we need at least the host/service name -if ! (($#)) ; then - usage >&2 - exit 1 -fi - -# Define relatively fixed/guaranteed fields for Nagios command; note that the -# comment has a default of 'no comment given' -now=$(date +%s) -spec=$1 -cmdfile=${NAGCMD_FILE:-/usr/local/nagios/var/rw/nagios.cmd} - -# If a service name is specified after a slash, figure that out -if [[ $spec == */* ]] ; then - host=${spec%/*} - service=${spec##*/} -else - host=$spec - service= -fi - -# Write command and print message if it fails; succeed silently -declare -a cmds -if [[ $service ]] ; then - cmds=("${cmds[@]}" "$(printf '[%lu] SCHEDULE_FORCED_SVC_CHECK;%s;%s;%lu' \ - "$now" "$host" "$service" "$now")") -else - cmds=("${cmds[@]}" "$(printf '[%lu] SCHEDULE_FORCED_HOST_CHECK;%s;%lu' \ - "$now" "$host" "$now")") - cmds=("${cmds[@]}" "$(printf '[%lu] SCHEDULE_HOST_SVC_CHECKS;%s;%lu' \ - "$now" "$host" "$now")") -fi - -# Attempt to write command to file -for cmd in "${cmds[@]}" ; do - if ! printf '%s\n' "$cmd" >> "$cmdfile" ; then - printf '%s: Failed to write command to file\n' "$self" >&2 - exit 1 - fi -done - +nagios-force-check
\ No newline at end of file |