Linux under Installation configuration Nagios monitoring

Source: Internet
Author: User
Tags disk usage

Nagios Installation configuration:

Nagios official website http://www.nagios.org

Environment Construction:

centos6.6 192.168.11.30 do the service side

centos6.6 192.168.11.100 do the client


1. Nagios Installation-server (192.168.11.30)

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

Installing Nagios-related packages

Yum install-y httpd nagios nagios-plugins nagios-plugins-all Nrpe Nagios-plugins-nrpe

Set the user and password to log in to the Nagios background:

Htpasswd-c/etc/nagios/passwd Nagiosadmin

Nagios-v/etc/nagios/nagios.cfg Detecting configuration file for errors

Start the service:

Service httpd StartService Nagios start

Browser access: http://192.168.11.30/nagios/

Popup authentication dialog, need to enter nagiosadmin and password, login Nagios interface;

The left hosts lists the server or monitor host list;

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= "http ://s3.51cto.com/wyfs02/m01/6e/88/wkiol1v_jmuwjo2jaakpnhr0ehe721.jpg "title=" nagios1.jpg "alt=" wKioL1V_ Jmuwjo2jaakpnhr0ehe721.jpg "/>

Services lists 8 service items monitored (System load, user, HTTP, ping, disk partition, SSH, swap partition, system process)

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= "http ://s3.51cto.com/wyfs02/m02/6e/8c/wkiom1v_jnahb0rlaalq0ms9gcg887.jpg "title=" nagios2.jpg "alt=" wKiom1V_ Jnahb0rlaalq0ms9gcg887.jpg "/>


2. Nagios Installation-Client (192.168.11.100)

On the client machine

Yum install-y epel-releaseyum install-y nagios-plugins nagios-plugins-all Nrpe Nagios-plugins-nrpe

To edit a configuration file:

Vim/etc/nagios/nrpe.cfg

Locate "allowed_hosts=127.0.0.1" to "allowed_hosts=127.0.0.1,192.168.11.30" after IP for server IP

Find "dont_blame_nrpe=0" and Change to "dont_blame_nrpe=1"

Start the client

/etc/init.d/nrpe start

3. Monitoring Center Server (192.168.11.30) add monitored host (192.168.11.100)

The following actions are performed by the server:

cd/etc/nagios/conf.d/

Vim 192.168.11.100.cfg//join:

define host{        use                      linux-server                      host_name          192.168.11.100         alias                    11.100        address                  192.168.11.100         }define service{         use                      generic-service        host_name                192.168.11.100         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.11.100         service_description     check_ssh         check_command           check_ssh         max_check_attempts      5#     ; when Nagios detects a problem, a total of 5 attempts to detect a problem will alarm, if the value is 1, then detect the problem immediately alarm          normal_check_interval 1#   ; time interval, unit is minutes, default is 3 minutes          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.11.100         service_description     check_http         check_command            check_http        max_check_attempts       5        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.


4. Continue adding services

Service side: Vim/etc/nagios/objects/commands.cfg

Increase:

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.11.100.cfg

Add the following content:

define service{        use      generic-service        host_name        192.168.11.100        service_description      check_load        check_command            check_nrpe!check_load         MAX_CHECK_ATTEMPTS 5        NORMAL_CHECK_INTERVAL 1} define service{        use      generic-service        host_name        192.168.11.100        service_description      check_disk_hda1    &Nbsp;   check_command           check_ nrpe!check_hda1        max_check_attempts 5         normal_check_interval 1}define service{         use     generic-service         host_name       192.168.11.100         service_description     check_disk_hda2         check_command           check_nrpe! check_hda2        max_check_attempts 5         NORMAL_CHECK_INTERVAL 1}

Description: Check_nrpe!check_load: Here the Check_nrpe is in commands.cfg just defined, Check_load is a remote host on a detection script;


In the monitoring client machine 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


192.168.11.100 monitoring information will appear in the Web interface after a reboot:

Service is the name of the script definition, disk (87% inode=99%) represents the remaining 99% of the disk's remaining space 87%,inode;

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= "http ://s3.51cto.com/wyfs02/m01/6e/8c/wkiom1v_jyfslvfkaaisltjtply533.jpg "title=" nagios3.jpg "alt=" wKiom1V_ Jyfslvfkaaisltjtply533.jpg "/>


5. Configuring Alarms

VIM/ETC/NAGIOS/OBJECTS/CONTACTS.CFG//Increase:

define contact{        contact_name                123         use                              generic-contact         alias                            aaa         email               [email protected]        }define  contact{        contact_name                456        use                               generic-contact        alias                              bbb        email               [email protected]         }define contactgroup{         contactgroup_name           common         alias                                    common         members                           123,456         }

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

Vi/etc/nagios/conf.d/192.168.11.100.cfg Add the following content:

define service{        use      generic-service,srv-pnp        host_name        192.168.11.100        service_description      check_load        check_command            check_nrpe!check_load         max_check_attempts 5        normal_check_interval  1        contact_groups         common        notifications_enabled  1#     ; whether to 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.         notification_optionsc#   ; This is the status of the service. W is waning, u for unknown, c Critical, r for recover (restored), can write multiple states, separated by commas, similar to a   host corresponding state: D,u ,r   d =  status for down, u =  status is unreachable , r =  status restored to OK , it needs to be added to the host's definition configuration. }


To configure an alert message:

To receive mail, you need to install the SendMail package yum install-y sendmail;

Start SendMail service after installation;/etc/init.d/sendmail start

and close Postfix #/etc/init.d/postfix stop

NETSTAT-NLP to see if the SendMail service is being monitored

Alarm email address can not be written QQ mailbox, because it will intercept the mail sent by SendMail, display 550 error, you can fill out 163 of the mailbox;


/var/log/maillog View Mail Logs


and keep hostname consistent; You can customize a domain name;

/etc/sysconfig/networkhostname=localhost.localdomain
# cat/etc/hosts127.0.0.1 localhost localhost.localdomain::1 localhost localhost.localdomain192.168.11.30 rfyy.n ET rfyy127.0.0.1 rfyy.net rfyy


Login 163 Email--Settings--anti-spam \ Black and white list--whitelist add [email protected] suffix domain name defined by yourself;


Restart the machine, start various services, found that hostname into rfyy.net, view log sent mail name also became custom, 163 also received alarm mail;

[Email protected] ~]# hostnamerfyy.net
June 17:16:43 Rfyy sendmail[1225]: T5g9gdad001223:to=<[email protected]>, Ctladdr=<[email protected]> ( 497/498), delay=00:00:03, xdelay=00:00:03, MAILER=ESMTP, pri=120678, relay=163mx01.mxmail.netease.com. [220.181.14.136], dsn=2.0.0, stat=sent (Mail OK queued as MX12,PSCOWEBZ4UJBEX9VODMMBW--. 5481s3 1434417474)

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/6E/8C/wKiom1V_joHQIfNLAAEgNJ6pD9Y495.jpg "title=" Youjian.jpg "alt=" Wkiom1v_johqifnlaaegnj6pd9y495.jpg "/>



This article is from the "Model Student's Learning blog" blog, please be sure to keep this source http://8802265.blog.51cto.com/8792265/1662250

Linux under Installation configuration Nagios monitoring

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.