Check domain expiration » Historique » Révision 3
Révision 2 (Patrice Nadeau, 2016-09-10 15:41) → Révision 3/8 (Patrice Nadeau, 2016-09-10 15:41)
h1. check_domain_expiration
Vérifie la date d'expiration d'un domaine internet.
> Voir problème #30
---
{{toc}}
h2. Explications
Ce script _Bash_ vérifie la date d'expiration d'un domaine internet.
Les TLD(Top Level Domain) suivants sont reconnus :
* biz
* ca
* co
* com
* edu
* info
* me
* mobi
* net
* org
* tv
* us
* xxx
h2. Installation
> Je prends pour acquis une installation sous [[guides_openSUSE:wiki|openSUSE]].
Installer le programme _whois_ (si il n'est pas déjà installé)
<pre><code class="bash">
# Verify if installed
rpm -qa | grep whois
# Install
zypper install whois
</code></pre>
<pre><code class="bash">
cd /usr/local/nagios/libexec
# Télécharger le fichier
wget http://redmine.patricenadeau.com/attachments/download/132/check_domain_expiration.sh
# Rendre le fichier exécutable
chmod +x check_domain_expiration.sh
</code></pre>
h2. Utilisation
> NOTE : Nagios vérifieras aussi le « ping » de ce domaine. Si le domaine est définis à l'interne, le test pourras être un « faux positif ».
> Cela n’influenceras pas le test d'expiration du domaine.
h3. Fichier de commandes
Ajouter au fichier _/etc/nagios/objects/commands.cfg_ :
<pre><code class="nagios">
# Check an internet domain expiration date
define command{
command_name check_domain_expiration
command_line $USER1$/check_domain_expiration.sh $HOSTADDRESS$ $ARG1$ $ARG2$
}
</code></pre>
h3. Fichier de domaines
Créer le fichier _/etc/nagios/objects/domains.cfg_ :
<pre><code class="nagios">
###############################################################################
# Domains.cfg
#
# Last Modified: 2014-09-08
#
###############################################################################
define host{
use generic-host
host_name mydomain
alias My domain name
address mydomain.net
max_check_attempts 4
check_period 24x7
icon_image internet.gif
}
define hostgroup{
hostgroup_name internet-domains
alias Internet domains
members mydomain
}
# Define a service to check the load on the local machine.
define service{
use local-service
hostgroup_name internet-domains
service_description Domain expiration
check_command check_domain_expiration!30!15
}
</code></pre>
h3. Configuration globale
Ajouter au fichier _/etc/nagios/nagios.cfg_ :
<pre><code class="nagios">
cfg_file=/etc/nagios/objects/domains.cfg
</code></pre>
h3. Test
Vérifier et lancer la nouvelle configuration
<pre><code class="bash">
# Verify
rcnagios check
# Reload
rcnagios reload
</code></pre>