Help Linux - до свидания! См. Новости проекта

You are here: start » en » kb » nagios-distributed


|

Дополнительно

 Creative Commons

Nagios Distributed Monitoring configuration

Central Server configuration (Ubuntu 12.04 Server LTS)

Installation and configuration

  1. Install packages
    sudo apt-get install nagios3 --no-install-recommends	# use "--no-install-recommends" in order not to install samba packages
    sudo apt-get install nagios-images
    sudo apt-get install nsca && update-rc.d nsca enable
  2. Make directories for custom configs
    sudo mkdir -p /etc/nagios3/custom/{commands,hosts,services,templates}
  3. Edit /etc/nagios3/nagios.cfg
    --- nagios.cfg.orig     2012-02-15 21:10:11.000000000 +0400
    +++ nagios.cfg  2012-05-17 14:40:43.734332705 +0400
    @@ -55,6 +55,10 @@
     #cfg_dir=/etc/nagios3/printers
     #cfg_dir=/etc/nagios3/switches
     #cfg_dir=/etc/nagios3/routers
    +cfg_dir=/etc/nagios3/custom/commands
    +cfg_dir=/etc/nagios3/custom/hosts
    +cfg_dir=/etc/nagios3/custom/services
    +cfg_dir=/etc/nagios3/custom/templates
     
     
     
    @@ -142,7 +146,8 @@
     # you will have to enable this.
     # Values: 0 = disable commands, 1 = enable commands
     
    -check_external_commands=0
    +#check_external_commands=0
    +check_external_commands=1
     
     
     
    @@ -1027,7 +1032,8 @@
     # manner.
     # Values: 1 = enabled freshness checking, 0 = disable freshness checking
     
    -check_host_freshness=0
    +#check_host_freshness=0
    +check_host_freshness=1
    
    
    
    
  4. Change permissions to /var/lib/nagios3
    # Change directory permissions and make the changes permanent in order to make external commands work (check /usr/share/doc/nagios3/README.Debian for more information)
    /etc/init.d/nagios3 stop
    dpkg-statoverride --update --add nagios www-data 2710 /var/lib/nagios3/rw
    dpkg-statoverride --update --add nagios nagios 751 /var/lib/nagios3
    /etc/init.d/nagios3 start
  5. Add /etc/nagios3/custom/templates/generic-host-passive.cfg
    define host{
            name                            generic-host-passive
            use                             generic-host
            active_checks_enabled           0
            check_freshness                 1
            check_command                   return-unknown
            register                        0
            }
  6. Add /etc/nagios3/custom/templates/generic-service-passive.cfg
    define service{
            name                            generic-service-passive
            use                             generic-service
            active_checks_enabled           0
            check_freshness                 1
            check_command                   return-unknown
            register                        0
            }
  7. Create a user and password
    # Create htpasswd file and set a password for nagiosadmin (this information is used to access the web-interface)
    htpasswd -c /etc/nagios3/htpasswd.users nagiosadmin
  8. Examples of a passive host and a service definitions:
    • /etc/nagios3/custom/hosts/server1.cfg
      # Define host "server1"
      define host{
              use             generic-host-passive
              host_name       server1
              }
    • /etc/nagios3/custom/services/disk-space.cfg
      # Define service "Disk Space"
      define service{
              use                             generic-service-passive
              host_name                       server1
              service_description             PING
              }

Usage

  • Apply the new configuration
    sudo /etc/init.d/nagios3 reload
  • Use http://IPADDRESS/nagios3 in order to access nagios web-interface

Distributed Server configuration (Ubuntu 12.04 Server LTS)

Installation and configuration

  1. Install packages
    sudo apt-get install nagios3-core
    sudo apt-get install nagios3-cgi --no-install-recommends	# use "--no-install-recommends" in order not to install apache2 packages
    sudo apt-get install nsca
  2. Disable localhost checking in order not to confuse with localhost on the Central Server
    sudo rename 's/$/.disabled/' /etc/nagios3/conf.d/{extinfo_nagios2,hostgroups_nagios2,localhost_nagios2,services_nagios2}.cfg
  3. Edit /etc/nagios3/nagios.cfg
    --- nagios.cfg.orig	2011-06-07 17:08:33.000000000 +0400
    +++ nagios.cfg	2012-05-18 14:57:29.343833057 +0400
    @@ -55,6 +55,9 @@
     #cfg_dir=/etc/nagios3/printers
     #cfg_dir=/etc/nagios3/switches
     #cfg_dir=/etc/nagios3/routers
    +cfg_dir=/etc/nagios3/commands
    +cfg_dir=/etc/nagios3/hosts
    +cfg_dir=/etc/nagios3/services
     
     
     
    @@ -808,7 +811,8 @@
     # service notifications when it is initially (re)started.
     # Values: 1 = enable notifications, 0 = disable notifications
     
    -enable_notifications=1
    +#enable_notifications=1
    +enable_notifications=0
     
     
     
    @@ -913,7 +917,8 @@
     # implementing distributed monitoring.
     # Values: 1 = obsess over services, 0 = do not obsess (default)
     
    -obsess_over_services=0
    +#obsess_over_services=0
    +obsess_over_services=1
     
     
     
    @@ -926,6 +931,7 @@
     # more information on implementing distributed monitoring.
     
     #ocsp_command=somecommand
    +ocsp_command=submit_check_result_via_nsca_service
     
     
     
    @@ -937,7 +943,8 @@
     # implementing distributed monitoring.
     # Values: 1 = obsess over hosts, 0 = do not obsess (default)
     
    -obsess_over_hosts=0
    +#obsess_over_hosts=0
    +obsess_over_hosts=1
     
     
     
    @@ -950,6 +957,7 @@
     # more information on implementing distributed monitoring.
     
     #ochp_command=somecommand
    +ochp_command=submit_check_result_via_nsca_host
     
     
     
  4. Edit /etc/nagios3/resource.cfg
    --- resource.cfg.orig	2011-06-07 17:07:47.000000000 +0400
    +++ resource.cfg	2012-05-12 17:39:46.125679961 +0400
    @@ -24,7 +24,7 @@
     $USER1$=/usr/lib/nagios/plugins
     
     # Sets $USER2$ to be the path to event handlers
    -#$USER2$=/usr/lib/nagios/plugins/eventhandlers
    +$USER2$=/usr/share/nagios3/plugins/eventhandlers
     
     # Store some usernames and passwords (hidden from the CGIs)
     #$USER3$=someuser
  5. Add /etc/nagios3/commands/submit_check_result_via_nsca_host.cfg
    define command{
            command_name    submit_check_result_via_nsca_host
            command_line    $USER2$/distributed-monitoring/submit_check_result_via_nsca $HOSTNAME$ $HOSTSTATEID$ '$HOSTOUTPUT$|$HOSTPERFDATA$'
    }
  6. Add /etc/nagios3/commands/submit_check_result_via_nsca_service.cfg
    define command{
            command_name    submit_check_result_via_nsca_service
            command_line    $USER2$/distributed-monitoring/submit_check_result_via_nsca $HOSTNAME$ '$SERVICEDESC$' $SERVICESTATEID$ '$SERVICEOUTPUT$|$SERVICEPERFDATA$'
    }
  7. Examples of an active host and a service definitions:
    • /etc/nagios3/hosts/server1.cfg
      define host{
              use                     generic-host
              host_name               server1
              address                 127.0.0.1
              }
    • /etc/nagios3/services/ping.cfg
      define service {
              use                             generic-service
              service_description             PING
              check_command                   check_ping!100.0,20%!500.0,60%
              host_name                       server1
      }

Usage

  • Apply the new configuration
    sudo /etc/init.d/nagios3 reload

Links