Difference between revisions of "Nagios"
(21 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
+ | = Monitoring met Nagios = |
||
+ | == Webhuis opzet == |
||
+ | Nagios is qua opzet vrij complex en de configuratie is foutgevoelig. Nagios bepaalt het functioneren aan de hand van een groot aantal verschillende, op verschillende plaatsen aanwezige, samenhangende configuratiebestanden. Er is een basis configuratie en in plaats van de eigen configuratie uit te breiden is het beter om de eigen configuratiebestanden onder te brengen in een aparte structuur. |
||
+ | |||
+ | * http://nagios.manubulon.com/index_commands.html |
||
+ | |||
+ | Nagios kent een hierarchische organisatie en laat met de parameter cfg_dir toe dat Webhuis de configuratiebestanden voor de klant in verschillende directories vastlegt, telkens met de naam <domein>.cfg. Voor elke klant is zo'n configuratiebestand aanwezig in elk van de volgende directories: |
||
+ | * hostgroups |
||
+ | * hosts |
||
+ | * scripts |
||
+ | * services |
||
+ | Het primaire nagios configuratiebestand /etc/nagios/nagios.cfg refereert aan deze directories: |
||
+ | <pre> |
||
+ | cfg_dir=/etc/nagios/hostgroups/ |
||
+ | cfg_dir=/etc/nagios/hosts/ |
||
+ | cfg_dir=/etc/nagios/scripts/ |
||
+ | cfg_dir=/etc/nagios/services/ |
||
+ | </pre> |
||
+ | Op deze manier is de opzet van nagios flexibel en zijn wijzigingen gemakkelijk door te voeren.<br/> |
||
+ | Bijzondere commando's staan in de driectory /etc/nagios/commands/. |
||
+ | * http://s23.org/wiki/Nagios/checks/ldap |
||
+ | * http://nagios.sourceforge.net/docs/2_0/templatetricks.html#hostgroup |
||
+ | Uitzoeken, https mobile.cir |
||
+ | === Hostgroups === |
||
+ | <pre> |
||
+ | # |
||
+ | # hostgroups.cfg - Config file for Nagios (www.nagios.org) |
||
+ | # |
||
+ | |||
+ | define hostgroup { |
||
+ | hostgroup_name <domein> |
||
+ | alias <domein> |
||
+ | name <domein> |
||
+ | contact_groups router-admins |
||
+ | register 1 |
||
+ | members dom0.<domein>,ips-vpn.<domein>,smb.<domein>,mail.<domein> |
||
+ | } |
||
+ | </pre> |
||
+ | === Hosts === |
||
+ | <pre> |
||
+ | define host{ |
||
+ | use generic-host ; Name of host template to use |
||
+ | |||
+ | host_name dom0.<domein> |
||
+ | alias dom0.<domein> |
||
+ | address 10.x.y.z |
||
+ | max_check_attempts 20 |
||
+ | notification_interval 60 |
||
+ | notification_period 24x7 |
||
+ | notification_options d,u,r |
||
+ | } |
||
+ | define host{ |
||
+ | use generic-host ; Name of host template to use |
||
+ | |||
+ | host_name ips-vpn.<domein> |
||
+ | alias ips-vpn.<domein> |
||
+ | address a.b.c.d |
||
+ | max_check_attempts 20 |
||
+ | notification_interval 60 |
||
+ | notification_period 24x7 |
||
+ | notification_options d,u,r |
||
+ | } |
||
+ | define host{ |
||
+ | use generic-host ; Name of host template to use |
||
+ | host_name smb.<domein> |
||
+ | alias smb.<domein> |
||
+ | address 10.x.y.11 |
||
+ | max_check_attempts 20 |
||
+ | notification_interval 60 |
||
+ | notification_period 24x7 |
||
+ | notification_options d,u,r |
||
+ | } |
||
+ | define host{ |
||
+ | use generic-host ; Name of host template to use |
||
+ | host_name mail.<domein> |
||
+ | alias mail.<domein> |
||
+ | address 10.x.y.12 |
||
+ | max_check_attempts 20 |
||
+ | notification_interval 60 |
||
+ | notification_period 24x7 |
||
+ | notification_options d,u,r |
||
+ | } |
||
+ | </pre> |
||
+ | |||
+ | === Services === |
||
+ | <pre> |
||
+ | define service { |
||
+ | host_name dom0.<domein>,ips-vpn.<domein>,smb.<domein>,mail.<domein> |
||
+ | service_description ssh |
||
+ | check_command check_ssh |
||
+ | name ssh |
||
+ | register 1 |
||
+ | max_check_attempts 3 |
||
+ | normal_check_interval 5 |
||
+ | retry_check_interval 1 |
||
+ | active_checks_enabled 1 |
||
+ | check_period 24x7 |
||
+ | notification_interval 120 |
||
+ | notification_period 24x7 |
||
+ | notification_options w,u,c,r |
||
+ | notifications_enabled 1 |
||
+ | contact_groups admins |
||
+ | } |
||
+ | define service { |
||
+ | host_name smb.<domein> |
||
+ | service_description check_ldap |
||
+ | use generic-service |
||
+ | check_command check_ldap!-H $hOSTADDRESS$ -b "cn=admin,dc=<domein>" |
||
+ | name ldap |
||
+ | register 1 |
||
+ | max_check_attempts 3 |
||
+ | normal_check_interval 5 |
||
+ | retry_check_interval 1 |
||
+ | active_checks_enabled 1 |
||
+ | check_period 24x7 |
||
+ | notification_interval 120 |
||
+ | notification_period 24x7 |
||
+ | notification_options w,u,c,r |
||
+ | notifications_enabled 1 |
||
+ | contact_groups admins |
||
+ | } |
||
+ | </pre> |
||
+ | |||
+ | == Specificatie van checks == |
||
+ | === check_ldap === |
||
+ | De check van ldap vindt plaats met behulp van de standaard nagios plugin: |
||
+ | <pre> |
||
+ | define service { |
||
+ | host_name <fdqn> |
||
+ | service_description check_ldap |
||
+ | use generic-service |
||
+ | check_command check_ldap!-H $hOSTADDRESS$ -b "cn=admin,dc=<fqdn>" |
||
+ | name ldap |
||
+ | register 1 |
||
+ | max_check_attempts 3 |
||
+ | normal_check_interval 5 |
||
+ | retry_check_interval 1 |
||
+ | active_checks_enabled 1 |
||
+ | check_period 24x7 |
||
+ | notification_interval 120 |
||
+ | notification_period 24x7 |
||
+ | notification_options w,u,c,r |
||
+ | notifications_enabled 1 |
||
+ | contact_groups admins |
||
+ | } |
||
+ | </pre> |
||
+ | === check samba === |
||
+ | In /etc/nagios/scripts staat het script check_samba. |
||
+ | <pre> |
||
+ | #!/bin/sh |
||
+ | # |
||
+ | /usr/bin/smbclient -W ${2} -L ${1} -N >/dev/null |
||
+ | if test ${?} -eq 0 |
||
+ | then |
||
+ | echo "\\\\${1}\\\\${2} answered SAMBA request" |
||
+ | exit 0 |
||
+ | else |
||
+ | echo "\\\\${1}\\\\${2} not responding to SAMBA requests" |
||
+ | exit 1 |
||
+ | fi |
||
+ | </pre> |
||
+ | Aanroep van het script in services: |
||
+ | <pre> |
||
+ | define service { |
||
+ | host_name >fqdn> |
||
+ | service_description samba |
||
+ | check_command check_samba! <fqdn> <nt-domain> |
||
+ | name samba |
||
+ | register 1 |
||
+ | max_check_attempts 3 |
||
+ | normal_check_interval 5 |
||
+ | retry_check_interval 1 |
||
+ | active_checks_enabled 1 |
||
+ | check_period 24x7 |
||
+ | notification_interval 120 |
||
+ | notification_period 24x7 |
||
+ | notification_options w,u,c,r |
||
+ | notifications_enabled 1 |
||
+ | contact_groups admins |
||
+ | } |
||
+ | </pre> |
||
<hr/> |
<hr/> |
||
− | Terug naar: [[ |
+ | Terug naar: [[Webhuis Support Infrastructuur]] |
Latest revision as of 10:33, 15 May 2012
Contents
Monitoring met Nagios
Webhuis opzet
Nagios is qua opzet vrij complex en de configuratie is foutgevoelig. Nagios bepaalt het functioneren aan de hand van een groot aantal verschillende, op verschillende plaatsen aanwezige, samenhangende configuratiebestanden. Er is een basis configuratie en in plaats van de eigen configuratie uit te breiden is het beter om de eigen configuratiebestanden onder te brengen in een aparte structuur.
Nagios kent een hierarchische organisatie en laat met de parameter cfg_dir toe dat Webhuis de configuratiebestanden voor de klant in verschillende directories vastlegt, telkens met de naam <domein>.cfg. Voor elke klant is zo'n configuratiebestand aanwezig in elk van de volgende directories:
- hostgroups
- hosts
- scripts
- services
Het primaire nagios configuratiebestand /etc/nagios/nagios.cfg refereert aan deze directories:
cfg_dir=/etc/nagios/hostgroups/ cfg_dir=/etc/nagios/hosts/ cfg_dir=/etc/nagios/scripts/ cfg_dir=/etc/nagios/services/
Op deze manier is de opzet van nagios flexibel en zijn wijzigingen gemakkelijk door te voeren.
Bijzondere commando's staan in de driectory /etc/nagios/commands/.
- http://s23.org/wiki/Nagios/checks/ldap
- http://nagios.sourceforge.net/docs/2_0/templatetricks.html#hostgroup
Uitzoeken, https mobile.cir
Hostgroups
# # hostgroups.cfg - Config file for Nagios (www.nagios.org) # define hostgroup { hostgroup_name <domein> alias <domein> name <domein> contact_groups router-admins register 1 members dom0.<domein>,ips-vpn.<domein>,smb.<domein>,mail.<domein> }
Hosts
define host{ use generic-host ; Name of host template to use host_name dom0.<domein> alias dom0.<domein> address 10.x.y.z max_check_attempts 20 notification_interval 60 notification_period 24x7 notification_options d,u,r } define host{ use generic-host ; Name of host template to use host_name ips-vpn.<domein> alias ips-vpn.<domein> address a.b.c.d max_check_attempts 20 notification_interval 60 notification_period 24x7 notification_options d,u,r } define host{ use generic-host ; Name of host template to use host_name smb.<domein> alias smb.<domein> address 10.x.y.11 max_check_attempts 20 notification_interval 60 notification_period 24x7 notification_options d,u,r } define host{ use generic-host ; Name of host template to use host_name mail.<domein> alias mail.<domein> address 10.x.y.12 max_check_attempts 20 notification_interval 60 notification_period 24x7 notification_options d,u,r }
Services
define service { host_name dom0.<domein>,ips-vpn.<domein>,smb.<domein>,mail.<domein> service_description ssh check_command check_ssh name ssh register 1 max_check_attempts 3 normal_check_interval 5 retry_check_interval 1 active_checks_enabled 1 check_period 24x7 notification_interval 120 notification_period 24x7 notification_options w,u,c,r notifications_enabled 1 contact_groups admins } define service { host_name smb.<domein> service_description check_ldap use generic-service check_command check_ldap!-H $hOSTADDRESS$ -b "cn=admin,dc=<domein>" name ldap register 1 max_check_attempts 3 normal_check_interval 5 retry_check_interval 1 active_checks_enabled 1 check_period 24x7 notification_interval 120 notification_period 24x7 notification_options w,u,c,r notifications_enabled 1 contact_groups admins }
Specificatie van checks
check_ldap
De check van ldap vindt plaats met behulp van de standaard nagios plugin:
define service { host_name <fdqn> service_description check_ldap use generic-service check_command check_ldap!-H $hOSTADDRESS$ -b "cn=admin,dc=<fqdn>" name ldap register 1 max_check_attempts 3 normal_check_interval 5 retry_check_interval 1 active_checks_enabled 1 check_period 24x7 notification_interval 120 notification_period 24x7 notification_options w,u,c,r notifications_enabled 1 contact_groups admins }
check samba
In /etc/nagios/scripts staat het script check_samba.
#!/bin/sh # /usr/bin/smbclient -W ${2} -L ${1} -N >/dev/null if test ${?} -eq 0 then echo "\\\\${1}\\\\${2} answered SAMBA request" exit 0 else echo "\\\\${1}\\\\${2} not responding to SAMBA requests" exit 1 fi
Aanroep van het script in services:
define service { host_name >fqdn> service_description samba check_command check_samba! <fqdn> <nt-domain> name samba register 1 max_check_attempts 3 normal_check_interval 5 retry_check_interval 1 active_checks_enabled 1 check_period 24x7 notification_interval 120 notification_period 24x7 notification_options w,u,c,r notifications_enabled 1 contact_groups admins }
Terug naar: Webhuis Support Infrastructuur