packages: nagios-plugin-check_domain/check_domain - improve *.info lookup -...

glen glen at pld-linux.org
Sun Aug 30 11:03:37 CEST 2009


Author: glen                         Date: Sun Aug 30 09:03:37 2009 GMT
Module: packages                      Tag: HEAD
---- Log message:
- improve *.info lookup
- verbose report of expire date

---- Files affected:
packages/nagios-plugin-check_domain:
   check_domain (1.4 -> 1.5) 

---- Diffs:

================================================================
Index: packages/nagios-plugin-check_domain/check_domain
diff -u packages/nagios-plugin-check_domain/check_domain:1.4 packages/nagios-plugin-check_domain/check_domain:1.5
--- packages/nagios-plugin-check_domain/check_domain:1.4	Sun Aug 30 10:49:55 2009
+++ packages/nagios-plugin-check_domain/check_domain	Sun Aug 30 11:03:32 2009
@@ -70,26 +70,28 @@
 fi
 
 # Calculate days until expiration
-country=$(awk -vd="$domain" 'BEGIN{print substr(d, length(d) - 2); exit}')
-
-if [ "$country" = ".ru" ]; then
+case "$domain" in
+*.ru)
 	expiration=$(whois $domain | awk '/paid-till:/{split($2, a, "."); printf("%s-%s-%s\n", a[1], a[2], a[3])}')
-else
-	expiration=$(whois $domain | awk '/Expiration Date:/{print $3}')
-fi
+	;;
+*)
+	expiration=$(whois $domain |awk -F: '/Expiration Date:/{print substr($0, length($1) + 2)}')
+	;;
+esac
 
 [ -z "$expiration" ] && die $STATE_UNKNOWN "UNKNOWN - Domain doesn't exist or no WHOIS server available."
 
 expseconds=$(date +%s --date="$expiration")
+expdate=$(date +'%Y-%m-%d' --date="$expiration")
 nowseconds=$(date +%s)
 diffseconds=$((expseconds-nowseconds))
 expdays=$((diffseconds/86400))
 
 # Trigger alarms if applicable
 [ $expdays -lt 0 ] && die $STATE_CRITICAL "CRITICAL - Domain expired on $expiration"
-[ $expdays -lt $critical ] && die $STATE_CRITICAL "CRITICAL - Domain will expire in $expdays days"
-[ $expdays -lt $warning ]&& die $STATE_WARNING "WARNING - Domain will expire in $expdays days"
+[ $expdays -lt $critical ] && die $STATE_CRITICAL "CRITICAL - Domain will expire in $expdays days ($expdate)."
+[ $expdays -lt $warning ]&& die $STATE_WARNING "WARNING - Domain will expire in $expdays days ($expdate)."
 
 # No alarms? Ok, everything is right.
-echo "OK - Domain will expire in $expdays days"
+echo "OK - Domain will expire in $expdays days ($expdate)."
 exit $STATE_OK
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/packages/nagios-plugin-check_domain/check_domain?r1=1.4&r2=1.5&f=u



More information about the pld-cvs-commit mailing list