监控端(服务端):ubuntu16.04.7 192.168.17.213 nagios-4.4.5 nagios-plugins-release-2.2.1 nrpe-2.15

被监控端(客户端):centos7.6 192.168.16.69 nrpe-2.15

服务端部署

1.安装依赖

1
apt-get install -y autoconf gcc libc6 make wget unzip apache2 php libapache2-mod-php7.0 libgd2-xpm-dev

2.下载安装包

1
2
cd /tmp
wget -O nagioscore.tar.gz https://github.com/NagiosEnterprises/nagioscore/archive/nagios-4.4.5.tar.gz

3.解压安装包

1
2
tar xzf nagioscore.tar.gz
cd /tmp/nagioscore-nagios-4.4.5/

4.编译安装

1
2
./configure --with-httpd-conf=/etc/apache2/sites-enabled
make all

5.配置安装

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#创建nagios用户和nagios用户组,并将www-date加入到nagios组
make install-groups-users
usermod -a -G nagios www-data
#安装库文件,CGIs,HTML files
make install
#安装Service/Daemon
make install-daemoninit
#安装外置命令
make install-commandmode
#安装配置文件
make install-config
#安装apache配置文件并启用cgi和rewrite功能
make install-webconf
a2enmod cgi
a2enmod rewrite

5.生成nagios管理账户和密码

1
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

6.配置防火墙

1
2
ufw allow Apache
ufw reload

7.重启nagios服务和apache服务

1
2
systemctl restart apache2.service
systemctl start nagios.service

安装nagios插件

1.安装依赖

1
apt-get install -y autoconf gcc libc6 libmcrypt-dev make libssl-dev wget bc gawk dc build-essential snmp libnet-snmp-perl gettext

2.下载插件包并解压

1
2
3
cd /tmp
wget --no-check-certificate -O nagios-plugins.tar.gz https://github.com/nagios-plugins/nagios-plugins/archive/release-2.2.1.tar.gz
tar zxf nagios-plugins.tar.gz

3.编译安装

1
2
3
4
cd /tmp/nagios-plugins-release-2.2.1/
sudo ./configure
sudo make
sudo make install

服务端NRPE安装

1.下载解压nrpe包

1
2
3
cd /tmp
wget https://github.com/NagiosEnterprises/nrpe/releases/download/nrpe-3.2.1/nrpe-3.2.1.tar.gz
tar xzf nrpe-3.2.1.tar.gz

2.编译安装

1
2
3
4
5
6
7
#编译安装
cd nrpe-nrpe-3.2.1
./configure --with-ssl-lib=/usr/lib/x86_64-linux-gnu
make all
make install-plugin
#查看是否安装成功
ll /usr/local/nagios/libexec/ |grep check_nrpe

客户端部署

1.nagios插件下载及安装

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#下载并解压
cd /tmp
wget http://nagios-plugins.org/download/nagios-plugins-2.2.1.tar.gz
tar xzf nagios-plugins-2.2.1.tar.gz
cd nagios-plugins-2.2.1
#编译安装
./configure
make
make install
#创建nagios用户和组
useradd nagios
groupadd nagios
usermod -a -G nagios nagios
#修改nagios目录所属
chown nagios.nagios /usr/local/nagios
chown -R nagios.nagios /usr/local/nagios/libexec

2.安装nrpe

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#安装xinetd守护进程
yum install xinetd -y

#下载nrpe包并解压
cd /tmp
wget https://github.com/NagiosEnterprises/nrpe/releases/download/nrpe-3.2.1/nrpe-3.2.1.tar.gz
tar xzf nrpe-3.2.1.tar.gz

#编译安装
cd nrpe-nrpe-3.2.1
./configure
make all
make install-groups-users
make install
make install-config
make install-inetd
make install-init
#启动xinetd和nrpe
service xinetd restart
systemctl reload xinetd
systemctl enable nrpe && systemctl start nrpe
#查看nrpe是否启动
netstat -at | egrep "nrpe|5666"