Ps:使用yum安装rrdtool,则忽略此步骤。
make all && make install && make install-webconf && make install-config && make install-init #编译安装,生成相应的配置及初始化文件 cd /usr/local/pnp4nagios/etc mv misccommands.cfg-sample misccommands.cfg mv nagios.cfg-sample nagios.cfg mv rra.cfg-sample rra.cfg cd /usr/local/pnp4nagios/etc/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 #将上述配置文件重命名,使之能够被程序识别重启服务
service npcd restart修改nagios相关配置文件中参数
process_performance_data=1 #将此变量值设为1 host_perfdata_command=process-host-perfdata service_perfdata_command=process-service-perfdata #取消这两项的注释 cd /usr/local/nagios/etc/objects vim commands.cfg #对nagios命令配置文件进行设置 # 'process-host-perfdata' command definition define command{ command_name process-host-perfdata command_line /usr/local/pnp4nagios/libexec/process_perfdata.pl } # 'process-service-perfdata' command definition define command{ command_name process-service-perfdata command_line /usr/local/pnp4nagios/libexec/process_perfdata.pl } #添加上面两行在文件的末行 ,并删除或注释掉原有对process-host-perfdata和process-service-perfdata进行定义的字段说明:command.cfg文件的默认设置对process-host-perfdata 和 process-service-perfdata有定义,如果直接添加而不删除默认定义会发生冲突,进而而导致在检测配置文件时报错。
vim templates.cfg #对nagios的模板配置文件进行修改 define host { name host-pnp action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_' class='tips' rel='/pnp4nagios/index.php/popup?host=$HOSTNAME$&srv=_HOST_ register 0 } define service { name srv-pnp action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$' class='tips' rel='/pnp4nagios/index.php/popup?host=$HOSTNAME$&srv=$SERVICEDESC$ register 0 } #在模版中添加pnp4nagios的定义 cp ../pnp4nagios-0.6.14/contrib/ssi/* /usr/local/nagios/share/ssi/ #回到解压目录下,复制鼠标悬停图标显示,预览绘图所需的文件定义监控服务/主机
cd /usr/local/nagios/etc/ vim mylinux.cfg #自定义监控主机和监控服务 define host{ use linux-server host_name mylinux alias mylinux address 192.168.0.72 } #定义监控主机 define service{ host_name mylinux use generic-service,srv-pnp service_description PING check_command check_ping!100.0,20%!500.0,60%! } define service{ hostgroup_name mylinux use generic-service,srv-pnp service_description remote_load check_command check_nrpe!check_load } #定义监控的服务 define serviceextinfo { host_name mylinux #与主机名对应 service_description remote_load #与要显示的服务对应 action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$' class='tips' rel='/pnp4nagios/index.php/popup?host=$HOSTNAME$&srv=$SERVICEDESC$ } #这是向nagios监控界面对应服务添加pnp4nagios图标的方法