Utiliser SNMPv3 sur Centreon, monitorer des serveurs Windows et Linux
Introduction
L'utilisation d'SNMPv3 sur Centreon peut être déroutante car les connectors gratuits « Linux-SNMP » et « Windows-SNMP » ne proposent que des Template configurés sur la version 2c.
A moins de vous inscrire et de bénéficier des connectors SNMPv3 gratuits, il faut ruser ...
Concrètement, il existe plusieurs manières de procéder à partir des connectors de base.
On peut utiliser une méthode hybride consistant à se servir du template « OS-Linux-SNMP-custom » (installé par le connector « Linux-SNMP »), auquel on adjoint des commandes de checks comportant les macros nécessaires pour la connexion SNMPv3, ou bien on peut aussi ne pas se servir du tout du Template !
Je vous montre donc ici la méthode manuelle (sans se servir du Template), utile dès lors qu'il s'agît de créer des services peu communs. Cela vous permettra d'explorer un peu plus Centreon.
Nous allons apprendre à superviseur des serveurs Linux et Windows via SNMPv3.
Nous monitorerons les services suivants : SWAP, CPU, RAM, DISK, CHARGE tantôt sur Windows, tantôt sur Linux (pour vous laisser chercher un peu !).
Je pose comme pré-requis la configuration des agents SNMPv3 sur les serveurs Windows et Linux à monitorer !
1. Ajouter les plugins (connectors)
Ces plugins sont indispensables.
Sans eux, Centreon ne peut pas travailler en SNMP.
- Rendez-vous dans : Configuration > Connectors > Monitoring Connectors
- Ajoutez les packs suivants :
(Cliquez sur l'icône correspondante, puis sur le bouton + pour installer chaque pack)
2. Créer des commandes de check personnalisées pour les services à superviser
Ces commandes de check ciblent précisément les services CPU, RAM, CHARGE et SWAP. A vous de créer celles qui manqueraient.
- Allez dans : Configuration > Commands > Checks
Command Name : LINUX_SWAP-SNMPv3
- Command Type : Check
- Command Line :
/usr/lib/centreon/plugins/centreon_linux_snmp.pl --mode=swap --hostname=$_HOSTADDRESS$ --snmp-version=3 --snmp-username=$_HOSTSNMPUSERNAME$ --authprotocol=$_HOSTSNMPAUTHPROTO$ --authpassphrase=$_HOSTSNMPAUTHPASSWD$ --privprotocol=$_HOSTSNMPPRIVPROTO$ --privpassphrase=$_HOSTSNMPPRIVPASSWD$ --warning-usage=$_SERVICEWARNING$ --critical-usage=$_SERVICECRITICAL$
Save
Command Name : LINUX_MEMORY-SNMPv3
- Command Type : Check
- Command Line :
/usr/lib/centreon/plugins/centreon_linux_snmp.pl --mode=memory --hostname=$_HOSTADDRESS$ --snmp-version=3 --snmp-username=$_HOSTSNMPUSERNAME$ --authprotocol=$_HOSTSNMPAUTHPROTO$ --authpassphrase=$_HOSTSNMPAUTHPASSWD$ --privprotocol=$_HOSTSNMPPRIVPROTO$ --privpassphrase=$_HOSTSNMPPRIVPASSWD$ --warning-usage=$_SERVICEWARNING$ --critical-usage=$_SERVICECRITICAL$
Save
Command Name : WIN_MEMORY-SNMPv3
- Command Type : Check
- Command Line :
/usr/lib/centreon/plugins//centreon_windows_snmp.pl --plugin=os::windows::snmp::plugin --mode=memory --hostname=$_HOSTADDRESS$ --snmp-version=3 --snmp-username=$_HOSTSNMPUSERNAME$ --authprotocol=$_HOSTSNMPAUTHPROTO$ --authpassphrase=$_HOSTSNMPAUTHPASSWD$ --privprotocol=$_HOSTSNMPPRIVPROTO$ --privpassphrase=$_HOSTSNMPPRIVPASSWD$ --warning-memory=$_SERVICEWARNING$ --critical-memory=$_SERVICECRITICAL$
Save
Command Name : LINUX_LOAD-SNMPv3
- Command Type : Check
- Command Line :
/usr/lib/centreon/plugins/centreon_linux_snmp.pl --mode=load --hostname=$_HOSTADDRESS$ --snmp-version=3 --snmp-username=$_HOSTSNMPUSERNAME$ --authprotocol=$_HOSTSNMPAUTHPROTO$ --authpassphrase=$_HOSTSNMPAUTHPASSWD$ --privprotocol=$_HOSTSNMPPRIVPROTO$ --privpassphrase=$_HOSTSNMPPRIVPASSWD$ --warning=$_SERVICEWARNING$ --critical=$_SERVICECRITICAL$
Save
Command Name : LINUX_CPU-SNMPv3
- Command Type : Check
- Command Line :
/usr/lib/centreon/plugins/centreon_linux_snmp.pl --mode=cpu --hostname=$_HOSTADDRESS$ --snmp-version=3 --snmp-username=$_HOSTSNMPUSERNAME$ --authprotocol=$_HOSTSNMPAUTHPROTO$ --authpassphrase=$_HOSTSNMPAUTHPASSWD$ --privprotocol=$_HOSTSNMPPRIVPROTO$ --privpassphrase=$_HOSTSNMPPRIVPASSWD$ --warning-average=$_SERVICEWARNING$ --critical-average=$_SERVICECRITICAL$
Save
Command Name : WIN_CPU-SNMPv3
- Command Type : Check
- Command Line :
/usr/lib/centreon/plugins/centreon_linux_snmp.pl --mode=cpu --hostname=$_HOSTADDRESS$ --snmp-version=3 --snmp-username=$_HOSTSNMPUSERNAME$ --authprotocol=$_HOSTSNMPAUTHPROTO$ --authpassphrase=$_HOSTSNMPAUTHPASSWD$ --privprotocol=$_HOSTSNMPPRIVPROTO$ --privpassphrase=$_HOSTSNMPPRIVPASSWD$ --warning-average=$_SERVICEWARNING$ --critical-average=$_SERVICECRITICAL$
Save
(vous remarquerez au passage que la commande est la même que pour Linux !)
Command Name : WIN_DISK-SNMPv3
- Command Type : Check
- Command Line :
/usr/lib/centreon/plugins//centreon_windows_snmp.pl --plugin=os::windows::snmp::plugin --mode=storage --hostname=$_HOSTADDRESS$ --snmp-version=3 --snmp-username=$_HOSTSNMPUSERNAME$ --authprotocol=$_HOSTSNMPAUTHPROTO$ --authpassphrase=$_HOSTSNMPAUTHPASSWD$ --privprotocol=$_HOSTSNMPPRIVPROTO$ --privpassphrase=$_HOSTSNMPPRIVPASSWD$ --storage '1' --display-transform-src='' --display-transform-dst='' --warning-usage=$_SERVICEWARNING$ --critical-usage=$_SERVICECRITICAL$
Save
Command Name : HOST-SNMPv3
- Command Type : Check
- Command Line :
/bin/true $_HOSTADDRESS$ $_HOSTSNMPUSERNAME$ $_HOSTSNMPAUTHPASSWD$ $_HOSTSNMPAUTHPROTO$ $_HOSTSNMPPRIVPASSWD$ $_HOSTSNMPPRIVPROTO$
Save
3. Créer les Hôtes
- Allez dans : Configuration > Hosts > Hosts > Add
Onglet « Host Configuration »
- Name : SRV-WEB
- Alias : Serveur Web
- Address : 10.10.20.2
- SNMP Community & Version : 3
- Monitoring Server : Central
- Timezone : Europe/Paris
- Create Services linked : No (inutile puisqu'il n'y a pas de template)
- Check Command : HOST-SNMPv3
- Custom Macros : remplir avec les informations SNMPv3 telles que configurées sur votre hôte.
| SNMPEXTRAOPTIONS |
(laisser vide) |
| ADDRESS |
10.10.20.2 |
| SNMPUSERNAME |
majekla |
| SNMPAUTHPROTO |
SHA |
| SNMPAUTHPASSWD |
Ertyuiop, |
| SNMPPRIVPROTO |
AES |
| SNMPPRIVPASSWD |
Ertyuiop, |
- Check Period : 24x7
- Max Check Attempts : 5
- Normal Check Interval : 1
- Retry Check Interval : 1
Onglet « Notification »
- Notification Enabled : Yes
- Notification Options : Down, Unreachable, Recovery
- Notification Interval : 30
- Notification Period : 24x7
4. Créer des services de monitoring
- Allez dans : Configuration > Services > Services by Host
- Ci-dessous : quelques exemples de services s'appuyant sur nos commandes de check manuelles
Sonde : CPU_SRV-WEB
Onglet « General Information »
- Name : CPU_SRV-WEB
- Hosts : SRV-WEB
- Check Command : LINUX_CPU-SNMPv3
- Custom macros :
- WARNING : 80
- CRITICAL : 90
- Check Period : 24x7
- Max Check Attempts : 5
- Normal Check Interval : 1
- Retry Check Interval : 1
Onglet « Notifications »
- Notification Enabled : Yes
- Notification Interval : 30
- Notification Period : 24x7
- Notification Type : Warning, Critical
Sonde : LOAD_SRV-WEB
Onglet « General Information »
- Name : LOAD_SRV-WEB
- Hosts : SRV-WEB
- Check Command : LINUX_LOAD-SNMPv3
- Custom macros :
- WARNING : 4,3,2
- CRITICAL : 6,5,4
- Check Period : 24x7
- Max Check Attempts : 5
- Normal Check Interval : 1
- Retry Check Interval : 1
Onglet « Notifications »
- Notification Enabled : Yes
- Notification Interval : 30
- Notification Period : 24x7
- Notification Type : Warning, Critical
Sonde : MEMORY_SRV-WEB
Onglet « General Information »
- Name : MEMORY_SRV-WEB
- Hosts : SRV-WEB
- Check Command : LINUX_MEMORY-SNMPv3
- Custom macros :
- WARNING : 80
- CRITICAL : 90
- Check Period : 24x7
- Max Check Attempts : 5
- Normal Check Interval : 1
- Retry Check Interval : 1
Onglet « Notifications »
- Notification Enabled : Yes
- Notification Interval : 30
- Notification Period : 24x7
- Notification Type : Warning, Critical
Sonde : SWAP_SRV-WEB
Onglet « General Information »
- Name : SWAP_SRV-WEB
- Hosts : SRV-WEB
- Check Command : LINUX_SWAP-SNMPv3
- Custom macros :
- WARNING : 10
- CRITICAL : 30
- Check Period : 24x7
- Max Check Attempts : 5
- Normal Check Interval : 1
- Retry Check Interval : 1
Onglet « Notifications »
- Notification Enabled : Yes
- Notification Interval : 30
- Notification Period : 24x7
- Notification Type : Warning, Critical
Sonde : CPU_PC-CLIENT
Onglet « General Information »
- Name : CPU_PC-CLIENT
- Hosts : PC-CLIENT
- Check Command : WIN_CPU-SNMPv3
- Custom macros :
- WARNING : 80
- CRITICAL : 90
- Check Period : 24x7
- Max Check Attempts : 5
- Normal Check Interval : 1
- Retry Check Interval : 1
Onglet « Notifications »
- Notification Enabled : Yes
- Notification Interval : 30
- Notification Period : 24x7
- Notification Type : Warning, Critical
Sonde : DISK_PC-CLIENT
Onglet « General Information »
- Name : DISK_PC-CLIENT
- Hosts : PC-CLIENT
- Check Command : WIN_DISK-SNMPv3
- Custom macros :
- WARNING : 80
- CRITICAL : 90
- DISKID : 1 (ça veut dire C:\)
- Check Period : 24x7
- Max Check Attempts : 5
- Normal Check Interval : 1
- Retry Check Interval : 1
Onglet « Notifications »
- Notification Enabled : Yes
- Notification Interval : 30
- Notification Period : 24x7
- Notification Type : Warning, Critical
Sonde : MEMORY_PC-CLIENT
Onglet « General Information »
- Name : MEMORY_PC-CLIENT
- Hosts : PC-CLIENT
- Check Command : WIN_MEMORY-SNMPv3
- Custom macros :
- WARNING : 80
- CRITICAL : 90
- Check Period : 24x7
- Max Check Attempts : 5
- Normal Check Interval : 1
- Retry Check Interval : 1
Onglet « Notifications »
- Notification Enabled : Yes
- Notification Interval : 30
- Notification Period : 24x7
- Notification Type : Warning, Critical
5. Exporter et Recharger la configuration
- Allez dans : Configuration > Pollers > Pollers > Export Configuration
- Pollers : Central
- Generate Configuration Files : coché
- Run monitoring engine debug (-v) : coché
- Restart Monitoring Engine : coché ; Method : Restart
- Export
- Cliquez sur « Pollers » (dans le menu Horizontal en haut) puis sur « Export Configuration ». (sinon les services n'apparaitront pas dans monitoring, c'est un bug ridicule).
6. Vérifier le monitoring
- Allez dans : Monitoring > Resources Status
(L'apparition des services prend un certain temps la première fois à cause de problèmes de Timeout. PRENEZ VOTRE MAL EN PATIENCE !)
Rechargez la page web si nécessaire pour afficher les hôtes et services.
Une fois apparus, sélectionnez-les tous et forcez un check)