Install Nagios on CentOS7

Source: Internet
Author: User
Tags install perl

Install Nagios on CentOS7

1. About nagios

Nagios is an open-source free network monitoring tool that can effectively monitor the status of Windows, Linux and Unix hosts, network settings such as vswitches and routers, and printers. If the system or service status is abnormal, an email or text message alert will be sent immediately to the website O & M personnel. After the status is restored, a normal email or text message notification will be sent.

Nagios can monitor the following functions:

1. Monitor network services (SMTP, POP3, HTTP, NNTP, PING, etc );

2. Monitor host resources (processor load, disk utilization, etc );

3. A simple plug-in design allows you to easily expand your service detection methods;

4. Parallel service check mechanism;

5. Have the ability to define the network hierarchy. Use "parent" host definition to express the relationship between network hosts,

This relationship can be used to identify and clarify host downtime or inaccessibility;

6. When a service or host problem occurs or is resolved, the alarm is sent to the contact (via EMail, SMS, or user-defined method );

7. You can define the event handle function to locate more problems when a host or service event occurs;

8. Automatic Log rollback;

9. Support and monitor the redundancy of hosts;

10. An optional WEB interface is used to view the current network status, notification and fault history, and log files.

Ii. Install Nagios basic support kit and add users

1). installation kit

# Yum install httpd gcc glibc-common gd-devel xinetd openssl-devel

2) create a nagios user and user group (perform this step first, otherwise an error will be reported during nagios compilation)

# Useradd-s/sbin/nologin nagios
# Mkdir/usr/local/nagios
# Chown-R nagios. nagios/usr/local/nagios

3) install httpd and php

Yum install httpd * # install Apache related services on the Web server. nagios provides a web monitoring interface that allows you to view the running status of the monitored host.

Yum install php * # install PHP-related services

3. Download and compile and install Nagios

1) download and decompress nagios

# Wgethttp: // response

# Tar -zvxfnagios-4.1.0rc1.tar.gz

# Cdnagios-4.1.0rc1

2) Compile and install nagios

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

# Make all # if there is A choice in the middle, directly

# Make install # install the main program, CGI and HTML files

# Make install-init # install the startup script in/etc/rc. d/init. d.

# Make install-config # install the sample configuration file

# Make install-commandmode # configure Directory Permissions

3) Configure auto-start

# Chkconfig -- add nagios # add nagios to serve the system

# Chkconfig -- level 35 nagios on # enable nagios at runtime level 3 and 5

# Chkconfig -- list nagios # list nagios service settings

4) Verify that the program is correctly configured

#/Usr/local/nagios/bin/nagios-v/usr/local/nagios/etc/nagios. cfg

4. Install the Nagios plugin

1) download nagios-plugins

# Wgethttp: // nagios-plugins.org/download/nagios-plugins-2.0.3.tar.gz # download nagios-plugins

# Tar-zxvf nagios-plugins-2.0.3.tar.gz # unzip nagios-plugins

# Cd nagios-plugins-2.0.3

2) Compile and install nagios-plugins

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

# Make

# Make install

3) download nagios-snmp-plugins

# Wgethttp: // nagios.manubulon.com/nagios-snmp-plugins.1.1.1.tgz

# Tar-zxvf nagios-snmp-plugins.1.1.1.tgz

# Cd nagios-plugins-2.0.3/

4) Compile and install nagios-snmp-plugins

# Yum install perl-CPAN # install Perl-CPAN in yum. CPAN is a collection library of Perl software and collects a large number of useful Perl modules and related files. Nagios-snmp-plugins is a set of plug-ins that use Perl to monitor hosts through SNMP. Therefore, you must first install perl-CPAN

# Perl-MCPAN-e shell

# Cpan [1]> install Net: SNMP

5. Configure httpd

# Vi/etc/httpd/conf/httpd. conf

1). Set

User apache
Group apache

Modify to the following content:

2) add index. php

3) Configure nagios. conf

# Cd nagios-4.1.0rc1/

# Ls

# Make install-webconf # install the nagios web interface. The nagios. conf file is created in the/etc/httpd/conf. d directory.

# Ls/etc/httpd/conf. d

# Vi/etc/httpd/conf. d/nagios. conf

Change htpasswd. user of lines 21 and 38 to htpasswd (Note: Do not change it, but add the full path name in the lower part)

4) create a nagios authentication File

# Htpasswd-c/usr/local/nagios/etc/htpasswd admin # create the user name and password of the nagios logon web Interface

# Cat/usr/local/nagios/etc/htpasswd # view the authentication File Content

5). Disable SELinux:

A. temporarily shut down (no need to restart the machine ):

# Setenforce 0 # Set SELinux to permissive mode (disable SELinux)

# Setenforce 1 # Set SELinux to enforcing mode (enable SELinux)

B. To modify the configuration file, restart the machine:

# Vi/etc/selinux/config

Change SELINUX = enforcing to SELINUX = disabled

Machine needs to be restarted

6) enable the Service and go to nagios

# Systemctl start httpd. service

# Systemctl start snmpd. service

# Systemctl start nagios. service

Open the browser, enter http: // 127.0.0.1/nagios/, and then enter the user name and password configured earlier to go to The nagios web interface.

6. Nagios Installation Problems

Enable the hosts option after installation.

In the preceding configuration, we used "htpasswd-c/usr/local/nagios/etc/htpasswd admin" to generate the Administrator account and password, nagios uses nagiosadmin as the Logon account and password by default, while cgi. cfg is used to verify the identity. If the Administrator account we generated is not nagiosadmin, verification fails and an error occurs.

Modify as follows:

# Vi/usr/local/nagios/etc/cgi. cfg

Add the account you generated in the above area. Here is the admin above, and then use systemctl restart httpd. service to restart http. OK

This article is from the "Notepad" blog, please be sure to keep this source http://wangzhijian.blog.51cto.com/6427016/1682211

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.