Plugin Apps-OPNSense-API : Différence entre versions
| (2 révisions intermédiaires par le même utilisateur non affichées) | |||
| Ligne 13 : | Ligne 13 : | ||
Editer l'utilisateur remote-centreon  | Editer l'utilisateur remote-centreon  | ||
| + | |||
| + | Privilèges effectifs: System: Firmware  | ||
Clés d'API cliquer sur +  | Clés d'API cliquer sur +  | ||
| Ligne 27 : | Ligne 29 : | ||
==Plugin==  | ==Plugin==  | ||
Source: https://exchange.icinga.com/nicolaiB/check_opnsense  | Source: https://exchange.icinga.com/nicolaiB/check_opnsense  | ||
| + | |||
| + | === Adapter le plugin ===  | ||
| + | Par defaut, si la mise à jour nécessite un redemarrage, le status passe en critical (rouge)  | ||
| + | |||
| + | Afin de ne pas en tenir compte et laisser le status en warning (orange) il faut modifier le plugin.  | ||
| + | |||
| + |  nano /usr/lib/centreon/plugins/apps/opnsense/snmp/check_opnsense.py  | ||
| + | |||
| + | Commenter les lignes comme ci dessous  | ||
| + | |||
| + | <nowiki>#            if data['upgrade_needs_reboot']:  | ||
| + | #                self.checkResult = NagiosState.CRITICAL  | ||
| + | #                self.checkMessage = "{}. Subsequent reboot required.".format(self.checkMessage)</nowiki>  | ||
==Le template d’hôte==    | ==Le template d’hôte==    | ||
Nous regrouperons les services dans un template dhôte  | Nous regrouperons les services dans un template dhôte  | ||
<syntaxhighlight lang="shell" line>clapi -o HTPL -a add -v "APP-OPNSense-API-SLM;APP-OPNSense-API-SLM;;;;"  | <syntaxhighlight lang="shell" line>clapi -o HTPL -a add -v "APP-OPNSense-API-SLM;APP-OPNSense-API-SLM;;;;"  | ||
| − | clapi -o HTPL -a addtemplate -v "APP-OPNSense-API-SLM;generic-active-host-custom"  | + | clapi -o HTPL -a addtemplate -v "APP-OPNSense-API-SLM;generic-active-host-custom"  | 
clapi -o HTPL -a setmacro -v "APP-OPNSense-API-SLM;PORTAPI;443"  | clapi -o HTPL -a setmacro -v "APP-OPNSense-API-SLM;PORTAPI;443"  | ||
clapi -o HTPL -a setmacro -v "APP-OPNSense-API-SLM;APIKEY;"  | clapi -o HTPL -a setmacro -v "APP-OPNSense-API-SLM;APIKEY;"  | ||
| − | clapi -o HTPL -a setmacro -v "APP-OPNSense-API-SLM;APISECRET;"  | + | clapi -o HTPL -a setmacro -v "APP-OPNSense-API-SLM;APISECRET;"</syntaxhighlight>  | 
===Version===    | ===Version===    | ||
Version actuelle datée du 29 avril 2020 à 21:01
Sommaire
Installation
Sur serveur centreon
mkdir /usr/lib/centreon/plugins/apps/opnsense/snmp -p cd /usr/lib/centreon/plugins/apps/opnsense/snmp git clone https://github.com/nbuchwitz/check_opnsense.git cp check_opnsense/* ./ rm check_opnsense -rf
Créer une clé API sur opnsense
Système: Accès: Utilisateurs
Editer l'utilisateur remote-centreon
Privilèges effectifs: System: Firmware
Clés d'API cliquer sur +
Téléchargement d'un fichier .txt contenant la clé et le secret.
Ce fichier devrait ressembler à celui-ci:
key=w86XNZob/8Oq8aC5r0kbNarNtdpoQU781fyoeaOBQsBwkXUt secret=XeD26XVrJ5ilAc/EmglCRC+0j2e57tRsjHwFepOseySWLM53pJASeTA3
Commande
/usr/lib/centreon/plugins/apps/opnsense/snmp/check_opnsense.py -H 10.10.10.1:8443 --api-key E/QJ64ddg...MX+fJ+B+7856 --api-secret GVf77emB8...peXAHAwjb -m updates --insecure
Plugin
Source: https://exchange.icinga.com/nicolaiB/check_opnsense
Adapter le plugin
Par defaut, si la mise à jour nécessite un redemarrage, le status passe en critical (rouge)
Afin de ne pas en tenir compte et laisser le status en warning (orange) il faut modifier le plugin.
nano /usr/lib/centreon/plugins/apps/opnsense/snmp/check_opnsense.py
Commenter les lignes comme ci dessous
# if data['upgrade_needs_reboot']: # self.checkResult = NagiosState.CRITICAL # self.checkMessage = "{}. Subsequent reboot required.".format(self.checkMessage)
Le template d’hôte
Nous regrouperons les services dans un template dhôte
1 clapi -o HTPL -a add -v "APP-OPNSense-API-SLM;APP-OPNSense-API-SLM;;;;"
2 clapi -o HTPL -a addtemplate -v "APP-OPNSense-API-SLM;generic-active-host-custom"
3 clapi -o HTPL -a setmacro -v "APP-OPNSense-API-SLM;PORTAPI;443"
4 clapi -o HTPL -a setmacro -v "APP-OPNSense-API-SLM;APIKEY;"
5 clapi -o HTPL -a setmacro -v "APP-OPNSense-API-SLM;APISECRET;"
Version
 1 #Création commande
 2 clapi -o CMD -a ADD -v "Check_APP_OPNSense_API_Version;2;/usr/lib/centreon/plugins/apps/opnsense/snmp/check_opnsense.py -H \$HOSTADDRESS\$:\$_HOSTPORTAPI\$ --api-key \$_HOSTAPIKEY\$ --api-secret \$_HOSTAPISECRET\$ \$_HOSTEXTRAOPTIONS\$ \$_SERVICEEXTRAOPTIONS\$ -m updates"
 3 clapi -o CMD -a setparam -v "Check_APP_OPNSense_API_Version;enable_shell;0"
 4 clapi -o CMD -a setparam -v "Check_APP_OPNSense_API_Version;command_activate;1"
 5 clapi -o CMD -a setparam -v "Check_APP_OPNSense_API_Version;command_locked;0"
 6 
 7 #Création template service
 8 clapi -o STPL -a add -v "Stpl_APP_OPNSense_API_Version;Version;generic-active-service-custom"
 9 clapi -o STPL -a setparam -v "Stpl_APP_OPNSense_API_Version;check_command;Check_APP_OPNSense_API_Version"
10 clapi -o STPL -a setmacro -v "Stpl_APP_OPNSense_API_Version;EXTRAOPTIONS;--insecure"
11 
12 #Ajout de la template service à la template d hôte
13 clapi -o STPL -a addhost -v "Stpl_APP_OPNSense_API_Version;APP-OPNSense-API-SLM"