Wiki » Historique » Version 25
Patrice Nadeau, 2015-02-14 17:37
| 1 | 22 | Patrice Nadeau | h1. check_domain_expiration |
|---|---|---|---|
| 2 | 1 | Patrice Nadeau | |
| 3 | 3 | Patrice Nadeau | Vérifie la date d'expiration d'un domaine internet. |
| 4 | |||
| 5 | 24 | Patrice Nadeau | > Voir problème #30 |
| 6 | |||
| 7 | 1 | Patrice Nadeau | --- |
| 8 | |||
| 9 | {{toc}} |
||
| 10 | |||
| 11 | 22 | Patrice Nadeau | h2. Explications |
| 12 | 3 | Patrice Nadeau | |
| 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 | 1 | Patrice Nadeau | |
| 29 | 22 | Patrice Nadeau | h2. Installation |
| 30 | 4 | Patrice Nadeau | |
| 31 | 23 | Patrice Nadeau | > Je prends pour acquis une installation sous [[guides_openSUSE:wiki|openSUSE]]. |
| 32 | 4 | Patrice Nadeau | |
| 33 | Installer le programme _whois_ (si il n'est pas deja installer) |
||
| 34 | <pre><code class="bash"> |
||
| 35 | # Verify if installed |
||
| 36 | rpm -qa | grep whois |
||
| 37 | # Install |
||
| 38 | zypper install whois |
||
| 39 | </code></pre> |
||
| 40 | |||
| 41 | 1 | Patrice Nadeau | <pre><code class="bash"> |
| 42 | 25 | Patrice Nadeau | cd /usr/local/nagios/libexec |
| 43 | # Télécharger le fichier |
||
| 44 | wget http://redmine.patricenadeau.com/attachments/download/77/check_domain_expiration.sh |
||
| 45 | # Rendre le fichier exécutable |
||
| 46 | chmod +x check_domain_expiration.sh |
||
| 47 | 1 | Patrice Nadeau | </code></pre> |
| 48 | 5 | Patrice Nadeau | |
| 49 | 22 | Patrice Nadeau | h2. Utilisation |
| 50 | 5 | Patrice Nadeau | |
| 51 | 20 | Patrice Nadeau | > 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 | 19 | Patrice Nadeau | > Cela n’influenceras pas le test d'expiration du domaine. |
| 53 | 18 | Patrice Nadeau | |
| 54 | 22 | Patrice Nadeau | h3. Fichier de commandes |
| 55 | 5 | Patrice Nadeau | |
| 56 | Ajouter au fichier _/etc/nagios/objects/commands.cfg_ : |
||
| 57 | 14 | Patrice Nadeau | <pre><code class="nagios"> |
| 58 | 6 | Patrice Nadeau | # 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 | 5 | Patrice Nadeau | </code></pre> |
| 64 | |||
| 65 | 22 | Patrice Nadeau | h3. Fichier de domaines |
| 66 | 5 | Patrice Nadeau | |
| 67 | Créer le fichier _/etc/nagios/objects/domains.cfg_ : |
||
| 68 | 12 | Patrice Nadeau | <pre><code class="nagios"> |
| 69 | 7 | Patrice Nadeau | ############################################################################### |
| 70 | # Domains.cfg |
||
| 71 | # |
||
| 72 | 8 | Patrice Nadeau | # Last Modified: 2014-09-08 |
| 73 | 7 | Patrice Nadeau | # |
| 74 | ############################################################################### |
||
| 75 | 5 | Patrice Nadeau | |
| 76 | 7 | Patrice Nadeau | define host{ |
| 77 | 17 | Patrice Nadeau | use generic-host |
| 78 | 15 | Patrice Nadeau | host_name mydomain |
| 79 | alias My domain name |
||
| 80 | 1 | Patrice Nadeau | address mydomain.net |
| 81 | 17 | Patrice Nadeau | max_check_attempts 4 |
| 82 | check_period 24x7 |
||
| 83 | 8 | Patrice Nadeau | icon_image internet.gif |
| 84 | 7 | Patrice Nadeau | } |
| 85 | |||
| 86 | |||
| 87 | define hostgroup{ |
||
| 88 | 8 | Patrice Nadeau | hostgroup_name internet-domains |
| 89 | alias Internet domains |
||
| 90 | 15 | Patrice Nadeau | members mydomain |
| 91 | 7 | Patrice Nadeau | } |
| 92 | |||
| 93 | |||
| 94 | # Define a service to check the load on the local machine. |
||
| 95 | |||
| 96 | define service{ |
||
| 97 | use local-service |
||
| 98 | 8 | Patrice Nadeau | hostgroup_name internet-domains |
| 99 | 21 | Patrice Nadeau | service_description Domain expiration |
| 100 | 8 | Patrice Nadeau | check_command check_domain_expiration!30!15 |
| 101 | 7 | Patrice Nadeau | } |
| 102 | 1 | Patrice Nadeau | </code></pre> |
| 103 | 5 | Patrice Nadeau | |
| 104 | 22 | Patrice Nadeau | h3. Configuration globale |
| 105 | 9 | Patrice Nadeau | |
| 106 | Ajouter au fichier _/etc/nagios/nagios.cfg_ : |
||
| 107 | 13 | Patrice Nadeau | <pre><code class="nagios"> |
| 108 | 10 | Patrice Nadeau | cfg_file=/etc/nagios/objects/domains.cfg |
| 109 | 9 | Patrice Nadeau | </code></pre> |
| 110 | 11 | Patrice Nadeau | |
| 111 | 22 | Patrice Nadeau | h3. Test |
| 112 | 11 | Patrice Nadeau | |
| 113 | Vérifier et lancer la nouvelle configuration |
||
| 114 | <pre><code class="bash"> |
||
| 115 | # Verify |
||
| 116 | rcnagios check |
||
| 117 | # Reload |
||
| 118 | rcnagios reload |
||
| 119 | </code></pre> |