Server monitoring: Configure Nagios and NRPE

Source: Internet
Author: User
1 Nagios introduces Nagios as an application for system and network monitoring. It can monitor hosts and services under the conditions you set, and provide alarm information when the status gets worse and better. Nagios was initially designed to run on Linux systems, but it can also run on Unix-like systems. Further features of Nagios include: 1. Introduction to Nagios

Nagios is an application for system and network monitoring. It can monitor hosts and services under the conditions you set, and provide alarm information when the status gets worse and better.

Nagios was initially designed to run on Linux systems, but it can also run on Unix-like systems.

Further features of Nagios include:

  1. Monitor network services (SMTP, POP3, HTTP, NNTP, PING, etc );
  2. Monitor host resources (processor load, disk utilization, etc );
  3. The Simple plug-in design allows users to easily expand their service detection methods;
  4. Parallel service check mechanism;
  5. Ability to define the network hierarchy. \ "parent \" host definition is used to express the relationship between network hosts. This relationship can be used to discover and clarify host downtime or inaccessibility;
  6. Send alerts to contacts when service or host problems are generated and resolved (by EMail, SMS, or user-defined method );
  7. It has the ability to define event handles. It can locate more problems when host or service events occur;
  8. Automatic Log rollback;
  9. Supports and monitors the redundancy of hosts;
  10. The optional WEB interface is used to view the current network status, notification and fault history, and log files;
2. Install the 2.1 software package for Nagios

Httpd
Gcc
Glibc-common
Gd-devel

Mysqlmysql-server mysql-devel

GnutLs

2.2 create users and groups

The main task is to create nagios users and their bundle groups so that the running users of nagios are nagios rather than root. Then, set the owner of the directory/usr/local/nagios to ensure system security. Nagios can run as a root user, but this is not recommended. Follow these steps:

1. Add the system account nagios: useraDdNagios

# Groupadd nagios

# Groupadd nagcmd

#UseraddNagios-M-s/sbin/nologin-g nagios

Note: Do not set a password for nagios users

2. Change the directory group:Chown? R nagios. nagios/usr/local/nagios.Note that some unix/linux users and group separators are not "." And may be chown? R nagios: nagios/usr/local/nagios.

 

2.3 install nagios2.3.1 download Nagios and plug-in packages

Download and install:

Http ://CdBytes

 

Wget http://jaist.dl.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.13.tar.gz

2.3.2 install nagios

# Tar? Zxvf nagios-3.2.1.tar.gz

# Cd nagios-3.2.1

#./Configure -- prefix =/usr/local/nagios -- with-command-group = nagcmd --Enable-NanoSleep-- Enable-broker

# Make all

# Make install

# Make install-init

# Make install-commandmode

# Make install-config

 

2.3.3 install the nagios plug-in

 

Nagios-plugins-1.4.15

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

Make

Make install

After the installation is complete, the directory lib will be generated in the/usr/local/nagios directoryExEc

 

3. install apache on the web Server

The Web Service is not required by nagios. However, if nagios does not have the web, it is very troublesome and interesting to view the Monitored object (only by checking the nagios log to determine the status ).

 

3.1 install Apache HTTP

Install Apache 2.2.3

./Configure -- prefix =/usr/local/apache2

-- Enable-moDuLe = most

-- Enable-sharEd= Max

# Make

# Make install

---------------------------------- Start the Apache service ----------------------------------

#/Usr/local/apache2/bin/ApachectlStart

---------------------------------- Close the Apache service ----------------------------------

#/Usr/local/apache2/bin/apachectl stop

-------------------------------- Restart the Apache service ----------------------------------

#/Usr/local/apache2/bin/apachectl restart

 

3.2 InstallationPHP

2. install PHP 5.3.6

#./Configure -- prefix =/usr/local/Php

-- With-apxs2 =/usr/local/apache2/bin/apxs

# Make

# Make install

#CpPhp. ini-production/usr/local/php/lib/php. ini

 

If has error: make clean

 

3.3 configure the httpd. conf file of the Apache service

* Add LoadModule php5_module module/libphp5.so to LoadModule.

* Add index. php at DirectoryIndex

* In AddType appliCatAdd at ion

AddType application/x-httpd-php. php. phtml

AddType applicatoin/x-httpd-php-source.phps

 

Then, add vi/usr/local/apache2/conf/httpd. conf:

 

SetHandler application/x-httpd-php

SetHandler application/x-httpd-php

SetHandler application/x-httpd-php-source

LoadModule php5_module modules/libphp5.so

DirectoryIndex index.html index. php

 

4 Nagios Configuration 4.1 Pre-configuration Processing

The main task is to create nagios users and their bundle groups so that the running users of nagios are nagios rather than root. Then, set the owner of the directory/usr/local/nagios to ensure system security. Nagios can run as a root user, but this is not recommended. Follow these steps:

2. Add a system account nagios: useradd nagios

# Groupadd nagios
# Useradd nagios-M-s/sbin/nologin-g nagios

Note: Do not set a password for nagios users

2. Change the directory group: chown? R nagios. nagios/usr/local/nagios.Note that some unix/linux users and group separators are not "." And may be chown? R nagios: nagios/usr/local/nagios.

Add Apache daemon to nagios User Group

3. sendmail.Check if sendmail is running properly? We need to use sendmail to send fault alarm information, so this package must work properly. Sendmail is divided into two parts: server and client. There are two ways to send alarm Emails:
(1) The machine on which nagios is located sends the mail to the dedicated email server through the sendmail client program, and then the mail server sends the message to the user's mailbox.
(2) The mail client and server use sendmail in the system where nagios is located. The first method is very standard, but it is more troublesome. For example, you need to perform address resolution and modify the configuration of the email server. Another problem is that it depends on other systems, it increases fault points and complexity. The second method is very simple. You only need to start the sendmail service, and it no longer depends on other systems and services. In actual scenarios of my work, both methods are used. A dedicated email server may cause sending latency (because the email server needs to process emails sent and received by many other users ); directly Using sendmail as the server and client is very simple and convenient. Fortunately, sendmail is installed by default in almost all linux/unix distributions. If so much ink is required, simply run the sendmail service.

4. Mobile text message sending tool.My current company is sp. I have my own text message channel. I directly copy the client program sms_send that sent the text message to the directory/usr/local/bin. What if there is no gateway channel for text message delivery? There are many client programs for sending text messages on the network. The most famous one is smsclient. Download it, unpack it, and install it. Do not forget to purchase mobile phone modem and mobile phone card. modem only supports SIM card but not cdma.

After installing the smsclient software and hardware modem, test whether the software is normal. What if there is no modem? There are still some ways: to make your mobile phone number acceptable to emails, you need to go to the Business Hall to activate this function. The text message alarm function is the most useful function. We cannot stare at the monitoring screen all day long or receive emails all day long, but our mobile phone can be online 24 hours a day, as long as the Monitored object fails, you can receive a fault alert text message immediately.

 

 

4.2 Apache configuration

 

 

The configuration is completed in two steps. The first step is to modify the configuration file httpd. conf of apache. The file path here is/usr/local/apache/conf/httpd. conf. Change apache runtime user [1] and runtime group to nagios, and append the following line to the end of the file httpd. conf:

 

 

#setting for nagios
ScriptAlias /nagios/cgi-bin /usr/local/nagios/sbin
// Cgi File directory
    AuthType Basic
    Options ExecCGI
    AllowOverride None
    Order allow,deny
    Allow from all
    AuthName \"Nagios Access\"
AuthUserFile/usr/local/nagios/etc/htPasswd// Verify the file path
    Require valid-user
 
Alias /nagios /usr/local/nagios/share

  
      
  
// Nagios page file directory
    AuthType Basic
    Options Indexes
    AllowOverride None
    Order allow,deny
    Allow from all
    AuthName \"nagios Access\"
AuthUserFile/usr/local/nagios/etc/htpasswd // verify the file path
    Require valid-user

 

The preceding text block is used to verify the user of the nagios directory. Only authorized users can access the page files of nagios.

 

Step 2: generate the user authentication file:Command

/Usr/local/apache/bin/htpasswd? C/usr/local/nagios/etc/htpasswd nagios

The valid web access user nagios is generated. for interactive command execution, you need to enter the password twice, then write a line in the file/usr/local/nagios/etc/htpasswd-the first field is the generated user name, and the second is the encrypted password, if you want to add more users, you do not need to select "-c" when executing the command htpasswd. Otherwise, all generated rows will be overwritten.

Related Article

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.