Nagios Monitoring Platform Setup

Source: Internet
Author: User

Nagios is an open source, free network monitoring tool that effectively monitors Windows, Linux and Unix host status, network settings such as switch routers , printers, and more. Send mail or SMS alarm when the system or service status is abnormal the first time to notify the site operators, after the status of the resumption of normal mail or SMS notification.

What is the difference between nagios and cacti? In short, cacti mainly monitor traffic, Server Status page display; Nagios main monitoring services, mail and SMS alarm lights, of course, there is a simple flow monitoring interface, the combination of the use of better results. (with Nagios working simple logic diagram)

The Nagios monitoring client needs to be implemented with plug-ins and Nrpe software, Nrpe as an intermediary agent, receiving requests from the Nagios server side, and the related monitoring information specified on the remote host at the other end.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6F/DA/wKiom1WrGVCjrmUkAAIMFOk4r_0339.jpg "title=" 1.png " alt= "Wkiom1wrgvcjrmukaaimfok4r_0339.jpg"/>

The following is simply the Nagios platform Setup

1. Preparatory work

Nagios-3.2.1.tar.gz

Nagios-plugins-1.4.14.tar.gz

Nrpe-2.14.tar.gz

2. Service-Side environment construction

Useradd-s/sbin/nologin Nagios

Mkdir/usr/local/nagios

Chown-r Nagios.nagios/usr/local/nagios

Tar zxvf nagios-3.2.1.tar.gz

CD nagios-3.2.1

./configure--prefix=/usr/local/nagios--with-command-group=nagios

Make all

make install;

Make install-init;

Make install-config;

Make Install-commandmode;

Make install-webconf;

Note:

Make install//To install the main program, CGI and HTML files

Make Install-init//install startup script in/ETC/RC.D/INIT.D

Make Install-config//To install the sample configuration file, the installation path is/USR/LOCAL/NAGIOS/ETC

Make Install-commandmode//To configure directory permissions

Make install-webconf//configure Nagios to integrate with Apache



Installing Nagios-plugins

Tar zxvf nagios-plugins-1.4.14.tar.gz

CD nagios-plugins-1.4.14

./configure--prefix=/usr/local/nagios--with-nagios-user=nagios--with-nagios-group=nagios

Make && make install

Nagios Access Control Settings

Htpasswd-c/usr/local/nagios/etc/htpasswd.users Nagiosadmin

Enter the password two times, the login page will use this password.

Nagios Test Access

Restart Nagios

/etc/init.d/nagios Restart;

/ETC/INIT.D/HTTPD Restart;

http://IP/nagios/


3. To add a client-side monitoring step:

CP Localhost.cfg 192.168.2.99.cfg

Replace the Locahost, 127.0.0.1, check_local in the default configuration file with the latest

because the Nagios plugin and Nrpe are not installed on the client,

Need to delete the configuration file in disk, swap, process, user, CPU and other Monitoring configuration section (here according to individual needs to modify)


Cd/usr/local/nagios/etc

VI nagios.cfg

Add cfg_file=/usr/local/nagios/etc/objects/192.168.2.99.cfg after nagios.cfg 36 rows

Last execution:/usr/local/nagios/bin/nagios-v/usr/local/nagios/etc/nagios.cfg no error can be.


4. Nagios Client Plug-in installation

Nagios Client installation requires the installation of two software, nagios-plugins-1.4.14.tar.gz and nrpe-2.14.tar.gz

The installation method is as follows:

Useradd Nagios;

Tar-xzf nagios-plugins-1.4.14.tar.gz

CD nagios-plugins-1.4.14

./configure--prefix=/usr/local/nagios

Make &&make Install

Tar-xzf nrpe-2.14.tar.gz

CD nrpe-2.14

./configure--enable-ssl--with-ssl-lib

Make all && make Install-plugin && make Install-daemon && make Install-daemon-config

Chown-r nagios:nagios/usr/local/nagios/


5. Nrpe Client Configuration

Modify Vi/usr/local/nagios/etc/nrpe.cfg to modify the contents of the default configuration section as follows,

allowed_hosts=192.168.2.91 (This is the IP of the server monitor)

Command[check_users]=/usr/local/nagios/libexec/check_users-w 5-c 10

Command[check_load]=/usr/local/nagios/libexec/check_load-w 15,10,5-c 30,25,20

Command[check_disk]=/usr/local/nagios/libexec/check_disk-w 20-c 10-p/dev/sda2

Command[check_procs]=/usr/local/nagios/libexec/check_procs-w 50-C 100

Command[check_swap]=/usr/local/nagios/libexec/check_swap-w 20-c 10

To start the Nrpe client command:

/usr/local/nagios/bin/nrpe-c/usr/local/nagios/etc/nrpe.cfg-d

Nagios Server Nrpe Configuration

Nagios server side also need to install Nrpe, and need to define NRPE monitoring command, write Command.cfg end can:

Define Command{

Command_name Check_nrpe

Command_line $USER 1$/check_nrpe-h $HOSTADDRESS $-C $ARG 1$

}


In the server-side IP-corresponding configuration file, add the items that need to be monitored:

Define Service{

Use Local-service

HOST_NAME 192.168.2.99

Service_description Users_monitor

Check_command check_nrpe!check_users

Notifications_enabled 1

}

The other way, add the same method. As long as the monitoring commands that are added inside the client nrpe.cfg, they can be referenced on the server.


nagios monitoring side HTTP keywords


In the real online environment, if you want to monitor the HTTP, Web, tomcat a URL keyword, monitoring site keywords have been tampered with, if to achieve it?

Here you can use the default monitoring command check_http command + related parameters to implement, as follows:

In command.cfg add the following keyword Monitoring command: Check_http_word, parameter resolution:-i specifies IP or hostname,-u specifies url,-p specified port,-s Specifies the keyword.

Vim Commands.cfg (This is a modification on the monitoring server)

definecommand{

Command_name Check_http_word

Command_line $USER 1$/check_http-i $HOSTADDRESS $-u$arg1$-P $ARG 2$-S $ARG 3$

}

You can then refer to the configuration file of the server-side monitoring host, and refer to the following methods:

Define Service{

Use Local-service

HOST_NAME 192.168.2.99

Service_description Discuz

Check_command check_http_word!/forum.php!80! Discuz

Notifications_enabled 1

}

It is usually better to test the configuration file at the outside command, for example:

/usr/local/nagios/libexec/check_http-i 192.168.2.99-u/index.php-p 80-s "Discuz"

nagios monitors mysql master and slave alarms


Monitoring MySQL can use the Nagios MySQL plugin, first defining the following configuration in Command.cfg:

Define Command{

Command_name Check_mysql_slave

Command_line $USER 1$/check_mysql-h $HOSTADDRESS $-s-uroot-p123456

}

Then define the monitoring project in the host configuration file:

Define Service{

Use Local-service

Host_name 192.168. 2.99

Service_description Mysql_slave_monitor

Check_command Check_mysql_slave

}

Restart Nagios service to view monitoring status after configuration is complete


Nagios Mail and SMS alerts

to install the Mail service:

[email protected] objects]# Yum install sendmail* mailx-y

Loaded Plugins:fastestmirror

Description Fastestmirror cannot be used to disable this plugin

    1. 1. Modify the plugin's configuration file

    2. # vi/etc/yum/pluginconf.d/fastestmirror.conf

    3. Enabled = 1//changed from 1 to 0, disable the plugin

    4. 2. Modify the Yum configuration file

    5. # vi/etc/yum.conf

    6. plugins=1//to 0, do not use plugins

Re-install can

Restart Service

Service SendMail Restart;

Chkconfig SendMail on

Mail test:

echo "Test" |mail-s "test" [email protected]

After testing OK

To modify a configuration file:

Vi/usr/local/nagios/etc/objects/contacts.cfg changes to a mailbox that needs to be sent

Finally restart the Nagios service to test the shutdown of a service and receive an alert message from Nagios after a while.

This article is from the "Linux---basics" blog, so be sure to keep this source http://perin.blog.51cto.com/10410663/1676095

Nagios Monitoring Platform Setup

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.