Nagios-PNP绘图

本文转自:http://www.yylog.org/?p=4287

rrdtool安装
pnp是基于php和perl,所有这两个软件包必须先安装好。rrdtool是用来采集nagios数据并生成绘图
[root@localhost tmp]# tar -zxvf rrdtool-11.0.50.tar.gz
[root@localhost tmp]# cd rrdtool-1.0.50/
[root@localhost rrdtool-1.0.50]# ./configure
[root@localhost rrdtool-1.0.50]# make
[root@localhost rrdtool-1.0.50]# make install
pnp安装
[root@localhost tmp]# tar -zxvf pnp-0.4.14.tar.gz
[root@localhost tmp]# cd pnp-0.4.14
[root@localhost pnp-0.4.14]# ./configure –with-rrdtool=/usr/local/rrdtool-1.0.50/bin/rrdtool
configure: error: Perl Module Time::HiRes not available
[root@localhost pnp-0.4.14]# yum install perl-Time-HiRes
[root@localhost pnp-0.4.14]# ./configure –with-rrdtool=/usr/local/rrdtool-1.0.50/bin/rrdtool
*** Configuration summary for pnp 0.4.14 05-02-2009 ***

General Options:
————————- ——————-
Nagios user/group: nagios nagios
Install directory: /usr/local/nagios
HTML Dir: /usr/local/nagios/share/pnp
Config Dir: /usr/local/nagios/etc/pnp
Location of rrdtool binary: /usr/local/rrdtool-1.0.50/bin/rrdtool Version 1.0.50
RRDs Perl Modules: *** NOT FOUND ***
RRD Files stored in: /usr/local/nagios/share/perfdata
process_perfdata.pl Logfile: /usr/local/nagios/var/perfdata.log
Perfdata files (NPCD) stored in: /usr/local/nagios/var/spool/perfdata/

Review the options above for accuracy. If they look okay,
type ‘make all’ to compile.

WARNING: The RRDs Perl Modules are not found on your System
Using RRDs will speedup things in larger Installtions.
[root@localhost pnp-0.4.14]# make all
[root@localhost pnp-0.4.14]# make install
[root@localhost pnp-0.4.14]# make install-config
[root@localhost pnp-0.4.14]# make install-init
编辑httpd.conf,在DirectoryIndex后面加上index.php
DirectoryIndex index.html index.php
[root@localhost pnp-0.4.14]#service httpd restart
在浏览器中访问http://192.168.1.66/nagios/pnp/index.php?host=localhost

Nagios增加绘图
[root@localhost /]# vi /usr/local/nagios/etc/nagios.cfg
#将0改为1
process_performance_data=1
#去掉一下2行注释
host_perfdata_command=process-host-perfdata
service_perfdata_command=process-service-perfdata

将commands.cfg最后面的command_line后的内容替换为下面的内容
[root@localhost /]# vi /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
}
修改localhost.cfg 文件,在define service加入以下参数(颜色标注)
[root@localhost /]# vi /usr/local/nagios/etc/objects/localhost.cfg
define service{
use local-service ; Name of service template to use
host_name localhost
service_description PING
check_command check_ping!100.0,20%!500.0,60%
process_perf_data 1
action_url /nagios/pnp/index.php?host=$HOSTNAME$
}
define service{
use local-service ; Name of service template to use
host_name localhost
service_description Root Partition
check_command check_local_disk!20%!10%!/
process_perf_data 1
action_url /nagios/pnp/index.php?host=$HOSTNAME$
}
define service{
use local-service ; Name of service template to use
host_name localhost
service_description Current Users
check_command check_local_users!20!50
process_perf_data 1
action_url /nagios/pnp/index.php?host=$HOSTNAME$
}
define service{
use local-service ; Name of service template to use
host_name localhost
service_description Total Processes
check_command check_local_procs!250!400!RSZDT
process_perf_data 1
action_url /nagios/pnp/index.php?host=$HOSTNAME$
}
define service{
use local-service ; Name of service template to use
host_name localhost
service_description Current Load
check_command check_local_load!5.0,4.0,3.0!10.0,6.0,4.0
process_perf_data 1
action_url /nagios/pnp/index.php?host=$HOSTNAME$
}
define service{
use local-service ; Name of service template to use
host_name localhost
service_description Swap Usage
check_command check_local_swap!20!10
process_perf_data 1
action_url /nagios/pnp/index.php?host=$HOSTNAME$
}
define service{
use local-service ; Name of service template to use
host_name localhost
service_description SSH
check_command check_ssh
notifications_enabled 0
process_perf_data 1
action_url /nagios/pnp/index.php?host=$HOSTNAME$
}
define service{
use local-service ; Name of service template to use
host_name localhost
service_description HTTP
check_command check_http
notifications_enabled 0
process_perf_data 1
action_url /nagios/pnp/index.php?host=$HOSTNAME$
}
[root@localhost /]# service httpd restart
[root@localhost /]# service nagios restart
Running configuration check…done.
Stopping nagios: done.
Starting nagios:This account is currently not available.
done.
重启httpd和nagios后重新打开web监控页面,此时服务状态多出一列小太阳图标,点击该图标可直接调出绘图页面,效果如图:

你可能感兴趣的:(绘图,nagios,pnp)