diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2016-09-15 12:40:32 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2016-09-15 12:40:32 +1200 |
commit | ca8dec754c841fb15389c919d14b91938fc58bb0 (patch) | |
tree | 2573da52c9a6b14d337293ae788f408eb0b9ef17 | |
parent | Upgrading to latest version (diff) | |
download | nagscripts-ca8dec754c841fb15389c919d14b91938fc58bb0.tar.gz nagscripts-ca8dec754c841fb15389c919d14b91938fc58bb0.zip |
Raise error on downtime ending before it starts
-rwxr-xr-x | nagios-downtime | 7 |
1 files changed, 7 insertions, 0 deletions
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//;/,} |