Package: nagios-plugins-contrib
Version: 9.20140106
Severity: wishlist
Tags: patch

Dear Maintainer,

It would be cool, if check_cert_expire could allow for different
expiration warnings than 2 weeks and one day ahead of critical. To that
end let me propose the attached patch introducing -w and -c options.

Helmut
--- dsa-check-cert-expire	2014-01-06 12:57:10.000000000 +0100
+++ dsa-check-cert-expire.new	2014-04-11 22:03:24.000000000 +0200
@@ -30,9 +30,30 @@
 warn=1209600
 crit=86400
 
-if [ "$#" != 1 ]; then
-	echo "Usage: $0 <certfile>" >&2
+usage() {
+	echo "Usage: $0 [-w seconds] [-c seconds] <certfile>" >&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"

Reply via email to