Author: glen Date: Sun Aug 30 08:26:52 2009 GMT Module: packages Tag: HEAD ---- Log message: - new
---- Files affected: packages/nagios-plugin-check_domain: check_domain (NONE -> 1.1) (NEW), nagios-plugin-check_domain.spec (NONE -> 1.1) (NEW) ---- Diffs: ================================================================ Index: packages/nagios-plugin-check_domain/check_domain diff -u /dev/null packages/nagios-plugin-check_domain/check_domain:1.1 --- /dev/null Sun Aug 30 10:26:52 2009 +++ packages/nagios-plugin-check_domain/check_domain Sun Aug 30 10:26:47 2009 @@ -0,0 +1,74 @@ +#!/bin/bash + +PROGPATH=`echo $0 | /bin/sed -e 's,[\\/][^\\/][^\\/]*$,,'` + +. $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 $0 -- "$@"` +[ $? != 0 ] && echo "$0: Could not parse arguments" && echo "Usage: $0 -h | -d <domain> [-c <critical>] [-w <warning>]" && exit +set -- $args + +while true ; 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) echo "check_domain - v1.01" + echo "Copyright (c) 2005 Tomàs Núñez Lirola <[email protected]> under GPL License" + echo "This plugin checks the expiration date of a domain name." + echo "" + echo "Usage: $0 -h | -d <domain> [-c <critical>] [-w <warning>]" + echo "NOTE: -d must be specified" + echo "" + echo "Options:" + echo "-h" + echo " Print detailed help" + echo "-d" + echo " Domain name to check" + echo "-w" + echo " Response time to result in warning status (days)" + echo "-c" + echo " Response time to result in critical status (days)" + echo "" + echo "This plugin will use whois service to get the expiration date for the domain name. " + echo "Example:" + echo " $0 -d domain.tld -w 30 -c 10" + echo "" + exit;; + --) shift; break;; + *) echo "Internal error!" ; exit 1 ;; + esac +done + +[ -z $domain ] && echo "UNKNOWN - There is no domain name to check" && exit $STATE_UNKNOWN + +# Looking for whois binary +if [ -z $whoispath ]; then + type whois &> /dev/null || error="yes" + [ ! -z $error ] && echo "UNKNOWN - Unable to find whois binary in your path. Is it installed? Please specify path." && exit $STATE_UNKNOWN +else + [ ! -x "$whoispath/whois" ] && echo "UNKNOWN - Unable to find whois binary, you specified an incorrect path" && exit $STATE_UNKNOWN +fi + +# Calculate days until expiration +expiration=`whois $domain |grep "Expiration Date:"| awk -F"Date:" '{print $2}'|cut -f 1` +expseconds=`date +%s --date="$expiration"` +nowseconds=`date +%s` +((diffseconds=expseconds-nowseconds)) +expdays=$((diffseconds/86400)) + +# Trigger alarms if applicable +[ -z "$expiration" ] && echo "UNKNOWN - Domain doesn't exist or no WHOIS server available." && exit $STATE_UNKNOWN +[ $expdays -lt 0 ] && echo "CRITICAL - Domain expired on $expiration" && exit $STATE_CRITICAL +[ $expdays -lt $critical ] && echo "CRITICAL - Domain will expire in $expdays days" && exit $STATE_CRITICAL +[ $expdays -lt $warning ]&& echo "WARNING - Domain will expire in $expdays days" && exit $STATE_WARNING + +# No alarms? Ok, everything is right. +echo "OK - Domain will expire in $expdays days" +exit $STATE_OK ================================================================ Index: packages/nagios-plugin-check_domain/nagios-plugin-check_domain.spec diff -u /dev/null packages/nagios-plugin-check_domain/nagios-plugin-check_domain.spec:1.1 --- /dev/null Sun Aug 30 10:26:52 2009 +++ packages/nagios-plugin-check_domain/nagios-plugin-check_domain.spec Sun Aug 30 10:26:47 2009 @@ -0,0 +1,56 @@ +# $Revision$, $Date$ +%define plugin check_domain +Summary: Nagios pluging for checking a domain name expiration date +Name: nagios-plugin-%{plugin} +Version: 0.1 +Release: 0.1 +License: BSD +Group: Networking +Source0: %{plugin} +# Source0-md5: fe2dffc066980e2385d88755703f97fe +URL: http://www.tomas.cat/blog/en/checking-domain-name-expiration-date-checkdomain +Requires: whois +BuildArch: noarch +BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n) + +%define _sysconfdir /etc/nagios/plugins +%define plugindir %{_prefix}/lib/nagios/plugins + +%description +Nagios pluging for checking a domain name expiration date. + +%prep +%setup -qcT +install -p %{SOURCE0} %{plugin} + +cat > nagios.cfg <<'EOF' +# Usage: +# %{plugin} +define command { + command_name %{plugin} + command_line %{plugindir}/%{plugin} -w 30 -c 10 -d $ARG1$ +} +EOF + +%install +rm -rf $RPM_BUILD_ROOT +install -d $RPM_BUILD_ROOT{%{_sysconfdir},%{plugindir}} +install -p %{plugin} $RPM_BUILD_ROOT%{plugindir}/%{plugin} +cp -a nagios.cfg $RPM_BUILD_ROOT%{_sysconfdir}/%{plugin}.cfg + +%clean +rm -rf $RPM_BUILD_ROOT + +%files +%defattr(644,root,root,755) +%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/%{plugin}.cfg +%attr(755,root,root) %{plugindir}/%{plugin} + +%define date %(echo `LC_ALL="C" date +"%a %b %d %Y"`) +%changelog +* %{date} PLD Team <[email protected]> +All persons listed below can be reached at <cvs_login>@pld-linux.org + +$Log$ +Revision 1.1 2009/08/30 08:26:47 glen +- new ================================================================ _______________________________________________ pld-cvs-commit mailing list [email protected] http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit
