nagios 安装完了,只有数字输出监控内容是不是不炫丽呢?是不是想像CACTI 一样出炫丽的图呢?那你可以选择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 nagios $> tar zxvf pnp4nagios-0.6.6.tar.gz nagios $> cd pnp4nagios-0.6.6 nagios $> ./configure --with-nagios-user=nagios --with-nagios-group=nagcmd nagios $> make all nagios $> make install nagios $> make install-webconf nagios $> make install-config nagios $> make install-init
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 $> mv web_traffic.cfg-sample web_traffic.cfg
nagios $> cd ../check_commands
nagios $> mv check_all_local_disks.cfg-sample check_all_local_disks.cfg
nagios $> mv check_nrpe.cfg-sample check_nrpe.cfg
nagios $> mv check_nwstat.cfg-sample check_nwstat.cfg
3. 重启服务
nagios $> /etc/init.d/npcd restart
4.修改 nagios 的配置文件.打开performance_data
nagios $> cd /usr/local/nagios/etc
nagios $> vim nagios.cfg
#打开注视项:
process_performance_data=1
host_perfdata_command=process-host-perfdata
service_perfdata_command=process-service-perfdata
5.修改 commands.cfg
nagios $> cd /usr/local/nagios/etc/objects
nagios $> vim 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页面上。
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.cfg
nagios $> cd /usr/local/nagios/etc/eric.com
#修改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
define service{
use local-service,srv-pnp
host_name eric.com
service_description PING
check_command check_ping!100.0,20%!500.0,60%
}
8.重启 nagios 服务
nagios $> /etc/init.d/nagios restart
本文转自Deidara 51CTO博客,原文链接:http://blog.51cto.com/deidara/382129,如需转载请自行联系原作者