From 4b8167c725c31a36a3ee5c7733522ca9ded015d6 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 22 Oct 2014 14:09:54 +1300 Subject: Whoops, those are meant to be symlinks --- nac | 98 +--------------------------------------------------------------- nac.1 | 48 +------------------------------ ndt | 101 +----------------------------------------------------------------- ndt.1 | 54 +---------------------------------- nfc | 78 +-------------------------------------------------- nfc.1 | 37 +----------------------- 6 files changed, 6 insertions(+), 410 deletions(-) mode change 100755 => 120000 nac mode change 100644 => 120000 nac.1 mode change 100755 => 120000 ndt mode change 100644 => 120000 ndt.1 mode change 100755 => 120000 nfc mode change 100644 => 120000 nfc.1 diff --git a/nac b/nac deleted file mode 100755 index 5878e40..0000000 --- a/nac +++ /dev/null @@ -1,97 +0,0 @@ -#!/usr/bin/env bash - -# -# nagios-acknowledge(1) -- Shortcut to acknowledge problems in Nagios, because -# it's annoying to do with the web interface for large sets of hosts or -# services. -# -# $ nac [/] [optional comment] -# -# Good for for/while loops: -# -# for hostname in hosta hostb hostc; do nac "$hostname" ... ; done -# while read -r hostname; do nac "$hostname" ... ; done < downtime-hostnames -# -# By default, does not send ACKNOWLEDGEMENT notifications. Use -n if you do -# want that. -# -# Author: Tom Ryder -# Copyright: 2014 Sanctum -# - -# Name self -self=nagios-acknowledge - -# Usage printing function -usage() { - printf 'USAGE: %s [-n] [comment]\n' "$self" -} - -# Default to not notifying -notify=0 - -# Figure out whether we should notify -OPTIND=1 -while getopts 'hn' opt ; do - case "$opt" in - n) - notify=1 - ;; - 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 -sticky=1 -notify=$notify -persistent=1 -author=${SUDO_USER:-$USER} -comment=${2:-'no comment given'} -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 - -# Quietly replace semicolons in comment with commas -comment=${comment//;/,} - -# Write command and print message if it fails; succeed silently -if [[ $service ]] ; then - cmd=$(printf '[%lu] ACKNOWLEDGE_SVC_PROBLEM;%s;%s;%u;%u;%u;%s;%s' \ - "$now" "$host" "$service" \ - "$sticky" "$notify" "$persistent" "$author" "$comment") -else - cmd=$(printf '[%lu] ACKNOWLEDGE_HOST_PROBLEM;%s;%u;%u;%u;%s;%s' \ - "$now" "$host" \ - "$sticky" "$notify" "$persistent" "$author" "$comment") -fi - -# Attempt to write command to file -if ! printf '%s\n' "$cmd" > "$cmdfile" ; then - printf '%s: Failed to write command to file\n' "$self" >&2 - exit 1 -fi - diff --git a/nac b/nac new file mode 120000 index 0000000..6b321ef --- /dev/null +++ b/nac @@ -0,0 +1 @@ +nagios-acknowledge \ No newline at end of file diff --git a/nac.1 b/nac.1 deleted file mode 100644 index 48f31f7..0000000 --- a/nac.1 +++ /dev/null @@ -1,47 +0,0 @@ -.TH NAGIOS-ACKNOWLEDGE 1 "Nagios Acknowledge" "Nagscripts" -.SH NAME -.B nac, nagios-acknowledge -\- Pleasant way to acknowledge problems with a Nagios host or service -.SH USAGE -.B nagios-acknowledge --h -.br -.B nagios-acknowledge -[-n] -.I HOSTNAME[/SERVICE] -.I [COMMENT] -.SH SYNOPSIS -.B nac -webhost 'DDoS I think, fixing' -.PP -.B nac --n webhost/HTTP 'Apache HTTPD crashed, fixing' -.PP -for hostname in ns{1..3} ; do -.br -.B - nac -"$hostname" 'DNS is completely rooted, addressing now' -.br -done -.SH DESCRIPTION -.B nagios-acknowledge -will format and attempt to write a Nagios command to the Nagios commands file -which it expects to find at /usr/local/nagios/var/rw/nagios.cmd to acknowledge -a problem for a particular host or service. -.PP -The user's current login name will be used as the author field for the -acknowledgement, taking into account any use of -.I sudo(8) -changes. Note that the -.I COMMENT -parameter is optional. -.P -By default, the script won't send an ACKNOWLEDGEMENT notification. Add a -n -option if you actually want to do this. -.SH SEE ALSO -nagios-downtime(1), nagios-force-check(1) -.SH AUTHOR -Tom Ryder -.PP - diff --git a/nac.1 b/nac.1 new file mode 120000 index 0000000..abde110 --- /dev/null +++ b/nac.1 @@ -0,0 +1 @@ +nagios-acknowledge.1 \ No newline at end of file diff --git a/ndt b/ndt deleted file mode 100755 index 9a886e0..0000000 --- a/ndt +++ /dev/null @@ -1,100 +0,0 @@ -#!/usr/bin/env bash - -# -# nagios-downtime(1) -- Shortcut to scheduling fixed downtime in Nagios, -# because it's annoying to do with the web interface for large sets of hosts -# or services. -# -# $ ndt [/] [optional comment] -# -# Good for for/while loops: -# -# for hostname in hosta hostb hostc; do ndt "$hostname" ... ; done -# while read -r hostname; do ndt "$hostname" ... ; done < downtime-hosts -# -# Assumes date(1) with +%s format and --date option (probably only GNU date). -# -# Author: Tom Ryder -# Copyright: 2014 Sanctum -# - -# Name self -self=nagios-downtime - -# Usage printing function -usage() { - printf 'USAGE: %s [comment]\n' "$self" -} - -# Process options (just 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 too few arguments left; we need at least the hostname, the start date, and the end date -if (($# < 3)) ; 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 -fixed=1 -trigger=0 -duration=0 -author=${SUDO_USER:-$USER} -comment=${4:-'no comment given'} -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 - -# Quietly replace semicolons in comment with commas -comment=${comment//;/,} - -# Attempt to parse start and end dates; fail usefully if the call doesn't work -if ! dtstart=$(date +%s --date "$2") ; then - printf '%s: Could not parse start date %s' "$self" "$2" >&2 - exit 1 -fi -if ! dtend=$(date +%s --date "$3") ; then - printf '%s: Could not parse end date %s' "$self" "$3" >&2 - exit 1 -fi - -# Write command and print message if it fails; succeed silently -if [[ $service ]] ; then - cmd=$(printf '[%lu] SCHEDULE_SVC_DOWNTIME;%s;%s;%s;%s;%u;%u;%u;%s;%s' \ - "$now" "$host" "$service" "$dtstart" "$dtend" \ - "$fixed" "$trigger" "$duration" "$author" "$comment") -else - cmd=$(printf '[%lu] SCHEDULE_HOST_DOWNTIME;%s;%s;%s;%u;%u;%u;%s;%s' \ - "$now" "$host" "$dtstart" "$dtend" \ - "$fixed" "$trigger" "$duration" "$author" "$comment") -fi - -# Attempt to write command to file -if ! printf '%s\n' "$cmd" > "$cmdfile" ; then - printf '%s: Failed to write command to file\n' "$self" >&2 - exit 1 -fi - diff --git a/ndt b/ndt new file mode 120000 index 0000000..f4c97a4 --- /dev/null +++ b/ndt @@ -0,0 +1 @@ +nagios-downtime \ No newline at end of file diff --git a/ndt.1 b/ndt.1 deleted file mode 100644 index c4ef614..0000000 --- a/ndt.1 +++ /dev/null @@ -1,53 +0,0 @@ -.TH NAGIOS-DOWNTIME 1 "Nagios Downtime" "Nagscripts" -.SH NAME -.B ndt, nagios-downtime -\- Pleasant way to script fixed downtime for a Nagios host or service -.SH USAGE -.B nagios-downtime --h -.br -.B nagios-downtime -.I HOSTNAME[/SERVICE] -.I START -.I END -.I [COMMENT] -.SH SYNOPSIS -.B ndt -webhost now 10pm 'Upgrading to latest OS release' -.PP -.B ndt -webhost/HTTP now 10pm 'Upgrading Apache HTTPD' -.PP -for hostname in ns{1..3} ; do -.br -.B - ndt -"$hostname" 'sunday 3:00am' 'sunday 4:00am' 'Outage for entire DNS system for upgrades' -.br -done -.SH DESCRIPTION -.B nagios-downtime -will format and attempt to write a Nagios command to the Nagios commands file -which it expects to find at /usr/local/nagios/var/rw/nagios.cmd to schedule -downtime for a particular host or service. The two date fields -.I START -and -.I END -may be given in any form understood by -.I date(1) -with the -.I --date -option. -.PP -The user's current login name will be used as the author field for the -downtime, taking into account any use of -.I sudo(8) -changes. Note that the -.I COMMENT -parameter is optional. -.SH SEE ALSO -nagios-acknowledge(1), nagios-force-check(1) -.SH AUTHOR -Tom Ryder -.PP - diff --git a/ndt.1 b/ndt.1 new file mode 120000 index 0000000..734e983 --- /dev/null +++ b/ndt.1 @@ -0,0 +1 @@ +nagios-downtime.1 \ No newline at end of file diff --git a/nfc b/nfc deleted file mode 100755 index 99d9534..0000000 --- a/nfc +++ /dev/null @@ -1,77 +0,0 @@ -#!/usr/bin/env bash - -# -# nagios-force-check(1) -- Force an immediate check of a nominated host or -# service. -# -# $ nac [/] -# -# Author: Tom Ryder -# Copyright: 2014 Sanctum -# - -# Name self -self=nagios-force-check - -# Usage printing function -usage() { - printf 'USAGE: %s [-n] \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 - diff --git a/nfc b/nfc new file mode 120000 index 0000000..fcf24d1 --- /dev/null +++ b/nfc @@ -0,0 +1 @@ +nagios-force-check \ No newline at end of file diff --git a/nfc.1 b/nfc.1 deleted file mode 100644 index 27d7114..0000000 --- a/nfc.1 +++ /dev/null @@ -1,36 +0,0 @@ -.TH NAGIOS-FORCE-CHECK 1 "Nagios Force Check" "Nagscripts" -.SH NAME -.B nfc, nagios-force-check -\- Pleasant way to force a check for a Nagios host or service -.SH USAGE -.B nagios-force-check --h -.br -.B nagios-force-check -.I HOSTNAME[/SERVICE] -.SH SYNOPSIS -.B nfc -webhost -.br -.B nfc -webhost/HTTP -.B -.br -.B nul -| while read -r object ; do -.br - nfc "$object" -.br -done -.SH DESCRIPTION -.B nagios-force-check -will format and attempt to write a Nagios command to the Nagios commands file -which it expects to find at /usr/local/nagios/var/rw/nagios.cmd to force a -check of a particular host (and all its services) or just one particular -service. -.SH SEE ALSO -nagios-acknowledge(1), nagios-downtime(1) -.SH AUTHOR -Tom Ryder -.PP - diff --git a/nfc.1 b/nfc.1 new file mode 120000 index 0000000..477ad4d --- /dev/null +++ b/nfc.1 @@ -0,0 +1 @@ +nagios-force-check.1 \ No newline at end of file -- cgit v1.2.3