commit 6e141f7abd5fb373e3d89058557678ce6e8fca89
Author: Elan Ruusamäe <[email protected]>
Date:   Fri Mar 8 11:53:36 2013 +0200

    handle .uk domain

 check_domain | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)
---
diff --git a/check_domain b/check_domain
index 4b9deb5..5cdf920 100755
--- a/check_domain
+++ b/check_domain
@@ -70,6 +70,17 @@ month2moy() {
        }'
 }
 
+# convert short month name to month number (Month Of Year)
+mon2moy() {
+       awk -vmonth="$1" 'BEGIN {
+               split("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec", 
months, " ");
+               for (i in months) {
+                       Month[months[i]] = i;
+               }
+               print Month[month];
+       }'
+}
+
 while :; do
        case "$1" in
                -c|--critical) critical=$2; shift 2;;
@@ -97,6 +108,8 @@ fi
 
 out=$($whois $domain)
 
+[ -z "$out" ] && die $STATE_UNKNOWN "UNKNOWN - Domain $domain doesn't exist or 
no WHOIS server available."
+
 # Calculate days until expiration
 case "$domain" in
 *.ru)
@@ -118,12 +131,18 @@ case "$domain" in
        set -- "$1" "$(month2moy $2)" "$3"
        expiration="$1-$2-$3"
        ;;
+*.uk)
+       # Expiry date:  05-Dec-2014
+       set -- $(echo "$out" | awk '/Expiry date:/{split($3, a, "-"); 
printf("%s %s %s\n", a[3], a[2], a[1])}')
+       set -- "$1" "$(mon2moy $2)" "$3"
+       expiration="$1-$2-$3"
+       ;;
 *)
        expiration=$(echo "$out" | awk -F: '/Expiration Date:/{print substr($0, 
length($1) + 2)}')
        ;;
 esac
 
-[ -z "$expiration" ] && die $STATE_UNKNOWN "UNKNOWN - Domain $domain doesn't 
exist or no WHOIS server available."
+[ -z "$expiration" ] && die $STATE_UNKNOWN "UNKNOWN - Unable to figure out 
expiration date for $domain Domain."
 
 expseconds=$(date +%s --date="$expiration")
 expdate=$(date +'%Y-%m-%d' --date="$expiration")
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/nagios-plugin-check_domain.git/commitdiff/b90816566b56dd69e128c835543567673bce3b46

_______________________________________________
pld-cvs-commit mailing list
[email protected]
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit

Reply via email to