Wiki » Historique » Version 24
Patrice Nadeau, 2015-01-02 17:58
| 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 | Copier le fichier dans _/usr/lib/nagios/plugins_ |
||
| 42 | |||
| 43 | Rendre le fichier exécutable |
||
| 44 | <pre><code class="bash"> |
||
| 45 | chmod +x /usr/lib/nagios/plugins/check_domain_expiration.sh |
||
| 46 | 1 | Patrice Nadeau | </code></pre> |
| 47 | 5 | Patrice Nadeau | |
| 48 | 22 | Patrice Nadeau | h2. Utilisation |
| 49 | 5 | Patrice Nadeau | |
| 50 | 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 ». |
| 51 | 19 | Patrice Nadeau | > Cela n’influenceras pas le test d'expiration du domaine. |
| 52 | 18 | Patrice Nadeau | |
| 53 | 22 | Patrice Nadeau | h3. Fichier de commandes |
| 54 | 5 | Patrice Nadeau | |
| 55 | Ajouter au fichier _/etc/nagios/objects/commands.cfg_ : |
||
| 56 | 14 | Patrice Nadeau | <pre><code class="nagios"> |
| 57 | 6 | Patrice Nadeau | # Check an internet domain expiration date |
| 58 | define command{ |
||
| 59 | command_name check_domain_expiration |
||
| 60 | command_line $USER1$/check_domain_expiration.sh $HOSTADDRESS$ $ARG1$ $ARG2$ |
||
| 61 | } |
||
| 62 | 5 | Patrice Nadeau | </code></pre> |
| 63 | |||
| 64 | 22 | Patrice Nadeau | h3. Fichier de domaines |
| 65 | 5 | Patrice Nadeau | |
| 66 | Créer le fichier _/etc/nagios/objects/domains.cfg_ : |
||
| 67 | 12 | Patrice Nadeau | <pre><code class="nagios"> |
| 68 | 7 | Patrice Nadeau | ############################################################################### |
| 69 | # Domains.cfg |
||
| 70 | # |
||
| 71 | 8 | Patrice Nadeau | # Last Modified: 2014-09-08 |
| 72 | 7 | Patrice Nadeau | # |
| 73 | ############################################################################### |
||
| 74 | 5 | Patrice Nadeau | |
| 75 | 7 | Patrice Nadeau | define host{ |
| 76 | 17 | Patrice Nadeau | use generic-host |
| 77 | 15 | Patrice Nadeau | host_name mydomain |
| 78 | alias My domain name |
||
| 79 | 1 | Patrice Nadeau | address mydomain.net |
| 80 | 17 | Patrice Nadeau | max_check_attempts 4 |
| 81 | check_period 24x7 |
||
| 82 | 8 | Patrice Nadeau | icon_image internet.gif |
| 83 | 7 | Patrice Nadeau | } |
| 84 | |||
| 85 | |||
| 86 | define hostgroup{ |
||
| 87 | 8 | Patrice Nadeau | hostgroup_name internet-domains |
| 88 | alias Internet domains |
||
| 89 | 15 | Patrice Nadeau | members mydomain |
| 90 | 7 | Patrice Nadeau | } |
| 91 | |||
| 92 | |||
| 93 | # Define a service to check the load on the local machine. |
||
| 94 | |||
| 95 | define service{ |
||
| 96 | use local-service |
||
| 97 | 8 | Patrice Nadeau | hostgroup_name internet-domains |
| 98 | 21 | Patrice Nadeau | service_description Domain expiration |
| 99 | 8 | Patrice Nadeau | check_command check_domain_expiration!30!15 |
| 100 | 7 | Patrice Nadeau | } |
| 101 | 1 | Patrice Nadeau | </code></pre> |
| 102 | 5 | Patrice Nadeau | |
| 103 | 22 | Patrice Nadeau | h3. Configuration globale |
| 104 | 9 | Patrice Nadeau | |
| 105 | Ajouter au fichier _/etc/nagios/nagios.cfg_ : |
||
| 106 | 13 | Patrice Nadeau | <pre><code class="nagios"> |
| 107 | 10 | Patrice Nadeau | cfg_file=/etc/nagios/objects/domains.cfg |
| 108 | 9 | Patrice Nadeau | </code></pre> |
| 109 | 11 | Patrice Nadeau | |
| 110 | 22 | Patrice Nadeau | h3. Test |
| 111 | 11 | Patrice Nadeau | |
| 112 | Vérifier et lancer la nouvelle configuration |
||
| 113 | <pre><code class="bash"> |
||
| 114 | # Verify |
||
| 115 | rcnagios check |
||
| 116 | # Reload |
||
| 117 | rcnagios reload |
||
| 118 | </code></pre> |