Part II: Nagios installation Configuration

Source: Internet
Author: User
Tags disk usage

  • Nagios Installation-server side (192.168.0.11)
    Then install the Nagios-related packages
    Yum install-y httpd nagios nagios-plugins nagios-plugins-all Nrpe Nagios-plugins-nrpe
    Set user and password to log in to Nagios background: htpasswd-c/etc/nagios/passwd nagiosadmin
    Vim/etc/nagios/nagios.cfg
    Nagios-v/etc/nagios/nagios.cfg Detection configuration file
  • Nagios Installation-Client (192.168.0.12)
    On the client machine
    Yum Install-y epel-release
    Yum install-y nagios-plugins nagios-plugins-all Nrpe Nagios-plugins-nrpe
  • Monitoring Center (192.168.0.11) add monitored host (192.168.0.12)
    cd/etc/nagios/conf.d/
    Vim 192.168.0.12.cfg//join:
    Define Host{
    Use Linux-server
    HOST_NAME 192.168.0.12
    Alias 0.12
    Address 192.168.0.12
    }
  • Define Service{
    Use Generic-service
    HOST_NAME 192.168.0.12
    Service_description check_ping
    Check_command check_ping!100.0,20%!200.0,50%
    Max_check_attempts 5
    Normal_check_interval 1
    }

    Define Service{
    Use Generic-service
    HOST_NAME 192.168.0.12
    Service_description Check_ssh
    Check_command Check_ssh
    Max_check_attempts 5; When Nagios detects a problem, it has a total of 5 attempts to detect a problem before alerting, if the value is 1, then an immediate alarm is detected.
    Normal_check_interval 1; The time interval for re-detection, in minutes, and 3 minutes by default
    Notification_interval 60; After the service has an exception, the failure has not been resolved and Nagios again notifies the user of the time. Units are minutes. If you think that all events require only one notification, you can set the option here to 0.
    }

    Define Service{
    Use Generic-service
    HOST_NAME 192.168.0.12
    Service_description check_http
    Check_command check_http
    Max_check_attempts 5

    1. Continue adding services
      Service-Side Vim/etc/nagios/objects/commands.cfg
      Added: Define command{
      Command_name Check_nrpe
      Command_line $USER 1$/check_nrpe-h $HOSTADDRESS $-C $ARG 1$
      }
      Continue editing Vim/etc/nagios/conf.d/192.168.0.12.cfg
      Add the following: Define Service{
      Use Generic-service
      HOST_NAME 192.168.0.12
      Service_description Check_load
      Check_command Check_nrpe!check_load
      Max_check_attempts 5
      Define Service{
      Use Generic-service
      HOST_NAME 192.168.0.12
      Service_description check_disk_hda1
      Check_command check_nrpe!check_hda1
      Max_check_attempts 5
      Define Service{
      Use Generic-service
      HOST_NAME 192.168.0.12
      Service_description Check_disk_hda2
      Check_command Check_nrpe!check_hda2
      Max_check_attempts 5
      Description: Check_nrpe!check_load: Here the Check_nrpe is just defined in Commands.cfg, Check_load is a detection script on the remote host
      On the remote host vim/etc/nagios/nrpe.cfg search Check_load, this line is on the server to execute the script, we can manually execute this script
      Change check_hda1:/dev/hda1 changed to/DEV/SDA1
      Add another line command[check_hda2]=/usr/lib/nagios/plugins/check_disk-w 20%-C 10%-p/dev/sda2
    2. Configuring alarms
      VIM/ETC/NAGIOS/OBJECTS/CONTACTS.CFG//Increase: Define contact{
      Contact_Name 123
      Use Generic-contact
      Alias Aming
      email [email protected]
      }

    Define contact{
    Contact_Name 456
    Use generic-contact
    alias AAA
    Email [email protected]
    Define contactgroup{
    Contactgroup_name Common
    Alias Common
    Define service{
    Use Generic-service
    Host_ Name 192.168.0.12
    service_description check_load
    Check_command check_nrpe!check_load
    max_check_attempts 5
    Normal_check_interval 1
    contact_groups common
    notifications_enabled 1; Turn on the alert function. 1 is on, 0 is disabled. In general, this option is defined in the main configuration file (Nagios.cfg), with the same effect.
    Notification_period 24x7; the time period during which reminders are sent. Very important host (service) I defined as 7x24, the general host (service) is defined as working hours. If no problem occurs, no reminder is sent if it is not within the defined time period.
    Reference:

      1. Configure graphical display Pnp4nagios (please do it yourself, not shown in Class)
        (2) Configure the main profile
        (3) Modify Commands.cfg
        (4) Modify the configuration file Templates.cfg
        Vim/etc/nagios/objects/templates.cfg Define host {
        Name HOSTS-PNP
        Register 0
        action_url/pnp4nagios/ index.php/graph?host= $HOSTNAME $&srv= host
        Process_perf_data 1
        }
        Define service {
        Name SRV-PNP
        Register 0
        action_url/pnp4nagios/index.php/graph?host= $HOSTNAME $&srv= $SERVICEDESC $
        (5) Modify the host and service configuration
        Vim/etc/nagios/conf.d/192.168.0.12.cfg
        to replace "define host{
        Use Linux-server"
        with:
        Define host{
        Use Linux-server,hosts-pnp

    Modify the corresponding service, such as
    put
    define service{
    Use Generic-service
    host_name 192.168.0.12
    Service_ Description check_disk_hda1
    Check_command check_nrpe!check_hda1
    max_check_attempts 5
    Normal_check_ Interval 1
    }
    Instead:
    define service{
    Use GENERIC-SERVICE,SRV-PNP
    host_name 192.168.0.12
    Service_ Description check_disk_hda1
    Check_command check_nrpe!check_hda1
    max_check_attempts 5
    Normal_check_ Interval 1
    }

    (6) Restart and start each service:
    Service Nagios Restart
    (7) Access test
    Two methods of Access:
    ip/nagios/
    Nagios official website http://www.nagios.org
    CENTOS6 The default Yum source does not have Nagios-related RPM packages, but we can install a epel extension source:
    Yum Install-y epel-release
    Start Services: Service httpd start; Service Nagios Start
    Browser access: Http://ip/nagios
    Vim/etc/nagios/nrpe.cfg find "allowed_hosts=127.0.0.1" changed to "allowed_hosts=127.0.0.1,192.168.0.11" after the IP for the server IP; Find "dont_blame_nrpe=0" and Change to "dont_blame_nrpe=1"
    Start Client/etc/init.d/nrpe start
    Normal_check_interval 1
    }
    The above services do not depend on the client Nrpe service, we can imagine that we can use ping or telnet on our own computer to detect whether a remote machine is alive, whether to open a port or service. When we want to detect a specific service on the client, we need to use Nrpe, for example, to know the responsibility of the client machine or disk usage.
    Normal_check_interval 1
    }
    Normal_check_interval 1
    }
    Normal_check_interval 1
    }
    Restart the client on Nrpe services: service Nrpe restart
    The server also restarts the Nagios service: service Nagios restart
    }

        members                          123,456    }

    and add Contactgroup to the service that needs to be alerted.
    Notification_options:w,u,c,r; This is the state of the service. W is waning, U is unknown, C is critical, R is recover (resumed), similar to the state of a host: d,u,r D = status is down, U = status is unreachable, R = State reverts to OK, need to join To the definition configuration of the host.
    }
    Call SMS Interface http://www.aminglinux.com/bbs/thread-7380-1-1.html
    Integrated http://www.aminglinux.com/bbs/thread-7917-1-1.html
    (1) Installation
    Yum Install Pnp4nagios RRDtool
    VIM/ETC/NAGIOS/NAGIOS.CFG//Modify the following configuration

    1. process_performance_data=1   2. host_perfdata_command=process-host-perfdata3. service_perfdata_command=process-service-perfdata4. enable_environment_macros=1     

    Vim/etc/nagios/objects/commands.cfg//Comment off original to Process-host-perfdata and Process-service-perfdata, redefine

    1. define command {  2.        command_name    process-service-perfdata  3.        command_line    /usr/bin/perl /usr/libexec/pnp4nagios/process_perfdata.pl  4. }  5.   6. define command {  7.        command_name    process-host-perfdata  8.        command_line    /usr/bin/perl /usr/libexec/pnp4nagios/process_perfdata.pl -d HOSTPERFDATA  9. }      process_perf_data               1

    }
    Service httpd Restart
    Service NPCD Start
    ip/pnp4nagios/

    Part II: Nagios installation Configuration

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.