nagios-1.3-14 (Network Monitor)

12/June/2005 tested on openSUSE 10.1

Nagios is an open source and network resource monitoring software. It can monitor hosts and services that you specify, alerting you when things get bad and when they get better.

RPMs are available for openSuSE10.1. However rpms are not included in CD nor DVD. rpms are only available at the Internet Installation Repository.
i.e. http://download.opensuse.org/distribution/SL-10.1/inst-source/

Installation

  • Install RPMs from the Net Installation Repository. Open YaST, Software, Installation Source and add the Internet installation repository. Check URL from http://en.opensuse.org/Mirrors_Released_Version
  • Open Software Management at YaST, search by "nagios", and install them all. You will be installing the following packages.
    nagios-1.3-14.i586.rpm
    nagios-nagat-1.0a2-289.noarch.rpm
    nagios-nrpe-2.2-15.i586.rpm
    nagios-plugins-1.4.2-16.i586.rpm
    nagios-plugins-extras-1.4.2-16.i586.rpm
    nagios-www-1.3-14
    

    Configure Web Interface

    Edit /etc/apache2/conf.d/nagios.conf, and give access to network where you want to open the web interface.
    ScriptAlias /nagios/cgi-bin/ /usr/lib/nagios/cgi/
    <Directory /usr/lib/nagios/cgi/>
       Options ExecCGI
       order deny,allow
       deny from all
       allow from 127.0.0.1 192.168.0.0/24
       AuthName "Nagios Access"
       AuthType Basic
       AuthUserFile /etc/nagios/htpasswd.users
       require valid-user
    </Directory>
    
    Alias /nagios/ /usr/share/nagios/
    <Directory /usr/share/nagios/>
       Options None
       order deny,allow
       deny from all
       allow from 127.0.0.1 192.168.0.0/24
       AuthName "Nagios Access"
       AuthType Basic
       AuthUserFile /etc/nagios/htpasswd.users
       require valid-user
    </Directory>
    
    Edit /etc/apache2/conf.d/nagat.conf, and give the same configuration.
    Alias /nagat/ /usr/share/nagat/
    <Directory /usr/share/nagat/>
       Options None
       order deny,allow
       deny from all
       allow from 127.0.0.1 192.168.0.0/24
       php_flag register_globals on
    </Directory>
    
    This will create a username and password for nagiosamin. If you change the username, you must chage the corresponding lines at cgi.cfg for the user as well.
    # htpasswd2 -c /etc/nagios/htpasswd.users nagiosadmin
    
    Edit /etc/nagios/cgi.cfg, and make sure use_authentication=1
    ...
    use_authentication=1
    ...
    
    Restart Apache
    # /etc/init.d/apache2 restart
    

    Configuration

    This is an example network.
    srv1(nagios) (192.168.66.128)
         |
       Firewall (192.168.254.254)-- ISP1 (85.115.193.253) -- ISP2 (213.248.68.33)
         |
    winxp1(192.168.66.1)
    

    Network Device

    Edit /etc/nagios/hosts.cfg as,
    # Generic host definition template
    define host{
            name                            generic-host
            notifications_enabled           1
            event_handler_enabled           1
            flap_detection_enabled          1
            process_perf_data               1
            retain_status_information       1
            retain_nonstatus_information    1
            max_check_attempts              3
            notification_interval           240
            register                        0
            }
    
    # 'srv1' host definition
    define host{
            use                     generic-host
            host_name               srv1
            alias                   srv1.test1.kg
            address                 192.168.66.128
            check_command           check-host-alive
            }
    
    # 'winxp1' host definition
    define host{
            use                     generic-host
            host_name               winxp1
            alias                   winxp1.test1.kg
            address                 192.168.66.1
            check_command           check-host-alive
            }
    
    # 'firewall' host definition
    define host{
            use                     generic-host
            host_name               firewall
            alias                   firewall.test1.kg
            address                 192.168.254.254
            check_command           check-host-alive
            }
    
    # 'isp1-router' host definition
    define host{
            use                     generic-host
            host_name               isp1-router
            alias                   ISP1 Router
            address                 85.115.193.253
            parents                 firewall
            check_command           check-host-alive
            }
    
    # 'isp2-router' host definition
    define host{
            use                     generic-host
            host_name               isp2-router
            alias                   ISP2 Router
            address                 213.248.68.33
            parents                 isp1-router
            check_command           check-host-alive
            }
    
    Edit /etc/nagios/hostgroups.cfg
    # 'local-servers' host group definition
    define hostgroup{
            hostgroup_name  local-servers
            alias           Local Servers
            contact_groups  admin-contactgroup
            members         srv1,winxp1,firewall
            }
    
    # 'isp-routers' host group definition
    define hostgroup{
            hostgroup_name  isp-routers
            alias           IPS Routers
            contact_groups  admin-contactgroup
            members         isp1-router,isp2-router
            }
    
    Edit /etc/nagios/services.cfg
    # Generic service definition template
    define service{
            name                            generic-service
            notifications_enabled           1
            event_handler_enabled           1
            process_perf_data               1
            retain_status_information       1
            retain_nonstatus_information    1
            is_volatile                     0
            max_check_attempts              3
            normal_check_interval           5
            retry_check_interval            1
            check_period                    24x7
            notification_interval           240
            notification_period             24x7
            notification_options            w,c,r
            contact_groups                  admin-contactgroup
            register                        0
            }
    # Service definition
    define service{
            use                             generic-service
            host_name                       firewall
            service_description             PING
            check_command                   check_ping!100.0,20%!500.0,60%
            }
    define service{
            use                             generic-service
            host_name                       isp1-router
            service_description             PING
            check_command                   check_ping!500.0,20%!1000.0,60%
            }
    define service{
            use                             generic-service
            host_name                       isp2-router
            service_description             PING
            check_command                   check_ping!500.0,20%!1000.0,60%
            }
    define service{
            use                             generic-service
            host_name                       srv1
            service_description             PING
            check_command                   check_ping!100.0,20%!500.0,60%
            }
    define service{
            use                             generic-service
            host_name                       srv1
            service_description             HTTP
            check_command                   check_http
            }
    define service{
            use                             generic-service
            host_name                       srv1
            service_description             POP
            check_command                   check_pop
            }
    define service{
            use                             generic-service
            host_name                       srv1
            service_description             SMTP
            check_command                   check_smtp
            }
    define service{
            use                             generic-service
            host_name                       srv1
            service_description             DNS
            check_command                   check_dns
            }
    define service{
            use                             generic-service
            host_name                       winxp1
            service_description             PING
            check_command                   check_ping!100.0,20%!500.0,60%
            }
    define service{
            use                             generic-service
            host_name                       winxp1
            service_description             HTTP
            check_command                   check_http
            }
    
    ## LOCAL SYSTEM
    define service{
            use                             generic-service
            host_name                       srv1
            service_description             LOCAL DISK
            check_command                   check_local_disk!20%!10%!/dev/sda6
            }
    
    define service{
            use                             generic-service
            host_name                       srv1
            service_description             LOCAL USERS
            check_command                   check_local_users!75!150
            }
    
    define service{
            use                             generic-service
            host_name                       srv1
            service_description             LOCAL PROCS
            check_command                   check_local_procs!150!200!RSZDT
            }
    
    

    Plug-in

    Note that the following plugins are available for services.cfg
    check_breezecheck_httpcheck_mysqlcheck_procscheck_time
    check_by_sshcheck_icmpcheck_nagioscheck_radiuscheck_udp
    check_dhcpcheck_ifoperstatuscheck_nntpcheck_realcheck_udp2
    check_digcheck_ifstatuscheck_nntpscheck_rpccheck_ups
    check_diskcheck_imapcheck_nrpecheck_sensorscheck_users
    check_disk_smbcheck_ircdcheck_ntcheck_simapcheck_wave
    check_dnscheck_jabbercheck_ntpcheck_smtpnegate
    check_dummycheck_ldapcheck_nwstatcheck_snmpurlize
    check_file_agecheck_loadcheck_oraclecheck_spoputils.pm
    check_flexlmcheck_logcheck_overcrcheck_sshutils.sh
    check_fpingcheck_mailqcheck_pgsqlcheck_ssmtp
    check_ftpcheck_mrtgcheck_pingcheck_swap
    check_hpjdcheck_mrtgtrafcheck_popcheck_tcp

  • Execute with -h option to check the help
    # cd /usr/lib/nagios/plugins/
    # ./check_imap -h
    check_IMAP (nagios-plugins 1.4.2) 1.66
    Copyright (c) 1999 Ethan Galstad <nagios@nagios.org>
    Copyright (c) 1999-2004 Nagios Plugin Development Team
            <nagiosplug-devel@lists.sourceforge.net>
    
    This plugin tests IMAP connections with the specified host.
    
    Usage: check_IMAP -H host -p port [-w <warning time>] [-c <critical time>]
                      [-s <send string>] [-e <expect string>] [-q <quit string>]
                      [-m <maximum bytes>] [-d <delay>] [-t <timeout seconds>]
                      [-r <refuse state>] [-M <mismatch state>] [-v] [-4|-6] [-j]
                      [-D <days to cert expiry>] [-S <use SSL>]
    ...
    
    To check the imap, test as,
    # ./check_imap -H 192.168.5.1
    SSH OK - OpenSSH_4.2-chrootssh (protocol 1.99)
    
    Edit /etc/nagios/checkcommands.cfg, and define the template for the plugin, if it is not configured. For example,
    define command{
            command_name    check_imap
            command_line    $USER1$/check_imap -H $HOSTADDRESS$
            }
    
    define command{
            command_name    check_ssh
            command_line    $USER1$/check_ssh $HOSTADDRESS$
            }
    
    define command{
            command_name    check_nt_cpu
            command_line    $USER1$/check_nt -H $HOSTADDRESS$ -v CPULOAD -l 60,90,95,120,90,95
            }
    
    define command{
            command_name    check_nt_mem
            command_line    $USER1$/check_nt -H $HOSTADDRESS$ -v MEMUSE
            }
    ...
    

    Note: For check_nt plugin, you need to install NSClient to Windows PC. Download from http://nsclient.ready2run.nl/

    Open /etc/nagios/services.cfg, and add followings,
    define service{
            use                             generic-service
            host_name                       srv1
            service_description             IMAP
            check_command                   check_imap
            }
    
    define service{
            use                             generic-service
            host_name                       srv1
            service_description             SSH
            check_command                   check_ssh
            }
    
    define service{
            use                             generic-service
            host_name                       winxp1
            service_description             CPU
            check_command                   check_nt_cpu
            }
    
    define service{
            use                             generic-service
            host_name                       winxp1
            service_description             MEM
            check_command                   check_nt_mem
            }
    

    Contacts

    Edit /etc/nagios/contacts.cfg
    define contact{
            name                            generic-contact
            contact_name                    daemon
            alias                           Nagios Admin
            service_notification_period     24x7
            host_notification_period        24x7
            service_notification_options    w,u,c,r
            host_notification_options       d,r
            service_notification_commands   notify-by-email,notify-by-epager
            host_notification_commands      host-notify-by-email
            register                        0
            }
    
    # 'user1' contact definition
    define contact{
            use                             generic-contact
            contact_name                    admin
            alias                           Admin
            email                           user1@test1.kg
            }
    
    Edit /etc/nagios/contactgroups.cfg
    # 'admin-contactgroup' contact group definition
    define contactgroup{
            contactgroup_name       admin-contactgroup
            alias                   admin-contactgroup
            members                 admin
            }
    
    Edit /etc/nagios/escalations.cfg
    # Hostgroup 'local-servers' escalation definition
    define hostgroupescalation{
            hostgroup_name          local-servers
            first_notification              2
            last_notification               5
            contact_groups                  admin-contactgroup
            notification_interval           10
            }
    
    Edit /etc/nagios/dependencies.cfg. Delete all lines, but keep this file.

    Run nagios

    Verify the configuration
    # nagios -v nagios.cfg
    
    If there is not error, you will see as,
    Total Warnings: 0
    Total Errors:   0
    
    Things look okay - No serious problems were detected during the pre-flight check
    
  • Run nagios, nrpe, and nagios-nrpe
    # chkconfig nagios on
    # chkconfig nrpe on
    # chkconfig nagios-nrpe on
    # /etc/init.d/nagios restart
    # /etc/init.d/nrpe restart
    # /etc/init.d/xinetd restart
    

    Report

  • Open http://yourhost/nagios/
  • Service Detail
  • Host Detail
  • Status Overview
  • Status Summary
  • Status Grid
  • Status Map
  • 3D Status Map
  • You might need to install VRML plug-in for your browser. i.e.,
    1. Windows: Cortona VRML Client (http://www.parallelgraphics.com/products/cortona/)
    2. Linux: FreeWRL (http://freewrl.sourceforge.net/)

  • Back
    Google
    Web www.grape-info.com