[packages/nagios-plugin-check_domain] up to 1.2.8; new homepage for project
glen
glen at pld-linux.org
Tue Feb 25 21:40:26 CET 2014
commit c19418153a24048eb2b533b54920e8f4ed0a2fee
Author: Elan Ruusamäe <glen at delfi.ee>
Date: Tue Feb 25 22:39:37 2014 +0200
up to 1.2.8; new homepage for project
check_domain.cfg | 21 -----
check_domain.sh | 182 ----------------------------------------
nagios-plugin-check_domain.spec | 15 ++--
test.sh | 28 -------
4 files changed, 7 insertions(+), 239 deletions(-)
---
diff --git a/nagios-plugin-check_domain.spec b/nagios-plugin-check_domain.spec
index f6991bb..bd71eda 100644
--- a/nagios-plugin-check_domain.spec
+++ b/nagios-plugin-check_domain.spec
@@ -1,13 +1,13 @@
%define plugin check_domain
Summary: Nagios plugin for checking a domain name expiration date
Name: nagios-plugin-%{plugin}
-Version: 1.2.7
+Version: 1.2.8
Release: 1
License: GPL
Group: Networking
-Source0: %{plugin}.sh
-Source1: %{plugin}.cfg
-URL: http://www.tomas.cat/blog/en/checking-domain-name-expiration-date-checkdomain
+Source0: https://github.com/glensc/nagios-plugin-check_domain/archive/v%{version}/%{plugin}-%{version}.tar.gz
+# Source0-md5: bce4330d80e1a6a8a5ecc9ef3aeaf0c3
+URL: https://github.com/glensc/nagios-plugin-check_domain
Requires: whois
BuildArch: noarch
BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
@@ -19,14 +19,13 @@ BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
Nagios pluging for checking a domain name expiration date.
%prep
-%setup -qcT
-install -p %{SOURCE0} %{plugin}
+%setup -q
%install
rm -rf $RPM_BUILD_ROOT
install -d $RPM_BUILD_ROOT{%{_sysconfdir},%{plugindir}}
-install -p %{plugin} $RPM_BUILD_ROOT%{plugindir}/%{plugin}
-sed -e 's, at plugindir@,%{plugindir},' %{SOURCE1} > $RPM_BUILD_ROOT%{_sysconfdir}/%{plugin}.cfg
+install -p %{plugin}.sh $RPM_BUILD_ROOT%{plugindir}/%{plugin}
+sed -e 's, at plugindir@,%{plugindir},' %{plugin}.cfg > $RPM_BUILD_ROOT%{_sysconfdir}/%{plugin}.cfg
%clean
rm -rf $RPM_BUILD_ROOT
diff --git a/check_domain.cfg b/check_domain.cfg
deleted file mode 100644
index 501571c..0000000
--- a/check_domain.cfg
+++ /dev/null
@@ -1,21 +0,0 @@
-# Usage:
-# check_domain!DOMAINNAME
-define command {
- command_name check_domain
- command_line @plugindir@/check_domain -w 30 -c 10 -d $ARG1$
-}
-
-
-# Check DNS domain
-define service {
- use generic-service
- name check_domain
- service_description check_domain
- register 0
-
- ; check every 12h is sufficent, notify daily
- normal_check_interval 720
- notification_interval 1440
-
- check_command check_domain
-}
diff --git a/check_domain.sh b/check_domain.sh
deleted file mode 100755
index bf6c6c4..0000000
--- a/check_domain.sh
+++ /dev/null
@@ -1,182 +0,0 @@
-#!/bin/sh
-# Nagios plugin for checking a domain name expiration date
-#
-# Copyright (c) 2005 Tomàs Núñez Lirola <tnunez at criptos.com>,
-# 2009-2014 Elan Ruusamäe <glen at pld-linux.org>
-#
-# Licensed under GPL v2 License
-# URL: http://git.pld-linux.org/?p=packages/nagios-plugin-check_domain.git;a=summary
-
-PROGRAM=${0##*/}
-PROGPATH=${0%/*}
-. $PROGPATH/utils.sh
-
-# Default values (days):
-critical=7
-warning=30
-
-# Parse arguments
-args=$(getopt -o hd:w:c:P: --long help,domain:,warning:,critical:,path: -u -n $PROGRAM -- "$@")
-if [ $? != 0 ]; then
- echo >&2 "$PROGRAM: Could not parse arguments"
- echo "Usage: $PROGRAM -h | -d <domain> [-c <critical>] [-w <warning>]"
- exit 1
-fi
-set -- $args
-
-die() {
- local rc=$1
- local msg="$2"
- echo "$msg"
- exit $rc
-}
-
-fullusage() {
- cat <<EOF
-check_domain - v1.2.7
-Copyright (c) 2005 Tomàs Núñez Lirola <tnunez at criptos.com>, 2009-2014 Elan Ruusamäe <glen at pld-linux.org>
-under GPL License
-
-This plugin checks the expiration date of a domain name.
-
-Usage: $PROGRAM -h | -d <domain> [-c <critical>] [-w <warning>]
-NOTE: -d must be specified
-
-Options:
--h
- Print detailed help
--d
- Domain name to check
--w
- Response time to result in warning status (days)
--c
- Response time to result in critical status (days)
-
-This plugin will use whois service to get the expiration date for the domain name.
-Example:
- $PROGRAM -d domain.tld -w 30 -c 10
-
-EOF
-}
-
-# convert long month name to month number (Month Of Year)
-month2moy() {
- awk -vmonth="$1" 'BEGIN {
- split("January February March April May June July August Sepember October November December", months, " ");
- for (i in months) {
- Month[months[i]] = i;
- }
- print Month[month];
- }'
-}
-
-# 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;;
- -w|--warning) warning=$2; shift 2;;
- -d|--domain) domain=$2; shift 2;;
- -P|--path) whoispath=$2; shift 2;;
- -h|--help) fullusage; exit;;
- --) shift; break;;
- *) die $STATE_UNKNOWN "Internal error!";;
- esac
-done
-
-if [ -z $domain ]; then
- die $STATE_UNKNOWN "UNKNOWN - There is no domain name to check"
-fi
-
-# Looking for whois binary
-if [ -z $whoispath ]; then
- type whois > /dev/null 2>&1 || die $STATE_UNKNOWN "UNKNOWN - Unable to find whois binary in your path. Is it installed? Please specify path."
- whois=whois
-else
- [ -x "$whoispath/whois" ] || die $STATE_UNKNOWN "UNKNOWN - Unable to find whois binary, you specified an incorrect path"
- whois="$whoispath/whois"
-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)
- # 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)
- # 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 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' | head -n1)
- ;;
-*.ca)
- # Expiry date: 2017/07/16
- 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
- set -- $(echo "$out" | awk '/renewal:/{split($2, a, "-"); printf("%s %s %s\n", a[3], a[2], a[1])}')
- set -- "$1" "$(month2moy $2)" "$3"
- expiration="$1-$2-$3"
- ;;
-
-*.dk)
- # Expires: 2014-01-31
- expiration=$(echo "$out" | awk '/Expires:/ {print $2}')
- ;;
-
-*.ac.uk|*.gov.uk)
- # Renewal date:
- # Monday 21st Sep 2015
- set -- $(echo "$out" | awk '/Renewal date:/{renewal = 1; next} {if (renewal) {print $0; exit}}')
- set -- "$4" "$(mon2moy $3)" $(echo "$2" | sed -re 's,[^0-9]+,,')
- 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 Date: 21-sep-2018
- # Registry Expiry Date: 2015-08-03T04:00:00Z
- expiration=$(echo "$out" | awk -F: '/Expir(ation|y) Date:/{print substr($0, length($1) + 2); exit}')
- ;;
-esac
-
-[ -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")
-nowseconds=$(date +%s)
-diffseconds=$((expseconds-nowseconds))
-expdays=$((diffseconds/86400))
-
-# Trigger alarms if applicable
-[ $expdays -lt 0 ] && die $STATE_CRITICAL "CRITICAL - Domain $domain expired on $expiration"
-[ $expdays -lt $critical ] && die $STATE_CRITICAL "CRITICAL - Domain $domain will expire in $expdays days ($expdate)."
-[ $expdays -lt $warning ] && die $STATE_WARNING "WARNING - Domain $domain will expire in $expdays days ($expdate)."
-
-# No alarms? Ok, everything is right.
-echo "OK - Domain $domain will expire in $expdays days ($expdate)."
-exit $STATE_OK
diff --git a/test.sh b/test.sh
deleted file mode 100755
index b2ecf0c..0000000
--- a/test.sh
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/bin/sh
-if [ ! -e utils.sh ]; then
- cat > utils.sh <<-EOF
- STATE_OK=0
- STATE_WARNING=1
- STATE_CRITICAL=2
- STATE_UNKNOWN=3
- STATE_DEPENDENT=4
- EOF
-fi
-
-
-domains="
-mail.ru
-delfi.ee
-delfi.tv
-amazon.ca
-amazon.ie
-amazon.co.uk
-dk-hostmaster.dk
-bbk.ac.uk
-cnn.com
-gimp.org
-"
-
-for domain in ${*:-$domains}; do
- sh -$- ./check_domain.sh -d $domain
-done
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/nagios-plugin-check_domain.git/commitdiff/c19418153a24048eb2b533b54920e8f4ed0a2fee
More information about the pld-cvs-commit
mailing list