2.nagios客户端安装

tonyty163 Nagios2.nagios客户端安装已关闭评论8,491字数 2274阅读7分34秒阅读模式

在被监控服务器(Linux/unix)上安装Nagios-plugins和nrpe

1、添加用户文章源自运维生存时间-https://www.ttlsa.com/nagios/install-nginx-client/

/usr/sbin/useradd -m nagios
passwd nagios

2、解压安装nagios-plugins文章源自运维生存时间-https://www.ttlsa.com/nagios/install-nginx-client/

cd /usr/local/src/tarbag
wget http://downloads.sourceforge.net/project/nagiosplug/nagiosplug/1.4.15/nagios-plugins-1.4.15.tar.gz?r=http%3A%2F%2Fwww.nagios.org%2Fdownload%2Fplugins%2F&ts=1331283502&use_mirror=ncu
tar zxvf nagios-plugins-1.4.15.tar.gz -C ../software/
cd ../software/nagios-plugins-1.4.15

Nagios-plugins默认安装到/usr/local/nagios文章源自运维生存时间-https://www.ttlsa.com/nagios/install-nginx-client/

./configure
make
make install

更改目录属主文章源自运维生存时间-https://www.ttlsa.com/nagios/install-nginx-client/

chown -R nagios.nagios /usr/local/nagios/

3、解压安装nrpe文章源自运维生存时间-https://www.ttlsa.com/nagios/install-nginx-client/

cd /usr/local/src/tarbag
wget http://downloads.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.13/nrpe-2.13.tar.gz?r=http%3A%2F%2Fexchange.nagios.org%2Fdirectory%2FAddons%2FMonitoring-Agents%2FNRPE--2D-Nagios-Remote-Plugin-Executor%2Fdetails&ts=1331283624&use_mirror=nchc
tar zxvf nrpe-2.13.tar.gz -C ../software/
cd ../software/nrpe-2.13
./configure
make all

安装nrpe插件,本插件监控端可以不装文章源自运维生存时间-https://www.ttlsa.com/nagios/install-nginx-client/

make install-plugin

安装nrpe守护进程文章源自运维生存时间-https://www.ttlsa.com/nagios/install-nginx-client/

make install-daemon

安张nrpe配置文件文章源自运维生存时间-https://www.ttlsa.com/nagios/install-nginx-client/

make install-daemon-config

4、配置相关文件文章源自运维生存时间-https://www.ttlsa.com/nagios/install-nginx-client/

修改nrpe配置文件,允许Nagios监控服务器(192.168.0.19)监控文章源自运维生存时间-https://www.ttlsa.com/nagios/install-nginx-client/

cd /usr/local/nagios/etc/
vi nrpe.cfg

多台机器用逗号隔开文章源自运维生存时间-https://www.ttlsa.com/nagios/install-nginx-client/

allowed_hosts=127.0.0.1,192.168.0.19

以独立守护进程启动nrpe,也可以使用xinetd启动nrpe,具体清查看nrpe官方文档。文章源自运维生存时间-https://www.ttlsa.com/nagios/install-nginx-client/

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

开机自动启动nrpe,在rc.local中加入上面行文章源自运维生存时间-https://www.ttlsa.com/nagios/install-nginx-client/

vi /etc/rc.local

5、检查nrpe是否安装正常文章源自运维生存时间-https://www.ttlsa.com/nagios/install-nginx-client/

/usr/local/nagios/libexec/check_nrpe -H localhost

得到以下输出
NRPE v2.13文章源自运维生存时间-https://www.ttlsa.com/nagios/install-nginx-client/

返回nrpe版本说明安装没问题。
查看启动端口文章源自运维生存时间-https://www.ttlsa.com/nagios/install-nginx-client/

netstat -tunlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name  
tcp        0      0 0.0.0.0:5666                0.0.0.0:*                   LISTEN      27387/nrpe

如果有防火墙应该开放5666端口:文章源自运维生存时间-https://www.ttlsa.com/nagios/install-nginx-client/

iptables -I eth0 -p tcp -m tcp –dport 5666 -j ACCEPT

6、定义监控项
注意:我们需要在/usr/local/nagios/etc/nrpe.cfg中定义我们用到的监控本地资源的命令。
下面的命令是默认定义的:文章源自运维生存时间-https://www.ttlsa.com/nagios/install-nginx-client/

command[check_users]=/usr/local/nagios/libexec/check_users -w 5 -c 10
command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20
command[check_hda1]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/hda1
command[check_zombie_procs]=/usr/local/nagios/libexec/check_procs -w 5 -c 10 -s Z
command[check_total_procs]=/usr/local/nagios/libexec/check_procs -w 150 -c 200

下面的命令是自己定义的:
监控交换分区的使用情况,使用超过20%时为警告状态,超过10%时为严重状态文章源自运维生存时间-https://www.ttlsa.com/nagios/install-nginx-client/

command[check_swap]=/usr/local/nagios/libexec/check_swap -w 20% -c 10%

监控根分区磁盘使用情况文章源自运维生存时间-https://www.ttlsa.com/nagios/install-nginx-client/

command[check_disk_root]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /

修改完配置需要重启nrpe
先将nrpe进程kill掉
在执行

/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
weinxin
我的微信
微信公众号
扫一扫关注运维生存时间公众号,获取最新技术文章~
tonyty163
  • 本文由 发表于 16/03/2012 16:05:21
  • 转载请务必保留本文链接:https://www.ttlsa.com/nagios/install-nginx-client/
  • Apache
  • nrpe
  • plugins
  • 安装
  • 客服端
  • 被监控