Centos6.5-----Nagios Quick Install compilation configuration document-All virtual environments

Source: Internet
Author: User
Tags fully qualified domain name

The purpose of writing this document is to facilitate the deployment of Nagios, related to the configuration of personal preferences, we modify, can be applied.

First, download and install the required software

1,yum install gcc mysql httpd php gd OpenSSL openssl-devel mysql-server vim wget

Wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-4.0.7.tar.gz

Wget http://nagios-plugins.org/download/nagios-plugins-2.0.3.tar.gz

Wget http://nchc.dl.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.14/nrpe-2.14.tar.gz



Ls can see nagios-4.0.7.tar.gz nagios-plugins-2.0.3.tar.gz nrpe-2.14.tar.gz


Yum install wget httpd php gcc glibc glibc-common gd gd-devel make NET-SNMP

Useradd Nagios

passwd Nagios

Groupadd Nagcmd

Usermod–a–g Nagcmd Nagios

(Nagcmd:x:504:nagios)


Tar–xvzf nagios-4.0.7.tar.gz

CD nagios-4.0.7

./configure–with-command-group=nagcmd


You can first./configure–help first look at the help, should be the default is to use Nagios users, do not need to specify-with-nagios-user or anything else.




Make all

Make install

Make Install-init

The init script in this installation/ETC/RC.D/INIT.D

Make Install-commandmode

This installation and configuration permissions

External command file for directory

Make Install-config

Example of this installation * */USR/LOCAL/NAGIOS/ETC configuration file

You must modify these sample files before

Use Nagios. Reading HTML documents


Make install-webconf

This installation of Nagios Apache configuration file

Web interface



Cp–r contrib/eventhandlers//usr/local/nagios/libexec/

(-R: Recursively replicate directories, which are copied together with subdirectories and files under the directory.) )


Chown–r nagios:nagios/usr/local/nagios/libexec/eventhandlers

/usr/local/nagios/bin/nagios-v/usr/local/nagios/etc/nagios.cfg (Detect configuration file for errors)


{[email protected] libexec]# chown-r nagios:nagios/usr/local/nagios/libexec/eventhandlers/

[email protected] libexec]# LL

Total 4

Drwxr-xr-x. 4 Nagios nagios 4096 Oct 01:16 eventhandlers}


/etc/init.d/nagios Start or service Nagios start

Chkconfig--add Nagios

Chkconfig Nagios on

Chkconfig httpd on

Service httpd Start


Ii. Creating a Web user


Switch to Ngios user


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

Enter Password Nagios



Third, installation Nagios-plugins


Tar–xvzf nagios-plugins-2.0.3.tar.gz

Cd nagios-plugins-2.0.3


./configure {–with-nagios-user=nagios–with-nagios-group=nagios}

Make

Make install

Before this step is done can be skipped, anyway to do once.

Chkconfig Nagios on or Chkconfig–level

Chkconfig httpd on or Chkconfig–level httpd on


Iv. shutting down firewalls and SELinux


Service Iptables Stop


Vim/etc/sysconfig/selinux change SELinux to disabled this requires a reboot to take effect.



http://192.168.1.202/nagios/This is the Nagios address, nagiosadmin Nagios to enter the user name and password


Unable to open the question notifications error ****************************************


Error:could not open command file '/usr/local/nagios/var/rw/nagios.cmd ' for update!

This is primarily the Apache user does not have Execute permission/usr/local/nagios/var/rw/nagios.cmd caused,

Workaround:

Usermod-a-G Nagcmd Apache

Adding Apache users to the Nagios user group is OK.



Date-s Adjust Date Time clock-w save



Installation of Nrpe plug-in.


Tar–xvzf nrpe-2.14.tar.gz

Cd nrpe-2.14

./configure

Make && make install

Make Install-plugin

Put the Check_nrpe under the/usr/local/nagios/libex. To use Check_nrpe.


***********************************************************************************

2***************************************************


installed on the monitored machine.


Nagios-plugins installation.


Useradd Nagios

PASSWD Nagios

Tar–xvzf nagios-plugins-2.0.3.tar.gz

Cd Nagios-plugins

./configure

Make

Make install

Chown–r Nagios:nagios/usr/local/nagios



Installing nrpe-2.14

Tar–xvzf nrpe-2.14.tar.gz

Cd nrpe-2.14

./configure

Make all

Make Install-plugin

Make Install-daemon

Make Install-daemon-config



Yum Install xinetd

Chkconfig--add xinetd

Chkconfig xinetd on


Make install-xinetd



Vim/etc/xinetd.d/nrpe

In the file Only_from = 127.0.0.1 192.168.1.107//Add the address of the monitoring host at the rear, with a space interval


Vim/usr/local/nagios/etc/nrpe.cfg Here is also a full-access add 192.168.107


Vim/etc/services

It's good to start the Nrpe.


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


Service xinetd Restart

Netstat-at |grep Nrpe

Netstat–an | grep 5666



Vim/etc/sysconfig/iptables


-A input-m state--state new-m tcp-p TCP--dport 5666-j ACCEPT (this statement is yet to be, but I have another one)

As if not add above this no line, will be reported check_nrpe:error-could not complete SSL handshake



Run ipables–f to clear the rules and save.

Then Iptables–l–n review the confirmation.


Service iptables Save

Service iptables Restart


2, configuration file aspects:

(1)/usr/local/nagios/etc/nrpe.cfg This profile is configured correctly, multiple IP addresses are separated by commas, and note spaces: allowed_host=127.0.0.1, 192.168.0.1 This is not right, Must be a allowed_host=127.0.0.1,192.168.1.202 comma cannot have spaces after it;

(2) Check whether the configuration is limited, in the/etc/xinetd.d/nrpe file to add the IP address of the server allowed to access, in the "Only_from =" line to add, multiple IP addresses are separated by spaces, for example: Only_from = 192.168.0. 8 192.168.1.202


Controlled End:

Vi/etc/xinetd.d/nrpe

Only_from increasing the master IP

Vi/usr/local/nagios/etc/nrpe.cfg

allowed_hosts increasing the master IP

Service xinetd Restart

Main control side:

/usr/local/nagios/libexec/check_nrpe-h the IP address of the monitored side to test if the connection was successful





After modifying the nrpe.cfg must restart Nrpe, warrior I do this:

Pkill Nrpe;

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



Second, add Monitoring node and service




Three "Add authentication user

That is, when you access Nagios through the Web, you must log in with this user. Here we add user test: password is 12345

[[email protected] nagios-plugins-1.4.13]# htpasswd-c/usr/local/nagios/etc/htpasswd test

You can use the which command to view the location of the HTPASSWD command, if it is the source installed Apache here to write htpasswd full path. The user is test, the command ends will prompt you to enter the password, here enter 123456.

65. View the contents of the certification file

[Email protected] nagios-plugins-1.4.13]# LESS/USR/LOCAL/NAGIOS/ETC/HTPASSWD

67. The installation of Nagios here is basically done, and you can access it through the web.


Third, the detection definition shortcut command


Issue 1: Newly created folders and nodes do not take effect


FIX: Modify the Nagios directory file so that its directory is detected

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

Add the directory you want to detect.

Cfg_dir=/usr/local/nagios/etc/cfgs



Issue 2: "Apache failed to start" is installed by default under/usr/sbin/, when executing apachectl start, the following error is indicated:


Httpd:apr_sockaddr_info_get () failed for Shiwei

Httpd:could not reliably determine the server ' s fully qualified domain name, using 127.0.0.1 for ServerName




So on the Internet to check a bit, according to the experience of predecessors, the problem finally solved. Summary, convenient for later use.


Reason: This problem should not be set ServerName in/etc/httpd/conf/httpd.conf. So Apache will use the host name to replace, first will find/etc/hosts in the definition of the host.


Workaround:


(1) You can set the ServerName in the httpd.conf file, as follows: ServerName localhost:80


(2) Fill in the/etc/hosts with its own host name Bogon, as follows: 127.0.0.1 Shiwei (user name)


Issue 3 nrpe:unable to read output

My workaround: Modify the permissions of the Nagios directory

#chown-R Nagios:nagios nagios/

#chmod-R 775 nagios/

Problem solving. Linux



Iv. Add Command

Command[check_cpu]=/usr/local/nagios/libexec/check_cpu_pct-w $ARG 1$-C $ARG 2$

Command[check_memory]=/usr/local/nagios/libexec/check_mem-w $ARG 1$-C $ARG 2$

After copying the configuration file to the specified directory, modify the owning and accessing permissions.


Command[check_load]=/usr/local/nagios/libexec/check_load-w $ARG 1$-C $ARG 2$

Command[check_swap]=/usr/local/nagios/libexec/check_swap-w $ARG 1$-C $ARG 2$228

Command[check_disk]=/usr/local/nagios/libexec/check_disk-w $ARG 1$-C $ARG 2$

command[check_io]=/usr/local/nagios/libexec/check_iostat-d $ARG 3$-W $ARG 1$-C $ARG 2$




V. Installation of SendMail

To ensure a complete installation of the SendMail related components first, we can use the following command to complete the SendMail installation:

# yum Install-y sendmail*

Then restart the SendMail service:

# Service SendMail Restart

Then send a test message to verify the availability of the SendMail:

# echo "Hello World" | mail [email protected]



[Email protected] objects]# service SendMail restart

Shutting down SendMail: [FAILED]

Starting sendmail: [OK]

Starting sm-client: [OK]


Chkconfig SendMail off




Chkconfig sendmail off accelerates boot time

Restart Server Note 1, boot Nrpe two boot sendmail three iptables settings





Some configuration of Nagios multi-user

At first I thought that when I was in Nagios, the user authentication was done with Apache, and the first reaction to this demand was that it could not be done. But then I thought, No. Nagios itself will have at least some user-configured bar, so start looking for relevant information, the basic configuration is as follows:

(1) Add an Apache user, such as Qiuyuetao

[Email protected] ~]# htpasswd/usr/local/nagios/etc/htpasswd.users Qiuyuetao

(2) Change cgi.cfg configuration

[Email protected] ~]# vi/usr/local/nagios/etc/cgi.cfg

Use_authentication=1

If only allow view, do not allow management, plus the following configuration

Authorized_for_read_only=qiuyuetao

Authorized_for_all_services=qiuyuetao

Authorized_for_all_hosts=qiuyuetao


(3) Set UserA as a contact

[Email protected] ~]# vi/usr/local/nagios/etc/objects/contacts.cfg #添加如下配置

Define Contact{

Contact_Name Qiuyuetao

Use Generic-contact

Alias Qyt

}

(4) Add Qiuyuetao to the contacts belonging to the UserA host, service profile

[Email protected] ~]# vi/usr/local/nagios/etc/objects/hosts.cfg

Define host {

host_name [email protected]

alias [email protected]

Address 10.1.1.22

Contacs Qyt

Contact_groups Sys_admins

Check_command check-host-alive

Max_check_attempts 5

Notification_interval 3

Notification_period 24x7

Notification_options D,u,r

}

(5) Effective after restarting Nagios

[Email protected] ~]#/etc/init.d/nagios restart


This article is from the "Useful Notes" blog, so be sure to keep this source http://qiuyt.blog.51cto.com/1229789/1580093

Centos6.5-----Nagios Quick Install compilation configuration document-All virtual environments

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.