nagios配合PNP,可以创造出绚烂多彩的输出,只要你的脚本符合perfdata规则,那么rrdtool就可以出数据,PNP就可以用图给你画出来。
1、下载安装 pnp4nagios-0.6.6.tar.gz
复制代码代码如下:
nagios $> wget http://cdnetworks-kr-1.dl.sourceforge.net/project/pnp4nagios/PNP-0.6/pnp4nagios-0.6.6.tar.gz
nagios $> apt-get install rrdtool librrds-perl
2、创建配置文件
复制代码代码如下:
nagios $> cd /usr/local/pnp4nagios/etc
nagios $> mv misccommands.cfg-sample misccommands.cfg nagios $> mv nagios.cfg-sample nagios.cfg nagios $> mv npcd.cfg-sample npcd.cfg nagios $> mv process_perfdata.cfg-sample process_perfdata.cfg nagios $> mv rra.cfg-sample rra.cfg
nagios $> cd pages
nagios $> cd ../check_commands
3、重启服务
复制代码代码如下:
nagios $> /etc/init.d/npcd restart
4、修改 nagios 的配置文件.打开performance_data
复制代码代码如下:
process_performance_data=1
host_perfdata_command=process-host-perfdata service_perfdata_command=process-service-perfdata
5、修改 commands.cfg
复制代码代码如下:
# '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 }
6、添加小太阳模版,镶嵌在nagios页面上。
复制代码代码如下:
## 在最后添加
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.cfg
复制代码代码如下:
#修改hosts.cfg
nagios $> vim hosts.cfg define host{ use linux-server,host-pnp host_name eric.com alias eric.com address 192.168.6.101 }
# 修改 services.cfg
8、重启 nagios 服务
复制代码代码如下:
nagios $> /etc/init.d/nagios restart
效果图如下: |