之前用pnp 整合到nagios中,发现总是没数据,图表也出不来,不知道是什么原因,找了资料发现现在用的更多还是pnp4nagios ,便下载试验一下,还真的成功了,配置如下: 1.安装RRDTool [iyunv@server nagios]# tar zxvf rrdtool-1.4.7.tar.gz [iyunv@server rrdtool-1.4.7]# ./configure --prefix=/usr/local/rrdtool 编译的时候出现了2个错误: (1)configure: error: Please fix the library issues listed above and try again. 解决办法: [iyunv@server nagios]# tar zxvf cgilib-0.5.tar.gz [iyunv@server nagios]# cd cgilib-0.5 [iyunv@server cgilib-0.5]# make [iyunv@server cgilib-0.5]# cp libcgi.a /usr/local/lib [iyunv@server cgilib-0.5]# cp cgi.h /usr/include [iyunv@server rrdtool-1.4.7]# yum -y install libart_lgpl-devel [iyunv@server rrdtool-1.4.7]# yum -y install pango-devel* cairo-devel* (2)在make的时候报错: Can't locate ExtUtils/MakeMaker.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at Makefile.PL line 1. 解决办法: yum install perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker 安装完重新编译即可。 [iyunv@server rrdtool-1.4.7]# ./configure --prefix=/usr/local/rrdtool [iyunv@server rrdtool-1.4.7]# make [iyunv@server rrdtool-1.4.7]# make install 2.安装pnp4nagios [iyunv@server ~]# tar zxvf pnp4nagios-0.6.19.tar.gz [iyunv@server ~]# cd pnp4nagios-0.6.19 [iyunv@server pnp4nagios-0.6.19]# ./configure --prefix=/usr/local/pnp4nagios --with-nagios-user=nagios [iyunv@server pnp4nagios-0.6.19]# make all [iyunv@server pnp4nagios-0.6.19]# make install [iyunv@server pnp4nagios-0.6.19]# make install-webconf [iyunv@server pnp4nagios-0.6.19]# make install-config [iyunv@server pnp4nagios-0.6.19]# make install-init 安装完成后,通过模板文件,创建配置文件 [iyunv@server ~]# cd /usr/local/pnp4nagios/etc/ [iyunv@server etc]# mv nagios.cfg-sample nagios.cfg [iyunv@server etc]# mv rra.cfg-sample rra.cfg [iyunv@server etc]# mv misccommands.cfg-sample misccommands.cfg [iyunv@server etc]# cd pages/ [iyunv@server pages]# mv web_traffic.cfg-sample web_traffic.cfg [iyunv@server pages]# cd ../check_commands/ [iyunv@server check_commands]# mv check_all_local_disks.cfg-sample check_all_local_disks.cfg [iyunv@server check_commands]# mv check_nrpe.cfg-sample check_nrpe.cfg [iyunv@server check_commands]# mv check_nwstat.cfg-sample check_nwstat.cfg 3.编辑httpd.conf 打开httpd.conf并添加以下内容: Alias /pnp4nagios "/usr/local/pnp4nagios/share" <Directory "/usr/local/pnp4nagios/share"> AllowOverride None Order allow,deny Allow from all AuthName "Nagios Access" AuthType Basic AuthUserFile /usr/local/nagios/etc/htpasswd Require valid-user <IfModule mod_rewrite.c> # Turn on URL rewriting RewriteEngine On Options symLinksIfOwnerMatch # Installation directory RewriteBase /pnp4nagios/ # Protect application and system files from being viewed RewriteRule "^(?:application|modules|system)/" - [F] # Allow any files or directories that exist to be displayed directly RewriteCond "%{REQUEST_FILENAME}" !-f RewriteCond "%{REQUEST_FILENAME}" !-d # Rewrite all other URLs to index.php/URL RewriteRule "^.*$" "index.php/$0" [PT] </IfModule> </Directory> 配置完成后保存退出。 4.编辑template.cfg 文件 添加以下内容: [iyunv@server ~]# vim /usr/local/nagios/etc/objects/templates.cfg define host { name hosts-pnp register 0 action_url /pnp4nagios/graph?host=$HOSTNAME$ process_perf_data 1 } define service { name services-pnp register 0 action_url /pnp4nagios/graph?host=$HOSTNAME$&srv=$SERVICEDESC$ process_perf_data 1 } 5.编辑hosts.cfg和services.cfg 添加小太阳标示 [iyunv@server ~]# vim /usr/local/nagios/etc/hosts.cfg define host{ use linux-server,hosts-pnp host_name node-1 alias lamp address 192.168.30.110 } [iyunv@server ~]# vim /usr/local/nagios/etc/services.cfg define service{ use generic-service,services-pnp host_name node-1 service_description check_users check_command check_nrpe!check_users max_check_attempts 5 normal_check_interval 1 } 6.编辑commands.cfg 添加相应命令 [iyunv@server ~]# vim /usr/local/nagios/etc/objects/commands.cfg # 'process-host-perfdata' command definition define command{ command_name process-host-perfdata command_line /usr/local/nagios/libexec/process_perfdata.pl } # 'process-service-perfdata' command definition define command{ command_name process-service-perfdata command_line /usr/local/nagios/libexec/process_perfdata.pl } 注意:这里为了方便管理,将process_perfdata.pl 复制到/usr/local/nagios/libexec/目录下 [iyunv@server ~]# cp /usr/local/pnp4nagios/libexec/process_perfdata.pl /usr/local/nagios/libexec/ 7.检查并重启nagios 通过nagios –v 参数检查配置是否有错误存在。 Total Warnings: 0 Total Errors: 0 确认无错误后,重启nagios [iyunv@server ~]# service nagios restart Running configuration check...done. Stopping nagios: .done. 效果如下:
点击小太阳进入测试页面
注:只有在前面准备阶段把基础环境都配置好,这里的环境测试才能全部通过的。 如果提示缺少Php 相关包,可以通过yum –y php-* 进行安装 按照图中提示删除或者重命名其安装文件install.php。这里选择重命名的方式。 [iyunv@server ~]# mv /usr/local/pnp4nagios/share/install.php /usr/local/pnp4nagios/share/install.php.bak 8.编辑nagios.cfg,开启数据接收功能 [iyunv@server ~]# vim /usr/local/nagios/etc/nagios.cfg process_performance_data=1 enable_environment_macros=1 service_perfdata_command=process-service-perfdata host_perfdata_command=process-host-perfdata 9.重启nagios 服务之后即可看到图表 注意:打开的时候遇到了以下的错误:
根据提示,是权限不够的问题: [iyunv@server ~]# chmod 750 /var/lib/php/session/ [iyunv@server ~]# chown nagios.nagios /var/lib/php/session/ 刷新网页之后即可看到有图表出现:
|