Nagios + nrpe Configuration Guide

Source: Internet
Author: User

1. Preface
For System Workers, monitoring various running statuses of servers is one of the tasks. for a small number of servers, manual observation is not a problem, but it is too troublesome for Server clusters, as a result, many people have adopted some automation tools, such as scripts, but today we are introducing a very famous open-source project Nagios.
Nagios is just a monitoring platform. All monitoring tasks are completed by plug-ins, with a high degree of customization and good configuration. nrpe is a popular plug-in, monitors the running status of remote servers, including disk space, CPU load rate, and other customizable content.

2. Nagios Configuration
This is a machine that installs the Nagios platform and receives information from other monitored servers.
Environment: centos System
Follow this guide to install the tool. The installation directory is as follows:
Install Nagios and plug-ins on/usr/local/Nagios
It will be configured to monitor several main services of the local system (CPU load, disk utilization, etc)
Nagios Web Interface: http: // localhost/Nagios/
 
2.1 preparations
Check that your server is installed:
Apache
GCC compiler
GD library and Development Library
Run the following command to install
Yum install httpd
Yum install gcc
Yum install glibc-common
Yum install GD Gd-devel

2.2 switch Root User
Su-l
Create a Nagios account and give a logon Password
/Usr/sbin/useradd Nagios
Passwd Nagios

Create a user group named nagcmd for web interfaces (mainly about Web permissions ). Add both Nagios users and Apache users to this group.
/Usr/sbin/groupadd nagcmd
/Usr/sbin/usermod-G nagcmd Nagios
/Usr/sbin/usermod-G nagcmd Apache

2.3 download the Nagios installation package
Mkdir ~ /Downloads
Cd ~ /Downloads

Download the latest version from http://www.nagios.org/download /.

2.4 compilation and Installation
Cd ~ /Downloads
Tar xzf Nagios-** .tar.gz
CD Nagios -*

./Configure -- With-command-group = nagcmd
Make all
Make install
Make install-init
Make install-config
Make install-commandmode

2.5 custom configuration
Edit the/usr/local/Nagios/etc/objects/contacts. cfg configuration file and modify the email address. This address is the address where the Nagios system sends an email alert.
2.6 configure web interfaces
Install the Nagios web configuration file to the conf. d directory of Apache:
Make install-webconf
Create a nagiosadmin user for logging on to Nagios through the Web interface. Write down the password you entered:
Htpasswd-C/usr/local/Nagios/etc/htpasswd. Users nagiosadmin
Restart the apache service to make the settings take effect.
Service httpd restart
2.7 compile and install the Nagios plugin
Cd ~ /Downloads
Tar xzf Nagios-plugins-* .tar.gz
CD Nagios-plugins -*
Compile and install the plug-in
./Configure -- With-Nagios-user = Nagios -- With-Nagios-group = Nagios
Make
Make install
2.8 start Nagios
Chkconfig -- add Nagios
Chkconfig Nagios on
Verify the Nagios sample configuration file
/Usr/local/Nagios/bin/Nagios-V/usr/local/Nagios/etc/Nagios. cfg
If no error is reported, you can start the Nagios service.
Service Nagios start

2.9 change seliux settings
Red Hat systems have SELinux to enhance security, but in some cases, this is a very troublesome thing. here you need to set up permissions. If it is too troublesome, you can directly disable SELinux.

If SELinux is in forced security mode, you must first
Get enforce
Make SELinux in allowed Mode
Set enforce 0

However, we recommend that you modify the file force target mode of SELinux:
Chcon-r-t httpd_sys_content_t/usr/local/Nagios/sbin/
Chcon-r-t httpd_sys_content_t/usr/local/Nagios/share/

2.10 login Web Interface
Now you can log on to http: // localhost/Nagios/to view the service information of the Local Machine. Enter the username and password you just entered.

At this point, the Nagios configuration is basically complete.

3.0 configure the nrpe plug-in
Now that the invigilator has been configured, the remote server requires a plug-in to connect to the platform. Fortunately, open-source products are comprehensive and there is a ready-made nrpe plug-in that can monitor server disk space problems in real time, CPU load problems, and you can customize monitoring items
3.1 create an account
Su-l
/Usr/sbin/useradd Nagios
Passwd Nagios
 
3.2 download plug-ins
Download the Nagios-plugins and nrpe plug-ins. Be sure to download the new version.
Tar xzf nagios-plugins-1.4.6.tar.gz
CD nagios-plugins-1.4.6

./Configure
Make
Make install

Chown Nagios. Nagios/usr/local/Nagios
Chown-r Nagios. Nagios/usr/local/Nagios/libexec
3.3 install xinetd
Because nrpe is loaded through xinetd process, xinetd needs to be installed. xinetd is not installed by default in Red Hat system.
Yum install xinetd

3.4
Install nrpe
Tar xzf nrpe-2.8.tar.gz
CD nrpe-2.8

./Configure
Make all
Make install-plugin
Make install-daemon
Make install-Daemon-config

Make install-xinetd
 
3.5 edit the nrpe File
Edit the/etc/xinetd. d/nrpe file and add the IP addresses of your monitoring platform machines. Separate them with spaces in the following line.
Only_from = 127.0.0.1 <IP address of your monitored machine>
Add the nrpe port to the service:
Edit the/etc/service file. Remember to copy a service file for backup.
Add this line:
Nrpe
5666/tcp # nrpe
3.6 start the xinetd service
Now you can start xinetd to enable the nrpe process to start normally.

3.7 start the verification service
We can use
Netstat-at | grep nrpe
To verify whether the process is started. If the process is started normally, the following information is returned:
TCP 0 0 *: nrpe *: * listen
Verify that the nrpe process works properly. Run the following command to verify the process:
/Usr/local/Nagios/libexec/check_nrpe-H localhost
Returned results:
Nrpe v2.8

3.8 CREATE Command
After completing the above work, you need to configure the check_nrpe command. This template is consistent, just copy it:
Define command {
Command_name
Check_nrpe
Command_line
$ User1 $/check_nrpe-h $ hostaddress $-C $ arg1 $
}

This purpose is to define the commands for monitoring hosts...

Not complete...

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.