Complete Nagios3 configuration document (chapter 1)

Source: Internet
Author: User
Chapter 1: install the nagios1.1 preparation package in a simple and fast manner. make sure that you have the root permission on the machine before installation. Make sure that the following software package has been installed on your linux system. ApacheGCC compiler GD library and development library Openssl-devel can be installed using the yum command...

 

Chapter 1: Simple and quick nagios installation

1.1 prepare the software package

Make sure that you have the root permission on the machine before installation. Make sure that the following software package has been installed on your linux system.

Apache

GCC compiler

GD library and development Library

Openssl-devel

You can use the yum command to install these software packages. type the command:

Yum-y install httpd gcc glibc? Common gd? Devel

 

 

1.2 Procedure

1.2.1 Create a nagios account

 

/Usr/sbin/useradd nagios & passwd nagios

 

Create a user group namedNagcmdUsed to execute external commands from Web interfaces. 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

 

1.2.2Download nagios and plug-in packages

Download software packages for Nagios and Nagios plug-ins (visit the http://www.nagios.org/download/ site for the latest version)

Cd/usr/local/src

Wget http://nchc.dl.sourceforge.net/sourceforge/nagios/nagios? 3.0.6.tar.gz

Wget http://nchc.dl.sourceforge.net/sourceforge/nagiosplug/nagios? Plugins? 1.4.13.tar.gz

 

 

1.2.3 Compile and install nagios

 

Cd/usr/local/src

Tar zxvf nagios? 3.0.6.tar.gz

Cd nagios? 3.0.6

./Configure ?? With? Command? Group = nagcmd? ? Prefix =/usr/local/nagios

Make all

Make install

Make install? Init

Make install? Config

Make install? Commandmode

 

 

Verify that the program is correctly installed. Switch the directory to the installation path (/usr/local/nagios) to check whether the five directories including etc, bin, sbin, share, and var exist, if yes, it indicates that the program has been correctly installed to the system. The following table provides a brief description of the five Directory functions:

Bin

The directory where the Nagios executable program is located. The nagios file is the main program.

Etc

Location of the Nagios configuration file. after the initial installation, there are only a few *. cfg-sample files.

3 and 2 different object configuration files are all under the etc/objects Directory

Sbin

The directory where the Nagios Cgi file is located, that is, the directory where the file needed to execute external commands is located

Share

Nagios webpage file directory

Var

Directory where Nagios log files, spids, and other files are located

Var/archives

Empty directory for the archived logs

Var/rw

Empty directory for the external command file

 

 

1.2.4 Compile and install the nagios plug-in nagios? Plugins

Cd/usr/local/src

Tar zxvf nagios? Plugins? 1.4.13.tar.gz

Cd nagios? Plugins? 1.4.13

./Configure ?? With? Nagios? User = nagios ?? With? Nagios? Group = nagios

?? Perfix =/usr/local/nagios

Make & make install

 

 

 

 

 

 

Verification:

Ls/usr/local/nagios/libexec

The installed plug-in file is displayed, that is, all plug-ins are installed in the libexec directory.

1.2.5 Configure WEB interfaces

Method 1: make install directly when installing nagios? Webconf

Create a nagiosadmin user for logging on to Nagios WEB interface. Write down the logon password you set and you will use it later.

Htpasswd? C/usr/local/nagios/etc/htpasswd. users nagiosadmin

Restart the Apache service to make the settings take effect.

Service httpd restart

 

Method 2: Add the following content at the end of httpd. conf:

# Setting for nagios 20090325

# Setting by bbs.linuxtone.org

ScriptAlias/nagios/cgi-bin/usr/local/nagios/sbin

Options ExecCGI

AllowOverride None

Order allow, deny

Allow from all

AuthName "Nagios Access"

AuthType Basic

AuthUserFile/usr/local/nagios/etc/htpasswd

// Access the authentication file in this directory

Require valid-user

 

Alias/nagios/usr/local/nagios/share

Options None

AllowOverride None

Order allow, deny

Allow from all

AuthName "Nagios Access"

AuthType Basic

AuthUserFile/usr/local/nagios/etc/htpasswd

// Access the authentication file in this directory

Require valid-user

 

 

/Usr/local/apache2/bin/htpasswd? C/usr/local/nagios/etc/htpasswd test

New password: (input 12345)

Re? Type new password: (enter the password again)

Adding password for user test

 

View authentication file content

Less/usr/local/nagios/etc/htpasswd

Test: the first half of OmWGEsBnoGpIc is the user name test, followed by the encrypted password.

In this example, the user name test is added. you need to change the cgi. cfg configuration file to allow the user test

 

Authorized_for_system_information = test

Authorized_for_configuration_information = test

Authorized_for_system_commands = test

Authorized_for_all_services = test

Authorized_for_all_hosts = nagiosadmin, test

Authorized_for_all_service_commands = test

Authorized_for_all_host_commands = test

If there are multiple users, use a comma to separate them.

 

 

 

1.2.6 Start nagios

 

Add Nagios to the service list to enable it automatically when the system starts.

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

 

1.2.7 Change SELinux settings

 

Fedora and SELinux (secure and enhanced Linux) are released and installed in Force mode by default. This will cause an "internal service error" message when you try to join the CGI of Nagios.

If SELinux is in forced security mode

Getenforce

Make SELinux in allowed mode

Setenforce 0

To change it permanently, you need to change the settings in/etc/selinux/config and restart the system.

If you do not disable SELinux or change SELinux permanently, you can enable the CGI module to specify the forced target mode Under SELinux:

Chcon? R? T httpd_sys_content_t/usr/local/nagios/sbin/

Chcon? R? T httpd_sys_content_t/usr/local/nagios/share/

 

1.2.8 Test

Log on to http: // localhost/nagios/and enter the user name and password to log on to the console.

 

1.2.9 Use NRPE to monitor"Local information"

1. on the monitored host

Add users

Useradd nagios

Set password

Passwd nagios

 

2. install the nagios plugin

Tar? Zxvf nagios? Plugins? * ** .Tar.gz

Cd nagios? Plugins? ***

./Configure

Make

Make install

Chown nagios. nagios/usr/local/nagios

Chown? R nagios. nagios/usr/local/nagios/libexec

 

 

3. install nrpe ?)

Tar? Zxvf nrpe? * ** .Tar.gz

Cd nrpe? 2.8.1

./Configure

Make all

Make install? Plugin

Make install? Daemon

Make install? Daemon? Config

/Usr/local/nagios/libexec/check_nrpe? H localhost

 

Returns the current NRPE version.

#/Usr/local/nagios/libexec/check_nrpe? H localhost

NRPE v2.8.1

 

Start NRPE on the monitoring and monitored machine:

/Usr/local/nagios/bin/nrpe? C/usr/local/nagios/etc/nrpe. cfg? D

 

Connect to the remote NRPE:

/Usr/local/nagios/libexec/check_nrpe? H

 

 

That is, it is normal to connect nrpe daemon with check_nrpe locally.

Note: In order to continue working smoothly, you must enable the local firewall 5666 to allow access by external invigilators.

/Usr/local/nagios/libexec/check_nrpe-h

Can we see that the usage is check_nrpe-H monitored host? C. The monitoring command to be executed

Note :? The monitoring command after c must be defined in the nrpe. cfg file. that is, NRPE daemon only runs the command defined in nrpe. cfg.

 

Open remote login under nrpe. cfg:

Vim/usr/local/nagios/nrpe. cfg

Allowed_hosts = 127.0.0.1, 10.1.16.111

 Note that the two IP addresses are separated by commas (,).

 

 

 

This article is from the "My home location" blog

 

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.