1.布景
本来的服务器和监控体系在移动机房(2.14,外网IP120.132.xx.xx),新上家校圈服务器(17台)在世纪互联机房,新旧服务器不在一致内网。
现在家校圈服务器100.6(120.132.xx.xx)上布置nagios监控布置体系,经过nsca传送到2.14一致进行前端页面办理。
2.装置nagios
(1)yum -y install httpd gcc glibc glibc-common gd gd-devel
(2) rpm -ivh nagios-3.2.1-1.el5.rf
rmp -ivh nagios-plugins-1.4.13-1.el5.rf
(3)设置办理账号:
/etc/httpd/conf.d/nagios.conf
#AuthName “Nagios Access”
#AuthType Basic
# AuthUserFile /etc/nagios/htpasswd.users
#Require valid-user
cat /etc/nagios/htpasswd.users
139guest:JKvJx00FiMbKo
139admin:d4PvA4FyLnZHM
vi /etc/nagios/cgi.cfg
authorized_for_system_information=139admin
authorized_for_configuration_information=139admin
authorized_for_system_commands=139admin
authorized_for_all_services=139admin,139guest
authorized_for_all_hosts=139admin,139guest
authorized_for_all_service_commands=139admin
authorized_for_all_host_commands=139admin
(4)测验
默许有个localhost.cfg是对本机的监控。
/usr/bin/nagios -v /etc/nagios/nagios.cfg 一切正常
/etc/init.d/nagios start 不正常 报错
Starting nagios:CONFIG ERROR! Start aborted. Check your Nagios configuration.
(5) 排查
a)开始置疑权限问题,检查/etc/nagios/权限、/etc/nagios/nagios.cfg里.cfg文件途径以及其他权限,未发现问题。
b)检查日志,/var/log/message,发现如下反常信息:
Nov 3 11:41:18 localhost kernel: audit(1288755678.187:52881): arch=c000003e syscall=2 success=no exit=-13 a0=6d61740 a1=10800 a2=feff72736b747264 a3=6d618f3 items=0 ppid=2377 pid=2380 auid=10015 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=pts0 ses=25 comm=”nagios” exe=”/usr/bin/nagios” subj=user_u:system_r:nagios_t:s0 key=(null)
置疑selinux的问题,检查发现selinux是封闭的。无果。。。
cat /etc/selinux/config
SELINUX=disabled
c)持续追寻/etc//init.d/nagios发动脚本
start)
echo -n “Starting nagios:”
$NagiosBin -v $NagiosCfgFile > /dev/null 2>1;
if [ $? -eq 0 ]; then
su – $NagiosUser -c “touch $NagiosVarDir/nagios.log $NagiosRetentionFile”
rm -f $NagiosCommandFile
touch $NagiosRunFile
chown $NagiosUser:$NagiosGroup $NagiosRunFile
$NagiosBin -d $NagiosCfgFile
if [ -d $NagiosLockDir ]; then touch $NagiosLockDir/$NagiosLockFile; fi
echo ” done.”
exit 0
else
echo “CONFIG ERROR! Start aborted. Check your Nagios configuration.”
exit 1
fi
;;
依据nagios发动时的报错信息“CONFIG ERROR! Start aborted. Check your Nagios configuration.”,阐明在nagios履行过程中,/usr/bin/nagios -v /etc/nagios/nagios.cfg是过错的,去掉> /dev/null 2>1,从头发动nagios,公然报错。提示nagios.cfg line465 装备过错。
vi /etc/nagios/nagios.cfg –line 465
check_result_path=/var/nagios/spool/checkresults
装备是没错的,权限也没错。把/var/nagios/spool/checkresults修正为777也不可。修正为check_result_path=/tmp/checkresults后发动nagios,line465过错处理。但呈现更多的形似权限过错的装备。。。要疯了。
d)置疑nagios账户有问题,公然id nagios也是反常的。
e)置疑selinux disabled后没有重启机器,寻求重启机器,问题决断处理。
(6)done.
浏览器翻开http://120.132.xx.xx/nagios/发现无法衔接,Y的。
检查了http是正常的。。。。再查本来http端口被之前他们改为8080了。
浏览器从头翻开http://120.132.xx.xx:8080/nagios/
everything done!!!
3.在所有(17台)被监控服务器上布置nrpe客户端
(1)装置相关软件包
rpm -ivh *.rpm
fping-2.4-1.b2.2.el5.rf.i386.rpm
perl-Net-SNMP-5.2.0-1.2.el5.rf.noarch.rpm
perl-Socket6-0.19-3.fc6.x86_64.rpm
perl-Crypt-DES-2.05-3.2.el5.rf.x86_64.rpm
lm_sensors-2.10.0-3.1.x86_64.rpm
perl-Digest-HMAC-1.01-15.noarch.rpm
perl-Digest-SHA1-2.11-1.2.1.x86_64.rpm
nagios-plugins-1.4.13-1.el5.rf.x86_64.rpm
nagios-nrpe-2.5.2-1.el5.rf.x86_64.rpm
sysstat-7.0.2-1.el5.x86_64.rpm
(2)修正nrpe.cfg
vi /etc/nagios/nrpe.cfg
allowed_hosts=192.168.100.6
command[check_cpu]=/usr/lib64/nagios/plugins/check_cpu
command[check_load]=/usr/lib64/nagios/plugins/check_load -w 15,12,9 -c 30,25,20
command[check_disk]=/usr/lib64/nagios/plugins/check_disk -w 12% -c 8% -p /
(3)发动nrpe
/etc/init.d/nrpe start
netstat -npl 检查nrpe5666端口是否发动了。
(4)测验
在100.6履行如下指令进行测验
/usr/lib64/nagios/plugins/check_nrpe -H 192.168.100.1 -c check_cpu
4.装备nagios
(1)cat /etc/nagios/objects/service/vianethost.cfg
################ jiaoxiao quan server ##############################