Outils pour utilisateurs

Outils du site


tech:notes_supervision_nagios

Ceci est une ancienne révision du document !


Notes supervision Nagios

Administration

Effacer l'historique des données remontées par les sondes Nagios

/etc/init.d/nagios stop
rm /usr/local/nagios/var/retention.dat
rm /usr/local/nagios/var/objects.cache
/etc/init.d/nagios start

A la place de systématiquement effacer ces fichiers avant de démarrer Nagios il est possible de changer :

nagios.cfg

#retain_state_information=1
retain_state_information=0

Configuration

Exemple de conf

Exemple avec check_snmp_mem_cpu.sh

/usr/local/nagios/etc/objects/servers.cfg

define service{
        service_description     Memory
        hostgroup_name          WEB_APP1
        check_command           check_snmp_mem_cpu!mem!80!90
        max_check_attempts      1
        normal_check_interval   1
        retry_check_interval    1
        check_period            24x7
        notification_interval   2000
        notification_period     24x7
        notification_options    w,c,r
        contact_groups          support
        #event_handler           trigger_memory
        }

/usr/local/nagios/etc/objects/commands.cfg

define command{
        command_name    check_snmp_mem_cpu
        command_line    $USER1$/check_snmp_mem.sh -H $HOSTADDRESS$ -t $ARG1$ -w $ARG2$ -c $ARG3$
        }

Supervision de services sans hôte réel associé

Voir :

Voir aussi :

Un service doit forcémenet être attaché à un hôte pour pouvoir être utilisé.

Dans certains cas il faudrait créer un hôte fantôme pour porter le service

define host{
        host_name	    generic
	use                 linux-server
	check_command	    check_dummy!0     # Revoit toujours OK
        max_check_attempts  1
        contact_groups      admins
}
 
define service{
        service_description plop
        use generic-service
	host_name generic
	check_command check_plop!80
}

Bonne solution

Finalement la solution est

define host{
        host_name	target
	use             generic-host
}
 
define service{
        service_description plop
        use generic-service
	host_name target
	check_command check_plop!80
}

Exemple conf host hostgroupe service

define host {
    use         physical-host
    host_name   busy-host.example.com
    alias       busy-host.example.com
    address     10.43.16.1
    hostgroups  linux,centos,ldap,http,busy
}
 
define host {
    use           physical-host
    host_name     normal-host.example.com
    alias         narmal-host.example.com
    address       10.43.1.1
    hostgroups    linux,centos,dns,proxy,ldap,hp,http,puppetmaster
}
 
define service {
    use                   generic-service
    hostgroup_name        linux,!busy
    service_description   Load
    check_command         check_snmp_load
}
 
define service {
    use                   generic-service
    hostgroup_name        busy
    service_description   Load
    check_command         check_snmp_load_busy
}

Conf des hosts

Conf des services

etc/objects/servers.cfg

define service{
    use generic-service
    hostgroup linux-remotes-servers
    service_description  Total Processes
    max_check_attempts 3         ; Re-check the service up to 3 times in order to determine its final (hard) state
    retry_check_interval 1       ; Re-check the service every minute until a hard state can be determined
    check_command check_snmp_host!procs!400!900
    flap_detection_enabled 0
}

Exclusion

define service{
        service_description     CPU Stats
        servicegroups   sysres
        use             generic
        hostgroup_name  linux
        host_name       !server1
        check_command   check_iostat
}

Conf command

Dummy commands.cfg

# 'check_dummy' command definition
# NOTE: This command always returns an 'OK' result no matter what.
define command{
        command_name    check_dummy
        command_line    $USER1$/check_dummy 0
}

Sondes locales

Toutes les sondes locales (qui remonte des infos du host sur lequel le script est exécuté) devraient avoir un command_name commençant par “check_local_”

Sauf exception seules les fichiers suivants devraient contenir ce motif

$ rgrep -l check_local_ *
objects/commands.cfg
objects/localhost.cfg

Exemple

objects/commands.cfg

define command {
    command_name    check_local_procs
    command_line    $USER1$/check_procs -w $ARG1$ -c $ARG2$ -s $ARG3$
}

Même chose avec les local-service

$ rgrep -l local-service *
objects/templates.cfg
objects/localhost.cfg

templates.cfg

  • Tous les bloques de code register 0 devraient être dans le fichier templates.cfg
  • Tous les bloques de code présent dans le fichier templates.cfg devrait avoir register 0

Vérifier la conf

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
tech/notes_supervision_nagios.1768398081.txt.gz · Dernière modification : de Jean-Baptiste

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki