1.创建账号信息
登录为root用户,
#su –l
创建nagios账号并设置密码
#/usr/sbin/useradd nagios
#passwd nagios
2.安装nagios插件
创建下载文件存放文件夹
#mkdir ~/downloads
#cd ~/downloads
下载nagios插件
#wget http://nagios-plugins.org/download/nagios-plugins-1.4.6.tar.gz
解压文件
#tar xzf nagios-plugins-1.4.6.tar.gz
#cd nagios-plugins-1.4.6.tar.gz
编译并安装插件
#./configure
#make
#make install
赋予访问插件权限
#chown nagios.nagios /usr/local/nagios
若报错chown: invalid user: `nagios.nagios‘,则输入下面命令
#groupadd nagios
#chown –R nagios.nagios/usr/local/nagios/libexec
3.安装xinetd
suse 11g sp3 应该是自带安装xinetd,若没有安装用下面语句
#zypper install xinetd
4.安装nrpe daemon
#cd ~/downloads
#wget http://ftp.jaist.ac.jp/pub/sourceforge/n/na/nagios/nrpe-2.x/nrpe-2.8/nrpe-2.8.tar.gz
解压文件
#tar xzf nrpe-2.8.tar.gz
编译nrpe addon
编译前安装openssl
#cd ~/downloads
#wget http://www.openssl.org/source/openssl-1.0.0l.tar.gz
#tar xzf openssl-1.0.0l.tar.gz
#cd openssl-1.0.01
#make
#make install
#cd ../nrpe-2.8
#./configure
#make all
安装nrpe plugin,daemon和样例daemon config文件
#makeinstall-plugin
#makeinstall-daemon
#makeinstall-daemon-config
在xinetd下安装nrpe daemon服务
#make install-xinetd
编辑/etc/xinetd.d/nrpe文件,在only_from后面增加监控主机IP地址,多个IP之间用空格区分
#vi/usr/local/nagios/etc/nrpe.cfg
在allowed_host后添加监控主机IP地址,多个IP之间用空格区分
在/etc/services文件中加入nrpe daemon端口号
重启xinetd服务
#service xinetd restart
5.本地nrpedaemon测试
#netstat –at | grep nrpe
#/usr/local/nagios/libexec/check_nrpe -H localhost
6.防火墙配置
#iptables -IINPUT -p tcp --dport 5666 -j ACCEPT
#service iptables save
报错service: no suchservice iptables
7.监控主机与被监控主机通信测试、
# /usr/local/nagios/libexec/check_nrpe-H 120.xxx.xx.xxx
测试成功,可正常通信!
8.监控主机配置
新建xx.cfg配置文件,如下所列,定义host模板、host、service等;
define host{
name online-server
use generic-host
check_period 24x7
check_interval 5
retry_interval 1
max_check_attempts 10
check_command check-host-alive
notification_period 24x7
notification_interval 30
notification_options d,r
contact_groups admins
register 0
}
define host{
use online-server
host_name linux-gu5z
alias XX
address 120.XXX.XX.XXX
}
define service{
use generic-service
host_name linux-gu5z
service_description CPULoad
check_command check_nrpe!check_load
}
define service{
use generic-service
host_name linux-gu5z
service_description Current Users
check_command check_nrpe!check_users
}
在nagios.cfg中添加该配置文件,
cfg_file=/usr/local/nagios/etc/objects/xx.cfg
重启nagios服务
#service nagios restart
系统工作正常!
*美中不足的是service:no such service iptables这个错误还没解决,如果设备重启防火墙设置应该要重设!
SUSE 11g SP3系统服务器NRPE配置,布布扣,bubuko.com