NAGIOS插件pnp4nagios安装
注:nagios版本nagios4.0.8
1.下载安装 pnp4nagios-0.6.25.tar.gz
wget http://sourceforge.net/projects/pnp4nagios/files/PNP-0.6/pnp4nagios-0.6.25.tar.gz
yum -y install rrdtool perl-Time-HiRes perl-File-Tail rrdtool rrdtool-perl php-gd
tar zxvf? pnp4nagios-0.6.25.tar.gz
cd pnp4nagios-0.6.25
#perl -MRRDs -le ‘print q(ok!)‘
如果返回值是ok!,则可以进行pnp4nagios配置和安装
#./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-rrdtool=/usr/bin/rrdtool?--with-perl_lib_path=/usr/lib64/perl5/vendor_perl/auto/RRDs
#make all
#make install
#make install-webconf
#make install-config
#make install-init
2.创建配置文件
cd /usr/local/pnp4nagios/etc
mv misccommands.cfg-sample? misccommands.cfg
mv nagios.cfg-sample? nagios.cfg
mv npcd.cfg-sample npcd.cfg
mv process_perfdata.cfg-sample? process_perfdata.cfg
#?mv rra.cfg-sample rra.cfg
#? cd pages
mv web_traffic.cfg-sample web_traffic.cfg
cd ../check_commands
mv check_all_local_disks.cfg-sample? check_all_local_disks.cfg
mv check_nrpe.cfg-sample? check_nrpe.cfg
mv check_nwstat.cfg-sample? check_nwstat.cfg
- 重启服务
/etc/init.d/npcd restart
echo “/etc/init.d/npcd start”>>/etc/rc.local
4.修改 nagios 的配置文件.打开performance_datacd /usr/local/nagios/etc
vim nagios.cfg
#打开注释项:
process_performance_data=1
host_perfdata_command=process-host-perfdata
service_perfdata_command=process-service-perfdata
#######################添加如下内容####################################
service_perfdata_file=/usr/local/pnp4nagios/var/service-perfdata
service_perfdata_file_template=DATATYPE::SERVICEPERFDATA\tTIMET::$TIMET$\tHOSTNAME::$HOSTNAME$\tSERVICEDESC::$SERVICEDESC$\tSERVICEPERFDATA::$SERVICEPERFDATA$\tSERVICEC::HECKCOMMAND::$SERVICECHECKCOMMAND$\tHOSTSTATE::$HOSTSTATE$\tHOSTSTATETYPE::$HOSTSTATETYPE$\tSERVICESTATE::$SERVICESTATE$\tSERVICESTATETYPE::$SERVICESTATETYPE$
service_perfdata_file_mode=a
service_perfdata_file_processing_interval=15
service_perfdata_file_processing_command=process-service-perfdata-filehost performancedata starting with Nagios 3.0
host_perfdata_file=/usr/local/pnp4nagios/var/host-perfdata
host_perfdata_file_template=DATATYPE::HOSTPERFDATA\tTIMET::$TIMET$\tHOSTNAME::$HOSTNAME$\tHOSTPERFDATA::$HOSTPERFDATA$\tHOSTCHECKCOMMAND::$HOSTCHECKCOMMAND$\tHOSTSTATE::$HOSTSTATE$\tHOSTSTATETYPE::$HOSTSTATETYPE$
host_perfdata_file_mode=a
host_perfdata_file_processing_interval=15
host_perfdata_file_processing_command=process-host-perfdata-file
###########################################################
5.修改 commands.cfgcd /usr/local/nagios/etc/objects
vim commands.cfg
##添加
#################################################################
define command{
command_name process-service-perfdata
command_line /usr/local/pnp4nagios/libexec/process_perfdata.pl --bulk=/usr/local/pnp4nagios/var/service-perfdata
}
define command{
command_name process-host-perfdata
command_line /usr/local/pnp4nagios/libexec/process_perfdata.pl --bulk=/usr/local/pnp4nagios/var/host-perfdata
}
- 添加小太阳模版,镶嵌在nagios页面上。
vim templates.cfg
在最后添加
define host {
name host-pnp
action_url /pnp4nagios/graph?host=$HOSTNAME$&srv=HOST
register 0
}
define service {
name srv-pnp
action_url /pnp4nagios/graph?host=$HOSTNAME$&srv=$SERVICEDESC$
register 0
}
7,修改 hosts.cfg 和services.cfgcd /usr/local/nagios/etc/objects
#修改hosts.cfg
vim hosts.cfg
define host{
????????use???????????????????? linux-server,host-pnp??
????????host_name????????? wwwserver
????????alias???????????????????? wwwserver
????????address????????????????? 10.10.10.111
????????}
修改 services.cfg
define service{
????????use???????????????????????? ?local-service,srv-pnp??????
????????host_name?????????????????? ?wwwserver
????????service_description???????? PING
????????check_command???????????? check_ping!100.0,20%!500.0,60%
}
其他的主机和服务以此类推
检查配置文件正确与否
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
返回值如上图片,则重启nagios
8.重启?nagios?服务
#/etc/init.d/nagios restart
效果图:
这时点击小太阳会出现如下提示:The requested URL /pnp4nagios/graph was not found on this server.
解决方法如下:
原因,当你在pnp4nagios安装的时候执行了make install-webconf,注意它生成了一个apache的配置文件。
你把这个文件:/etc/httpd/conf.d/pnp4nagios.conf?中的所有内容全部添加到apache的httpd.conf文件最后,再重新启动nagios和apache就应该可以啦。
[[email protected] etc]# find / -name pnp4nagios.conf
/etc/httpd/conf.d/pnp4nagios.conf
[[email protected] etc]# vim /etc/httpd/conf.d/pnp4nagios.conf
[[email protected] etc]# cat /etc/httpd/conf.d/pnp4nagios.conf>>/usr/local/apache/conf/httpd.conf
#service httpd restart
#service Nagios restart
这时再点击小太阳,会出现pnp4nagios的测试页,结果如下:
告诉要删掉或重命名/usr/local/pnp4nagios/share/install.php
故障2:
安装测试:
http://monitor.dreamlive.tv//pnp4nagios/index.php
#cd /usr/local/pnp4nagios/share
#mv install.php install.php.bak
在此测试:显示如下:
没有图像出现,主要原因就是:导致
解决方法:
改为:
重启httpd
结果就正常了
报如下错误
Yum -y install pango pango-devel
然后重启系统
原文地址:http://blog.51cto.com/niming2008/2136408