Outils pour utilisateurs

Outils du site


tech:exemple_simple_de_conf_nagios

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
tech:exemple_simple_de_conf_nagios [2026/01/14 14:51] Jean-Baptistetech:exemple_simple_de_conf_nagios [2026/01/19 10:10] (Version actuelle) Jean-Baptiste
Ligne 6: Ligne 6:
 Voir : Voir :
 * https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/3/en/objectinheritance.html * https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/3/en/objectinheritance.html
 +* https://packages.debian.org/sid/nagios4-common
 +* https://github.com/Webconverger/nagios
 +
 +Voir aussi :
 +* https://github.com/monitoring-fr/Documentation-Nagios-3.x-French
  
  
Ligne 12: Ligne 17:
  
 Le fichier de conf principale appelant tous les autres : Le fichier de conf principale appelant tous les autres :
-* etc/nagios.cfg+etc/nagios.cfg  
 +  * Voir https://github.com/NagiosEnterprises/nagioscore/blob/master/t/etc/nagios.cfg
  
 Fichier contenant les commandes à exécuter : Fichier contenant les commandes à exécuter :
Ligne 22: Ligne 28:
 * etc/resource.cfg * etc/resource.cfg
  
-Ce fichier ne devrait être en lecture que pour l'utilisateur de Nagios+Ce fichier ne devrait être en lecture que pour l'utilisateur "nagios"
  
  
Ligne 41: Ligne 47:
  
  
-## Fichier de conf principale+## Exemple de conf 
 + 
 +### Fichier de conf principale nagios.cfg
  
 Extrait Extrait
Ligne 75: Ligne 83:
 ~~~ ~~~
  
-## Fichier contenant les Templates+ 
 + 
 +### Fichier commands.cfg 
 + 
 +`commands.cfg` 
 + 
 +~~~c 
 +# 'check-host-alive' command definition 
 +define command { 
 +    command_name    check-host-alive 
 +    command_line    $USER1$/check_ping -H $HOSTADDRESS$ -w 3000.0,80% -c 5000.0,100% -p 5 
 +
 + 
 +# 'notify-service-by-email' command definition 
 +define command { 
 +    command_name    notify-service-by-email 
 +    command_line    /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$ 
 +
 + 
 +# 'notify-host-by-email' command definition 
 +define command { 
 +    command_name    notify-host-by-email 
 +    command_line    /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$ 
 +
 + 
 + 
 +# NOTE:  The following 'check_local_...' functions are designed to monitor 
 +#        various metrics on the host that Nagios is running on (i.e. this one). 
 +define command { 
 +    command_name    check_local_users 
 +    command_line    $USER1$/check_users -w $ARG1$ -c $ARG2$ 
 +
 + 
 +define command { 
 +    command_name    check_centreon_snmp_linux_mem 
 +    command_line    $USER1$/centreon_plugins --plugin=os::linux::snmp::plugin --hostname=$HOSTADDRESS$ --snmp-version=3 --snmp-username $USER6$ --authprotocol MD5 --authpassphrase "$USER7$" --mode=memory --warning-usage-prct $ARG1$ --critical-usage-prct $ARG2$ 
 +
 + 
 +#define command { 
 +#    command_name    check_active_router 
 +#    command_line    $USER1$/check_snmp_active_router.sh -v 3 -a MD5 -A "$USER4$" -l authNoPriv -u $USER3$ 
 +#} 
 + 
 +#define command { 
 +#    command_name    trigger_memory 
 +#    command_line    /usr/bin/tclsh $USER1$/eventhandlers/app_snmp_pxy.tcl MEM $HOSTNAME$ $SERVICEDESC$ #$SERVICESTATE$ 
 +#} 
 +~~~ 
 + 
 +Ce fichier contient les commandes qui seront exécutées. 
 + 
 +Tous les scripts ne renvoyant que des données locales (de localhost), et donc ne contenant pas ''$HOSTADDRESS$'', devraient avoir en *command_name* le préfixe "check_local_" 
 + 
 +Seul le fichier `localhost.cfg` devrait faire appel aux commandes "check_local_*" 
 + 
 + 
 +### Fichier contenant les Templates
  
 `templates.cfg` `templates.cfg`
Ligne 186: Ligne 250:
 Pour utiliser un template il faut utiliser la directive "use". Nous verons des exemples dans la suite. Pour utiliser un template il faut utiliser la directive "use". Nous verons des exemples dans la suite.
  
-Pour tous les nouveaux objets templates, nous recommandons pour une meilleurs lisibilité de leurs appliquer une convention de nommage spécique+Pour tous les nouveaux objets templates, nous recommandons pour une meilleurs lisibilité de leurs appliquer une convention de nommage spécifique
 Par exemple en les préfixant par "tpl-" Par exemple en les préfixant par "tpl-"
  
  
-## Passons rapidement sur timeperiods.cfg & contacts.cfg+### Passons rapidement sur timeperiods.cfg & contacts.cfg
  
 `timeperiods.cfg` `timeperiods.cfg`
Ligne 207: Ligne 271:
     saturday         00:00-24:00     saturday         00:00-24:00
 } }
- 
  
 # 'workhours' timeperiod definition # 'workhours' timeperiod definition
Ligne 229: Ligne 292:
     email                   nagios@localhost  ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******     email                   nagios@localhost  ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
 } }
 +
  
 define contactgroup { define contactgroup {
Ligne 240: Ligne 304:
  
  
-## Fichier commands.cfg 
  
-`commands.cfg` 
  
-~~~c +### Fichier localhost.cfg
-'check-host-alive' command definition +
-define command { +
-    command_name    check-host-alive +
-    command_line    $USER1$/check_ping -H $HOSTADDRESS$ -w 3000.0,80% -c 5000.0,100% -p 5 +
-+
- +
-# 'notify-service-by-email' command definition +
-define command { +
-    command_name    notify-service-by-email +
-    command_line    /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$ +
-+
- +
-# 'notify-host-by-email' command definition +
-define command { +
-    command_name    notify-host-by-email +
-    command_line    /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$ +
-+
- +
- +
-# NOTE:  The following 'check_local_...' functions are designed to monitor +
-#        various metrics on the host that Nagios is running on (i.e. this one). +
-define command { +
-    command_name    check_local_users +
-    command_line    $USER1$/check_users -w $ARG1$ -c $ARG2$ +
-+
- +
-define command { +
-    command_name    check_centreon_snmp_linux_mem +
-    command_line    $USER1$/centreon_plugins --plugin=os::linux::snmp::plugin --hostname=$HOSTADDRESS$ --snmp-version=3 --snmp-username $USER6$ --authprotocol MD5 --authpassphrase "$USER7$" --mode=memory --warning-usage-prct $ARG1$ --critical-usage-prct $ARG2$ +
-+
- +
-#define command { +
-#    command_name    check_active_router +
-#    command_line    $USER1$/check_snmp_active_router.sh -v 3 -a MD5 -A "$USER4$" -l authNoPriv -u $USER3$ +
-#} +
- +
-#define command { +
-#    command_name    trigger_memory +
-#    command_line    /usr/bin/tclsh $USER1$/eventhandlers/app_snmp_pxy.tcl MEM $HOSTNAME$ $SERVICEDESC$ #$SERVICESTATE$ +
-#} +
-~~~ +
- +
-Ce fichier contient les commandes qui seront executées. +
-Pour des raisons de simplification nous n'avons ici que quelques commandes. +
- +
-Tous les scripts ne renvoiyant que des données locales (sur localhost), et donc ne contenant pas ''$HOSTADDRESS$'' devraient avoir pour préfix (dans "command_name") :  "check_local_" +
- +
-Seul le fichier `localhost.cfg` devrait faire appel aux commandes "check_local_*" +
- +
- +
-## Fichier localhost.cfg+
  
 `localhost.cfg` `localhost.cfg`
Ligne 325: Ligne 336:
 ~~~ ~~~
  
-Toutes les commandes présentent dans ce fichier devraient avoir pour check_command "check_local_" +Toutes les commandes présentent dans ce fichier devraient avoir pour check_command "check_local_"
 Voir `commands.cfg` Voir `commands.cfg`
  
  
-## Fichier servers.cfg+### Fichier servers.cfg
  
 `servers.cfg` `servers.cfg`
Ligne 360: Ligne 371:
     hostgroup_name          App     hostgroup_name          App
     alias                   ReseauGlobalApp     alias                   ReseauGlobalApp
-    # hostgroup_members     linux-hosts, Switchs, Routeurs, printer-hosts+    # hostgroup_members      linux-hosts, Switchs, Routeurs, printer-hosts
     hostgroup_members       linux-hosts     hostgroup_members       linux-hosts
 } }
Ligne 379: Ligne 390:
 ou d'autres hostgroups avec `hostgroup_members` ou d'autres hostgroups avec `hostgroup_members`
  
-Mais souvent on préférera utliser les templates comme dans notre exemple avec `tpl-host-linux`+Souvent on préférera utliser les templates à l'aide de la directive "use". Voir notre exemple avec `tpl-host-linux`
  
  
Ligne 394: Ligne 405:
 Trouver les commandes non utilisées Trouver les commandes non utilisées
 ~~~bash ~~~bash
-for CMD in $(grep command_name etc/objects/commands.cfg |grep -v "^#" |awk '{ print $2}' |sort  -u) ; do grep -q "$CMD" $(find etc/objects/ -type f -not -name commands.cfg) || echo $CMD; done+for CMD in $(grep command_name etc/objects/commands.cfg | grep -v "^#" |awk '{ print $2}' | sort  -u) ; do grep -q "$CMD" $(find etc/objects/ -type f -not -name commands.cfg) || echo $CMD; done
 ~~~ ~~~
  
 Trouver les commandes en double Trouver les commandes en double
 ~~~bash ~~~bash
-diff <(grep -v ^# etc/objects/commands.cfg |awk '/command_name/ { print $NF }' | sort) <(grep -v ^# etc/objects/commands.cfg |awk '/command_name/ { print $NF }' | sort -u)+diff <(grep -v ^# etc/objects/commands.cfg | awk '/command_name/ { print $NF }' | sort) <(grep -v ^# etc/objects/commands.cfg | awk '/command_name/ { print $NF }' | sort -u)
 ~~~ ~~~
  
  
-### Sondes locales+#### Sondes locales
  
  
Ligne 437: Ligne 448:
 * Pour toute directive "use" il doit y avoir un template corespondant (template.cfg) * Pour toute directive "use" il doit y avoir un template corespondant (template.cfg)
 * Pour chaque "check_command" il doit y avoir une entrée "command_name" correspondante (commands.cfg) * Pour chaque "check_command" il doit y avoir une entrée "command_name" correspondante (commands.cfg)
 +* Tous les noms indiqués par la directive "name" dans les objets de type "host" doivent être résolvables 
 +
  
tech/exemple_simple_de_conf_nagios.1768398690.txt.gz · Dernière modification : de Jean-Baptiste

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki