为nagios添加图表
1、安装组件
专注于为中小企业提供成都网站设计、网站制作服务,电脑端+手机端+微信端的三站合一,更高效的管理,为中小企业磐石免费做网站提供优质的服务。我们立足成都,凝聚了一批互联网行业人才,有力地推动了成百上千企业的稳健成长,帮助中小企业通过网站建设实现规模扩充和转变。
yum install perl-Time-HiRes rrdtool rrdtool-perl
2、安装pnp4nagios-0.6.24
wget http://jaist.dl.sourceforge.net/project/pnp4nagios/PNP-0.6/pnp4nagios-0.6.24.tar.gz
tar zxvf pnp4nagios-0.6.24.tar.gz
cd pnp4nagios-0.6.24
./configure --with-nagios-user=nagios --with-nagios-group=nagcmd
make all
make install
make install-webconf
make install-config
make install-init
3、创建配置文件
cd /usr/local/pnp4nagios/etc/
mv misccommands.cfg-sample misccommands.cfg
mv nagios.cfg-sample nagios.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
4、重启服务
service npcd restart
5、修改nagios配置档
1)vi /usr/local/nagios/etc/nagios.cfg
将process_performance_data=0 修改为 process_performance_data=1
将以下两项的#去掉
host_perfdata_command=process-host-perfdata
service_perfdata_command=process-service-perfdata
2)vi /usr/local/nagios/etc/objects/commands.cfg 添加以下内容
define command{ command_name process-service-perfdata-file command_line /bin/mv /usr/local/pnp4nagios/var/service-perfdata /usr/local/pnp4nagios/var/spool/service-perfdata.$TIMET$ } define command{ command_name process-host-perfdata-file command_line /bin/mv /usr/local/pnp4nagios/var/host-perfdata /usr/local/pnp4nagios/var/spool/host-perfdata.$TIMET$ }
并将原有# 'process-host-perfdata' command definition、# 'process-service-perfdata' command definition注解删除!
3)vi /usr/local/nagios/etc/objetcs/templates.cfg
添加红色字体内容
define service{
name generic-service
active_checks_enabled 1
passive_checks_enabled 1
parallelize_check 1
obsess_over_service 1
check_freshness 0
notifications_enabled 1
event_handler_enabled 1
flap_detection_enabled 1
failure_prediction_enabled 1
process_perf_data 1
retain_status_information 1
retain_nonstatus_information 1
is_volatile 0
check_period 24x7
max_check_attempts 3
normal_check_interval 10
retry_check_interval 2
contact_groups admins
notification_options w,u,c,r
notification_interval 60
notification_period 24x7
register 0
action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$
process_perf_data 1
}
4)vi /usr/local/nagios/etc/nagios.cfg 修改参数如下
# Bulk / NPCD mode # process_performance_data=1 # *** the template definition differs from the one in the original nagios.cfg # service_perfdata_file=/usr/local/pnp4nagios/var/service-perfdata service_perfdata_file_template=DATATYPE::SERVICEPERFDATA\tTIMET::$TIMET$\tHOSTNAME::$HOSTNAME$\tSERVICEDESC::$SERVICEDESC$\tSERVICEPERFDATA::$SERVICEPERFDATA$\tSERVICECHECKCOMMAND::$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-file # *** the template definition differs from the one in the original nagios.cfg # 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
6、检查配置是否有误
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
重启服务
service nagios restart
service httpd restart
7、排错
pnp4nagios输入用户名密码始终不正确具体解决方法
是由于在安装pnp4nagios后在/etc/httpd/conf.d里,已经生成pnp4nagios.conf配置文件
vi /etc/httpd/conf.d/pnp4nagios.conf 将AuthUserFile /usr/local/nagios/etc/htpasswd.user修改为 /usr/local/nagios/etc/htpasswd
The requested URL /nagios/pnp4nagios/index.php/graph was not found on this server
开启apache的php功能
vi /usr/local/httpd/conf/httpd.conf
查找字符串AddType,并增加
AddType application/x-httpd-php .php .php3 .htm .phtml .php4
AddType application/x-httpd-php-source .phps
查找字符串DirectoryIndex,并修改为
DirectoryIndex index.html index.php3 index.php default.php
将/etc/httpd/conf.d/pnp4nagios.conf所有内容复制到/etc/httpd/conf/httpd.conf后面
service httpd restart
perfdata directory "/usr/local/pnp4nagios/var/perfdata/localhost" for host "does not。。。。
chown -R nagios.nagcmd /usr/local/pnp4nagios/var/
本文名称:为nagios添加图表
标题路径:http://hbruida.cn/article/poicdp.html