Linux Learning Note: Nagios installation

Source: Internet
Author: User

Nagios's official QuickStart URL https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/4/en/quickstart-fedora.html


About Nagios's diagram with other servers (the simplest description)

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M01/7A/C4/wKiom1a0FDjz4crOAABYV7wIrvQ573.png "title=" Qq20160205110546.png "alt=" Wkiom1a0fdjz4croaabyv7wirvq573.png "/>

The simplest is because this is just the most common way to deploy, and there is a cluster pattern that is not being studied here.


Way One:

1) Deploy the Nagios core suite on the Nagios server

2) Install the Nagios plugin Kit and Nrpe kit on the client side

3) Each time the Nagios server collects information, it will contact the client's Nrpe (port 5666), which is implemented by clients ' Nrpe to collect the information. Nrpe is actually a client software, extensibility is very strong, you can also write your own plug-in with Shell/python and so on. This kind of collection method is called passive mode.

4) Client side can also act as the proxy side, because Nrpe as the client's local software, can access both local resources, external resources, through some plug-ins, but also to explore other server applications, and these servers do not need to install Nrpe. This method of detection is called active mode.


Way two:

1) The Nagios server side directly detects applications from other servers that do not require additional installation of Nrpe.



If you can read basic English, basically nagios installation according to QuickStart installed on it. Here say a * * * meaning and simple translation

Note implementation

In general, the Nagios server needs to pre-install the following components

httpd php* net-snmp* mrtg gcc glibc glibc-common gd gd-devel perl perl-devel MAILX

Optional components MySQL Mysql-devel


Pre-provisioning

===================================================

1) Turn off SELinux. Command: Setenforce 0 and the SELinux disabled;

2) Add Nagios user, and set password,/usr/sbin/useradd-m Nagios; passwd Nagios;

3) Set the content of/etc/mail.rc (http://coosh.blog.51cto.com/6334375/1735688) and set permissions, by default, its permissions are RW-------, Later we will make changes to Nagios's email alert function, so chgrp nagios/etc/mail.rc; chmod 640/etc/mail.rc;

4) If you want to actively detect the remote server MySQL, then install the optional components above;

5) Set the httpd to boot status


Create a nagcmd group (optional, I did not take this step in the test because I thought it was a bit superfluous, but according to the official guidelines)

/usr/sbin/groupadd Nagcmd

/usr/sbin/usermod-a-G Nagcmd Nagios

/usr/sbin/usermod-a-G Nagcmd Apache


Download Nagios, in the official guide, the version is as follows, and when I write this note Nagios is 4.1.1,nagios plugins is 2.1.1, so the following wget command if copied, may not be able to download the corresponding file. It is best to find the appropriate link from the official website.

mkdir ~/downloads

CD ~/downloads

wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-4.0.8.tar.gz

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


Start installation

Unzip first

CD ~/downloads

Tar xzf nagios-4.0.8.tar.gz

CD nagios-4.0.8

./configure--with-command-group=nagcmd #这一步我把nagcmd改为了nagios, it's up to you to make a change here, but it's important that once you modify it, the group you're setting up is now the group name.

Make all

Make install

Make Install-init

Make Install-config

Make Install-commandmode

#如果依赖的组件都装齐了, there's usually no error.

Vi/usr/local/nagios/etc/objects/contacts.cfg #修改联系方式, later modification can also

Make install-webconf

#重启apache服务

Service httpd Restart


Configure CGI Permissions

Configure an HTTP user admin first

[Email protected] ~]# htpasswd-cb/usr/local/nagios/etc/htpasswd.users admin AdminPassword

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

Change all nagiosadmin strings to nagiosadmin,admin, because you will be logged in to the Web interface with admin, but the admin account does not have access to CGI permissions.


#安装Nagios Plugins

CD ~/downloads

Tar xzf 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

Chkconfig--add Nagios

Chkconfig Nagios on

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

#所有配置文件都OK的情况下, you will be prompted to OK, or you will be prompted for error or warning


To change the way the notification message is sent, the red part, originally mail, please change to MAILX

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

Define Command{

Command_name Notify-host-by-email

command_line/usr/bin/printf "%b" "* * * * Nagios *****\n\nnotification Type: $NOTIFICATIONTYPE $\nhost: $HOSTNAME $\nstat E: $HOSTSTATE $\naddress: $HOSTADDRESS $\ninfo: $HOSTOUTPUT $\n\ndate/time: $LONGDATETIME $\n "| /bin/Mailx -S

"* * $NOTIFICATIONTYPE $ Host Alert: $HOSTNAME $ is $HOSTSTATE $ * *" $CONTACTEMAIL $

}


# ' notify-service-by-email ' command definition

Define Command{

Command_name Notify-service-by-email

command_line/usr/bin/printf "%b" "* * * * Nagios *****\n\nnotification Type: $NOTIFICATIONTYPE $\n\nservice: $SERVICEDES C$\nhost: $HOSTALIAS $\naddress: $HOSTADDRESS $\nstate: $SERVICESTATE $\n\ndate/time: $LONGDATETIME $\n\nadditi

Onal info:\n\n$serviceoutput$\n "| /bin/mailx -S "* * $NOTIFICATIONTYPE $ Service Alert: $HOSTALIAS $/$SERVICEDESC $ is $SERVICESTATE $ * *" $ contactemail$

}


The Nagios server-side installation is complete.


===========================================================

Installing Nrpe on the client

Nrpe needs to install Nagios Plugins First, and if MySQL is involved, it requires a pre-installation of MySQL Mysql-devel


Turn off SELinux and do not repeat the method.


Add Nagios Users

/usr/sbin/useradd Nagios

passwd Nagios


Download Nagios plugin, note the following is a link to the official guide, may not be able to download to the document, the reason ibid.

mkdir ~/downloads

CD ~/downloads

wget http://osdn.dl.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.6.tar.gz

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

Yum Install xinetd #在老男孩老师的视频里, is a standalone daemon way, and in the official guide is the use of xinetd, I used the same xinetd, so the xinetd configuration file has the following modifications

[Email protected] ~]# Vi/etc/xinetd.d/nrpe

Service Nrpe

{

Flags = IPv4 #默认这里是REUSE, I changed to IPV4, the test found that if you use reuse, you can not listen to the IPV4 port

Socket_type = Stream

Port = 5666

wait = no

user = Nagios

Group = Nagios

Server =/usr/local/nagios/bin/nrpe

Server_args =-c/usr/local/nagios/etc/nrpe.cfg--inetd

Log_on_failure + = USERID

Disable = no

Only_from = 127.0.0.1 192.168.5.41 #加入Nagios服务器的地址, separated by spaces

}


Download Nrpe, I was writing this note when the latest version is 2.15

CD ~/downloads

wget http://osdn.dl.sourceforge.net/sourceforge/nagios/nrpe-2.8.tar.gz

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

Be sure to add the following line at the end of the/etc/services, otherwise Nrpe cannot start

Nrpe 5666/tcp # Nrpe


Restart XINETD Service

Service xinetd Restart


To see if there is a listening TCP 5666

NETSTAT-TLNP | grep 5666

TCP 0 0 0.0.0.0:5666 0.0.0.0:* LISTEN 1241/xinetd


Self-test, if normal, then return Nrpe version number, note that the official guide is using localhost, but in general, localhost will be parsed into 127.0.0.1 and:: 1, because we only listen to IPV4, so the host changed to 127.0.0.1

/usr/local/nagios/libexec/check_nrpe-h 127.0.0.1

NRPE v2.8


Configuring the client's firewall

[Email protected] ~]# Vi/etc/sysconfig/iptables

# Firewall configuration written by System-config-firewall

# Manual Customization of this file are not recommended.

*filter

: INPUT ACCEPT [0:0]

: FORWARD ACCEPT [0:0]

: OUTPUT ACCEPT [0:0]

-A input-m state--state established,related-j ACCEPT

-A input-p icmp-j ACCEPT

-A input-i lo-j ACCEPT

-A input-m state--state new-m tcp-p TCP--dport 5666-j ACCEPT


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


The client end is installed







Linux Learning Note: Nagios installation

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.