Nagios installation Configuration Alarm monitoring and construction

Source: Internet
Author: User

1. About Nagios
is an open source software that can monitor network device network traffic, linux/windows host status, and even monitor the printer
It can run on Linux or on Windows
Browser-based web interface makes it easy for operations personnel to view the status of monitoring items
Support Web interface configuration, management operations
Support SMS, email notification
Customizable scripting enables custom monitoring
Nagios official website http://www.nagios.org


2. Nagios Installation-server (192.168.0.11)
CENTOS6 The default Yum source does not have Nagios-related RPM packages, but we can install a epel extension source:
RPM-IVH http://www.aminglinux.com/bbs/data/attachment/forum/month_1211/epel-release-6-7.noarch.rpm
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
Start Services: Service httpd start; Service Nagios Start
Browser access: Http://ip/nagios

3. Nagios Installation-Client (192.168.0.12)
RPM-IVH http://www.aminglinux.com/bbs/data/attachment/forum/month_1211/epel-release-6-7.noarch.rpm on the client machine
Yum install-y nagios-plugins nagios-plugins-all Nrpe Nagios-plugins-nrpe
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

4. 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:

  1. Define Host{
  2. Use Linux-server; Name of the host template to use
  3. ; This host definition would inherit all variables that is defined
  4. ; In (or inherited by) the Linux-server host template definition.
  5. HOST_NAME 192.168.0.12
  6. Alias 0.12
  7. Address 192.168.0.12
  8. }
  9. Define Service{
  10. Use Generic-service
  11. HOST_NAME 192.168.0.12
  12. Service_description check_ping
  13. Check_command check_ping!100.0,20%!200.0,50%
  14. Max_check_attempts 5
  15. Normal_check_interval 1
  16. }
  17. Define Service{
  18. Use Generic-service
  19. HOST_NAME 192.168.0.12
  20. Service_description Check_ssh
  21. Check_command Check_ssh
  22. Max_check_attempts 5
  23. Normal_check_interval 1
  24. }
  25. Define Service{
  26. Use Generic-service
  27. HOST_NAME 192.168.0.12
  28. Service_description check_http
  29. Check_command check_http
  30. Max_check_attempts 5
  31. Normal_check_interval 1
  32. }
Copy Code



5. Simple description of the configuration file
A total of three service:ssh, Ping, and http are monitored in our defined profiles by using the local Nagios tool to connect to the remote machine, meaning that even if the client does not have Nagios-plugins installed and Nrpe can be monitored. Other services such as load, disk usage, etc. require the server to connect to the remote host via Nrpe, so the remote host needs to install the Nrpe service and the corresponding execution script (nagios-plugins)
Max_check_attempts 5 #当nagios检测到问题时, a total of 5 attempts to detect a problem before the alarm, if the value is 1, then detected a problem immediately alarm
Normal_check_interval # Re-detection interval, unit is minutes, default is 3 minutes
Notification_interval #在服务出现异常后, the failure has not been resolved, Nagios again to notify 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.

6. 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 content:

  1. Define Service{
  2. Use Generic-service
  3. HOST_NAME 192.168.0.12
  4. Service_description Check_load
  5. Check_command Check_nrpe!check_load
  6. Max_check_attempts 5
  7. Normal_check_interval 1
  8. }
  9. Define Service{
  10. Use Generic-service
  11. HOST_NAME 192.168.0.12
  12. Service_description check_disk_hda1
  13. Check_command check_nrpe!check_hda1
  14. Max_check_attempts 5
  15. Normal_check_interval 1
  16. }
  17. Define Service{
  18. Use Generic-service
  19. HOST_NAME 192.168.0.12
  20. Service_description Check_disk_hda2
  21. Check_command Check_nrpe!check_hda2
  22. Max_check_attempts 5
  23. Normal_check_interval 1
  24. }
Copy Code



Check_nrpe!check_load: Here Check_nrpe is commands.cfg just defined, 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
Restart the client on Nrpe services: service Nrpe restart
The server also restarts the Nagios service: service Nagios restart

7. Configure the graphical display Pnp4nagios
(1) Installation
Yum Install Pnp4nagios RRDtool

(2) Configuring the master configuration file
VIM/ETC/NAGIOS/NAGIOS.CFG//Modify the following configuration

    1. Process_performance_data=1
    2. Host_perfdata_command=process-host-perfdata
    3. Service_perfdata_command=process-service-perfdata
    4. Enable_environment_macros=1
Copy Code



(3) Modify Commands.cfg
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. Define Command {
    6. Command_name Process-host-perfdata
    7. Command_line/usr/bin/perl/usr/libexec/pnp4nagios/process_perfdata.pl-d Hostperfdata
    8. }
Copy Code



(4) Modify the configuration file Templates.cfg
Vim/etc/nagios/objects/templates.cfgDefine 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 $
Process_perf_data 1
}  


(5) Modify host and service configuration
Vim/etc/nagios/conf.d/192.168.0.12.cfg
Put "define host{
Use Linux-server "
Switch
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
}
Switch
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
Service httpd Restart
Service NPCD Start

(7) Access test
Two methods of Access:
ip/nagios/
ip/pnp4nagios/


8. Configure Email Alerts
VIM/ETC/NAGIOS/OBJECTS/CONTACTS.CFG//Increase:

  1. Define Contact{
  2. Contact_Name 123
  3. Use Generic-contact
  4. Alias Aming
  5. email [email protected]
  6. }
  7. Define Contact{
  8. Contact_Name 456
  9. Use Generic-contact
  10. Alias AAA
  11. email [email protected]
  12. }
  13. Define Contactgroup{
  14. Contactgroup_name Common
  15. Alias Common
  16. Members 123,456
  17. }
Copy Code



and add Contactgroup to the service that needs to be alerted.

    1. Define Service{
    2. Use Generic-service
    3. HOST_NAME 192.168.0.12
    4. Service_description Check_load
    5. Check_command Check_nrpe!check_load
    6. Max_check_attempts 5
    7. Normal_check_interval 1
    8. Contact_groups Common
    9. }
Copy Code



9. Description of several important parameters
Notifications_enabled: Whether to turn on the reminder 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_interval: The minimum interval for sending reminders repeatedly, as described earlier. The default time interval is 60 minutes. If this value is set to 0, duplicate reminders will not be sent.
Notification_period: 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.
Notification_options: This parameter defines what is included in the sending reminder: D = status is down, U = status is unreachable, R = State reverts to OK, F = flapping. , n= does not send reminders.

Nagios installation Configuration Alarm monitoring and construction

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.