Ubuntu16.04 nagios通过NRPE监控客户端

1.先安装这个

sudo apt-get install wget build-essential apache2 php apache2-mod-php7.0 php-gd libgd-dev sendmail unzip

2.用户和组配置

useradd nagios
groupadd nagcmd
usermod -a -G nagcmd nagios
usermod -a -G nagios,nagcmd www-data

3.安装nagios

cd ~
wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.2.0.tar.gz
tar -xzf nagios*.tar.gz
cd nagios-4.2.0

Ubuntu16.04 nagios通过NRPE监控客户端

4.编译nagios

./configure --with-nagios-group=nagios --with-command-group=nagcmd

make all
sudo make install
sudo make install-commandmode
sudo make install-init
sudo make install-config
/usr/bin/install -c -m 644 sample-config/httpd.conf /etc/apache2/sites-available/nagios.conf

并将evenhandler目录复制到nagios目录中:

cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/
chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers

 Ubuntu16.04 nagios通过NRPE监控客户端

5.安装Nagios插件

wget https://nagios-plugins.org/download/nagios-plugins-2.1.2.tar.gz
tar -xzf nagios-plugins*.tar.gz

Ubuntu16.04 nagios通过NRPE监控客户端

 cd nagios-plugins-2.1.2/

以下命令安装nagios插件:

./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-openssl
make
make install

6.安装阶段完成之后,配置nagios

vim /usr/local/nagios/etc/nagios.cfg

将下面这行cfg_dir=.......取消注释

Ubuntu16.04 nagios通过NRPE监控客户端

添加名为servers的新文件夹:

mkdir -p /usr/local/nagios/etc/servers

Ubuntu16.04 nagios通过NRPE监控客户端

然后

vim /usr/local/nagios/etc/objects/contacts.cfg

更改为自己的电子邮箱

Ubuntu16.04 nagios通过NRPE监控客户端

 7.配置Apache

启动apache模块

sudo a2enmod rewrite
sudo a2enmod cgi

Ubuntu16.04 nagios通过NRPE监控客户端

可以使用htpasswd命令为nagios Web界面配置用户nagiosadmin:

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

Ubuntu16.04 nagios通过NRPE监控客户端

启用Nagios虚拟主机:

sudo ln -s /etc/apache2/sites-available/nagios.conf /etc/apache2/sites-enabled/

启动Apache和Nagios

service apache2 restart
service nagios start

在这里遇到了问题:

Ubuntu16.04 nagios通过NRPE监控客户端

解决方法:

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

Ubuntu16.04 nagios通过NRPE监控客户端

创建这个文件,并添加内容:

sudo vi /etc/systemd/system/nagios.service

Ubuntu16.04 nagios通过NRPE监控客户端

Ubuntu16.04 nagios通过NRPE监控客户端

8.添加主机监控(通过nrpe对主机进行监控):

服务器是:192.168.121.27

客户端:192.168.121.28

Ubuntu16.04 nagios通过NRPE监控客户端

配置nrpe

vim /etc/nagios/nrpe.cfg

Ubuntu16.04 nagios通过NRPE监控客户端

service nagios-nrpe-server restart

9.在服务器中创建一个新文件并添加内容:

vim /usr/local/nagios/etc/servers/ubuntu_host.cfg

Ubuntu16.04 nagios通过NRPE监控客户端

Ubuntu16.04 nagios通过NRPE监控客户端

Ubuntu16.04 nagios通过NRPE监控客户端

检查配置:

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

Ubuntu16.04 nagios通过NRPE监控客户端

10.启动服务:

服务器:

Ubuntu16.04 nagios通过NRPE监控客户端

客户端:

Ubuntu16.04 nagios通过NRPE监控客户端

登录网页:

用户名是:nagiosadmin

密码:123456(刚刚有个命令让输入的密码)

Ubuntu16.04 nagios通过NRPE监控客户端

Ubuntu16.04 nagios通过NRPE监控客户端

上一篇:全局设置axios发送cookie(axios 默认不发送cookie)


下一篇:xshell工具连接不上虚拟机问题解决