From bd358aed1b7ca0b01c021574986fa7e9ec2d2157 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 21 Jun 2016 13:42:05 +1200 Subject: Require at least one host --- nagios-acknowledge | 7 +++++++ nagios-downtime | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/nagios-acknowledge b/nagios-acknowledge index c25deac..5fc6703 100755 --- a/nagios-acknowledge +++ b/nagios-acknowledge @@ -87,6 +87,13 @@ case $spec in ;; esac +# There must be at least one object +if ! ((${#objects[@]})) ; then + printf '%s: At least one host/service must be given\n' \ + "$self" >&2 + exit 1 +fi + # All the hosts or services must exist, just to be strict; they don't # necessarily have to be in a PROBLEM state though for object in "${objects[@]}" ; do diff --git a/nagios-downtime b/nagios-downtime index fdf9988..6493dcf 100755 --- a/nagios-downtime +++ b/nagios-downtime @@ -81,6 +81,13 @@ case $spec in ;; esac +# There must be at least one object +if ! ((${#objects[@]})) ; then + printf '%s: At least one host/service must be given\n' \ + "$self" >&2 + exit 1 +fi + # All the hosts or services must exist, just to be strict for object in "${objects[@]}" ; do nagios-exists "$object" && continue -- cgit v1.2.3