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"
    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 choisit de ne pas changer le fichier templates.cfg mais de créer un templates2.cfg

templates2.cfg

define host {

    name                         windows-tpl
    use                             windows-server
    hostgroups               windows-hosts
    register                      0
    }
 

define host {

    name                         linux-tpl
    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 windows-server'' en
''use windows-tpl''

Changer la définition des hosts
''use linux-server''
''use linux-tpl''





tech/generateur_de_conf_nagios.1745232609.txt.gz · Dernière modification : de Jean-Baptiste

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki