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