tech:generateur_de_conf_nagios

Ceci est une ancienne révision du document !


Générateur de conf Nagios

Brouillon

object configuration files

Voir :

Voir aussi :

Fichiers plats à garder en statique :

  • commands.cfg
  • contacts.cfg
  • localhost.cfg
  • templates.cfg
  • timeperiods.cfg

Fichier à supprimer ou à regénérer :

  • printer.cfg
  • switch.cfg
  • windows.cfg

Types d'objets à générer :

  • host
  • hostgroup
  • service
  • servicegroup ?

Dans le conf par défaut nous avons les templates suivants pour les hosts

  • generic-host
  • linux-server
  • windows-server
  • generic-printer
  • generic-switch

et pour les services :

  • generic-service
  • local-service (utiliser que dans localhost.cfg)

Proposition de format YAML

---

hosts:
  - host_name:             "srv1"
    use:                   "linux-server"
    alias:                 "Server 1"
    address:               "192.168.1.10"

  - host_name:             "hplj2605dn"
    use:                   "generic-printer"
    alias:                 "HP LaserJet 2605dn"
    address:               "192.168.1.30"
    hostgroups:            "network-printers"             # Member of hostgroup

  - host_name:             "winserver"
    use:                   "windows-server"               # Template contains "hostgroups windows-servers"
    alias:                 "My Windows Server"
    address:               "192.168.1.2"

hostgroups:
  - hostgroup_name:        "linux-servers"
    alias:                 "Linux Servers"
    # members:             "srv1"                         # Member of hostgroup
    # hostgroup_members:

  - hostgroup_name:        "network-printers"
    alias:                 "Network Printers"

  - hostgroup_name:        "windows-servers"
    alias:                 "Windows Servers"

services:
  - service_description:   "SSH"
    use:                   "generic-service"
    #hostgroup:             "linux-remote-servers"
    hostgroup_name:        "generic-remote-hosts"
    check_command:         "check_ssh"                                                                                                                                           

  - service_description:   "NSClient++ Version"
    use:                   "generic-service"
    host_name:             "winserver"
    check_command:         "check_nt!CLIENTVERSION"

  - service_description:   Memory
    hostgroup_name:        "linux-servers"
    check_command:         "check_centreon_snmp_linux_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"

Entrées :

  • printer.yaml
  • switch.yaml
  • windows.yaml
  • linux.yaml

Sorties :

  • printer.cfg
  • switch.cfg
  • windows.cfg
  • linux.cfg

On ajoute un template au fichier templates.cfg

templates.cfg

#define host {
#
#    name                 tpl-host-windows
#    use                  windows-server
#    hostgroups           windows-hosts
#    register             0
#    }
 

define host {

    name                 linux-remote-servers
    use                  linux-server
    hostgroups           linux-hosts
    register             0
    }

Il faudra créer les hostgroups associer (à faire à partir de YAML)

linux.cfg

define hostgroup {
    hostgroup_name       linux-hosts
    alias                Linux Hosts
}

windows.cfg

define hostgroup {

    hostgroup_name       windows-hosts
    alias                Windows Hosts
}

Changer la définition des hosts use linux-server use linux-remote-servers

templates2.cfg

 
###############################################################################
#
# HOST TEMPLATES
#
###############################################################################
 
 
#define host {
#
#    name                            tpl-host-generic
#    use                             generic-host
#    hostgroups                      generic-remote-hosts
#    register                        0
#}
 
 
define host {
 
    name                            tpl-host-linux
    use                             linux-server
    hostgroups                      linux-hosts
    register                        0
}
 
 
define host {
 
    name                            tpl-host-windows
    use                             windows-server
    #hostgroups                      windows-servers
    hostgroups                      windows-hosts
    register                        0
}
 
 
define host {
 
    name                            tpl-host-printer
    use                             generic-printer
    hostgroups                      printer-hosts  
    register                        0
}
 
 
define host {
 
    name                            tpl-host-network
    use                             generic-switch
    hostgroups                      network-hosts
    register                        0
}
tech/generateur_de_conf_nagios.1745256420.txt.gz · Dernière modification : de Jean-Baptiste

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki