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