首页 > 代码库 > SUSE 11g SP3系统服务器NRPE配置

SUSE 11g SP3系统服务器NRPE配置

1.创建账号信息

登录为root用户,

#su –l

创建nagios账号并设置密码

#/usr/sbin/useradd nagios

#passwd nagios

wKioL1N656qxIoB3AADKJHj1THc554.jpg

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

wKioL1N659CBTgjIAADM2LPRPn4398.jpg

安装nrpe plugindaemon和样例daemon config文件

#makeinstall-plugin

#makeinstall-daemon

#makeinstall-daemon-config

wKioL1N65-yiGlisAAM2a3NK9h0361.jpg

xinetd下安装nrpe daemon服务

#make install-xinetd

wKiom1N66ILCBEuIAABpR5JHmCo888.jpg

编辑/etc/xinetd.d/nrpe文件,在only_from后面增加监控主机IP地址,多个IP之间用空格区分

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

allowed_host后添加监控主机IP地址,多个IP之间用空格区分

/etc/services文件中加入nrpe daemon端口号

wKiom1N66ZzRs7NWAAAW4ZmuPpk908.jpgspacer.gif

重启xinetd服务

#service xinetd restart

spacer.gif

5.本地nrpedaemon测试

#netstat –at | grep nrpe

wKioL1N66ZGz6rf_AABs6lrpKAw081.jpg

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

wKiom1N66diQ0-ZfAABjnsMgYl0136.jpg

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

wKioL1N66eHCFQXiAAA3GsBUSV8483.jpg

测试成功,可正常通信!

8.监控主机配置

新建xx.cfg配置文件,如下所列,定义host模板、hostservice等;

 

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

wKiom1N66p_BeC6gAAHQ3E9H2j8249.jpgwKioL1N66oPCio-MAAFrPlUyuKY779.jpg


系统工作正常!

 

*美中不足的是service:no such service iptables这个错误还没解决,如果设备重启防火墙设置应该要重设!


本文出自 “lucas” 博客,请务必保留此出处http://4292565.blog.51cto.com/4282565/1414095