X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=dsa-nagios-checks%2Fchecks%2Fdsa-check-cert-expire;h=98a04a2e3d1fe57819b83902e88b03260cb67d92;hb=f62b4bd52da89a58d87a32e5b058b67e60815985;hp=89a119a00f884dca9e9e7dd2d2b86f2cfb8669b2;hpb=3efdb1338b4e8a5568a9a792c89f34566b47661a;p=mirror%2Fdsa-nagios.git diff --git a/dsa-nagios-checks/checks/dsa-check-cert-expire b/dsa-nagios-checks/checks/dsa-check-cert-expire index 89a119a..98a04a2 100755 --- a/dsa-nagios-checks/checks/dsa-check-cert-expire +++ b/dsa-nagios-checks/checks/dsa-check-cert-expire @@ -30,9 +30,30 @@ set -e warn=1209600 crit=86400 -if [ "$#" != 1 ]; then - echo "Usage: $0 " >&2 +usage() { + echo "Usage: $0 [-w seconds] [-c seconds] " >&2 exit 3 +} + + +OPTS=`getopt -o w:c: -n "$0" -- "$@"` || usage + +eval set -- "$OPTS" + +while :; do + case "$1" in + -w) warn=$2; shift 2 ;; + -c) crit=$2; shift 2 ;; + --) shift; break; ;; + *) usage ;; + esac +done +if test "$crit" -gt "$warn"; then + warn=$crit +fi + +if [ "$#" != 1 ]; then + usage fi cert="$1"