[packages/nagios-plugin-check_domain] rework to use sed patterns

glen glen at pld-linux.org
Sat Oct 26 21:55:52 CEST 2013


commit 206a6a48ac9ebccf64132924b46996afefeb45cf
Author: Elan Ruusamäe <glen at delfi.ee>
Date:   Sat Oct 26 22:44:14 2013 +0300

    rework to use sed patterns

 check_domain.sh | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
---
diff --git a/check_domain.sh b/check_domain.sh
index 841eb21..0e6f9eb 100755
--- a/check_domain.sh
+++ b/check_domain.sh
@@ -113,17 +113,20 @@ out=$($whois $domain)
 # Calculate days until expiration
 case "$domain" in
 *.ru)
-	expiration=$(echo "$out" | awk '/paid-till:/{split($2, a, "."); printf("%s-%s-%s\n", a[1], a[2], a[3])}')
+	# paid-till: 2013.11.01
+	expiration=$(echo "$out" | sed -rne 's;paid-till:[^0-9]+([0-9]{4})\.([0-9]{1,2})\.([0-9]{2});\1-\2-\3;p')
 	;;
 *.ee)
-	expiration=$(echo "$out" | awk '/expire:/{split($2, a, "."); printf("%s-%s-%s\n", a[3], a[2], a[1])}')
+	# expire: 16.11.2013
+	expiration=$(echo "$out" | sed -rne 's;expire:[^0-9]+([0-9]{1,2})\.([0-9]{1,2})\.([0-9]{4});\3-\2-\1;p')
 	;;
 *.tv)
-	expiration=$(echo "$out" | awk -F: '/Expiration Date:/{print substr($0, length($1) + 3, 10)}')
+	# Expiration Date: 2017-01-26T10:14:11Z
+	expiration=$(echo "$out" | sed -rne 's;Expiration Date:[^0-9]+([0-9]{4}-[0-9]{2}-[0-9]{2})T[0-9:Z]+;\1;p')
 	;;
 *.ca)
 	# Expiry date: 2017/07/16
-	expiration=$(echo "$out" | awk '/Expiry date:/{split($3, a, "/"); printf("%s-%s-%s\n", a[1], a[2], a[3])}')
+	expiration=$(echo "$out" | sed -rne 's;Expiry date:[^0-9]+([0-9]{4})/([0-9]{1,2})/([0-9]{2});\1-\2-\3;p')
 	;;
 *.ie)
 	# renewal: 31-March-2016
================================================================

---- gitweb:

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



More information about the pld-cvs-commit mailing list