From ca8dec754c841fb15389c919d14b91938fc58bb0 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 15 Sep 2016 12:40:32 +1200 Subject: Raise error on downtime ending before it starts --- nagios-downtime | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/nagios-downtime b/nagios-downtime index 6493dcf..46de12e 100755 --- a/nagios-downtime +++ b/nagios-downtime @@ -108,6 +108,13 @@ if ((dtn > dtb)) ; then exit 1 fi +# If the end time is less than the start time, this is definitely a mistake +if ((dta > dtb)) ; then + printf '%s: Refusing to schedule downtime that ends (%s) before it starts (%s)\n' \ + "$self" "$(date -d @"$dtb" +%c)" "$(date -d @"$dta" +%c)" + exit 1 +fi + # Quietly replace semicolons in comment with commas comment=${comment//;/,} -- cgit v1.2.3