Projet

Général

Profil

Wiki » Historique » Version 17

Patrice Nadeau, 2014-09-14 11:55

1 1 Patrice Nadeau
%{font-size:18pt}check_domain_expiration%
2
3 3 Patrice Nadeau
Vérifie la date d'expiration d'un domaine internet.
4
5 1 Patrice Nadeau
---
6
7
{{toc}}
8
9
h1. Explications
10 3 Patrice Nadeau
11
Ce script _Bash_ vérifie la date d'expiration d'un domaine internet.
12
Les TLD(Top Level Domain) suivants sont reconnus :
13
* biz
14
* ca
15
* co
16
* com
17
* edu
18
* info
19
* me
20
* mobi
21
* net
22
* org
23
* tv
24
* us
25
* xxx
26 1 Patrice Nadeau
27 5 Patrice Nadeau
h1. Installation
28 4 Patrice Nadeau
29 16 Patrice Nadeau
> Je prends pour acquis une installation sous openSUSE.
30 4 Patrice Nadeau
31
Installer le programme _whois_ (si il n'est pas deja installer)
32
<pre><code class="bash">
33
# Verify if installed
34
rpm -qa | grep whois
35
# Install
36
zypper install whois
37
</code></pre>
38
39
Copier le fichier dans _/usr/lib/nagios/plugins_
40
41
Rendre le fichier exécutable
42
<pre><code class="bash">
43
chmod +x /usr/lib/nagios/plugins/check_domain_expiration.sh
44 1 Patrice Nadeau
</code></pre>
45 5 Patrice Nadeau
46
h1. Utilisation
47
48
h2. Fichier de commandes
49
50
Ajouter au fichier _/etc/nagios/objects/commands.cfg_ :
51 14 Patrice Nadeau
<pre><code class="nagios">
52 6 Patrice Nadeau
# Check an internet domain expiration date
53
define command{
54
        command_name check_domain_expiration
55
        command_line $USER1$/check_domain_expiration.sh $HOSTADDRESS$ $ARG1$ $ARG2$
56
}
57 5 Patrice Nadeau
</code></pre>
58
59
h2. Fichier de domaines
60
61
Créer le fichier _/etc/nagios/objects/domains.cfg_ :
62 12 Patrice Nadeau
<pre><code class="nagios">
63 7 Patrice Nadeau
###############################################################################
64
# Domains.cfg
65
#
66 8 Patrice Nadeau
# Last Modified: 2014-09-08
67 7 Patrice Nadeau
#
68
###############################################################################
69 5 Patrice Nadeau
70 7 Patrice Nadeau
define host{
71 17 Patrice Nadeau
        use                     generic-host            
72 15 Patrice Nadeau
        host_name               mydomain
73
        alias                   My domain name
74 1 Patrice Nadeau
        address                 mydomain.net
75 17 Patrice Nadeau
        max_check_attempts      4
76
        check_period            24x7
77 8 Patrice Nadeau
        icon_image              internet.gif
78 7 Patrice Nadeau
        }
79
80
81
define hostgroup{
82 8 Patrice Nadeau
        hostgroup_name          internet-domains
83
        alias                   Internet domains
84 15 Patrice Nadeau
        members                 mydomain
85 7 Patrice Nadeau
        }
86
87
88
# Define a service to check the load on the local machine. 
89
90
define service{
91
        use                     local-service         
92 8 Patrice Nadeau
        hostgroup_name          internet-domains
93 7 Patrice Nadeau
        service_description     Expiration
94 8 Patrice Nadeau
        check_command           check_domain_expiration!30!15
95 7 Patrice Nadeau
        }
96 1 Patrice Nadeau
</code></pre>
97 5 Patrice Nadeau
98 9 Patrice Nadeau
h2. Configuration globale
99
100
Ajouter au fichier _/etc/nagios/nagios.cfg_ :
101 13 Patrice Nadeau
<pre><code class="nagios">
102 10 Patrice Nadeau
cfg_file=/etc/nagios/objects/domains.cfg
103 9 Patrice Nadeau
</code></pre>
104 11 Patrice Nadeau
105
h2. Test
106
107
Vérifier et lancer la nouvelle configuration
108
<pre><code class="bash">
109
# Verify
110
rcnagios check
111
# Reload
112
rcnagios reload
113
</code></pre>