aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2014-10-22 14:09:54 +1300
committerTom Ryder <tom@sanctum.geek.nz>2014-10-22 14:09:54 +1300
commit4b8167c725c31a36a3ee5c7733522ca9ded015d6 (patch)
tree069f69963a8c57b3239b1a7e4f3540d40c6911f1
parent0f18c2426e1eecee9f40084b5cc3a41a61338595 (diff)
downloadnagscripts-4b8167c725c31a36a3ee5c7733522ca9ded015d6.tar.gz
Whoops, those are meant to be symlinks
l---------[-rwxr-xr-x]nac98
l---------[-rw-r--r--]nac.148
l---------[-rwxr-xr-x]ndt101
l---------[-rw-r--r--]ndt.154
l---------[-rwxr-xr-x]nfc78
l---------[-rw-r--r--]nfc.137
6 files changed, 6 insertions, 410 deletions
diff --git a/nac b/nac
index 5878e40..6b321ef 100755..120000
--- a/nac
+++ b/nac
@@ -1,97 +1 @@
-#!/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 <host>[/<service>] [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 <tom@sanctum.geek.nz>
-# Copyright: 2014 Sanctum
-#
-
-# Name self
-self=nagios-acknowledge
-
-# Usage printing function
-usage() {
- printf 'USAGE: %s [-n] <host[/service]> [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
-
+nagios-acknowledge \ No newline at end of file
diff --git a/nac.1 b/nac.1
index 48f31f7..abde110 100644..120000
--- a/nac.1
+++ b/nac.1
@@ -1,47 +1 @@
-.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 <tom@sanctum.geek.nz>
-.PP
-
+nagios-acknowledge.1 \ No newline at end of file
diff --git a/ndt b/ndt
index 9a886e0..f4c97a4 100755..120000
--- a/ndt
+++ b/ndt
@@ -1,100 +1 @@
-#!/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 <host>[/<service>] <start> <end> [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 <tom@sanctum.geek.nz>
-# Copyright: 2014 Sanctum
-#
-
-# Name self
-self=nagios-downtime
-
-# Usage printing function
-usage() {
- printf 'USAGE: %s <host[/service]> <start> <end> [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
-
+nagios-downtime \ No newline at end of file
diff --git a/ndt.1 b/ndt.1
index c4ef614..734e983 100644..120000
--- a/ndt.1
+++ b/ndt.1
@@ -1,53 +1 @@
-.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 <tom@sanctum.geek.nz>
-.PP
-
+nagios-downtime.1 \ No newline at end of file
diff --git a/nfc b/nfc
index 99d9534..fcf24d1 100755..120000
--- a/nfc
+++ b/nfc
@@ -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
diff --git a/nfc.1 b/nfc.1
index 27d7114..477ad4d 100644..120000
--- a/nfc.1
+++ b/nfc.1
@@ -1,36 +1 @@
-.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 <tom@sanctum.geek.nz>
-.PP
-
+nagios-force-check.1 \ No newline at end of file