Nagios PNP Configuration
nagios中文在線文檔 http://www.itnms.net/docs/nagios/cn/build/html/cgiconfig.html下载pnp-0.4.13.tar.gz
tar zvxf pnp-*
cd pnp*
./configure
当显示出以下信息,就表示配置正常
*** Configuration summary for pnp 0.4.13 02-19-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
Path to rrdtool: /usr/bin/rrdtool (Version 1.2.30)
RRDs Perl Modules: FOUND (Version 1.203)
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/
make all && make install
make install-config && make install-init
Nagios 2.x
Until nagios 2.10 the integration of external URLs into the nagios web interface occurs using Extended Info Objects. For PNP we use the directive action_url to call the PNP web frontend with the appropriate options.
define serviceextinfo {
host_name localhost
service_description load
action_url /nagios/pnp/index.php?host=$HOSTNAME$&srv=$SERVICEDESC$
}
Nagios 3.x
Since nagios 3.0 the action_url-directive has be moved to the host or service definition. The objects serviceextinfo and hostextinfo do not apply anymore. This way the definition of URLs to the PNP-interface have been simplified.
define host {
name host-pnp
register 0
action_url /nagios/pnp/index.php?host=$HOSTNAME$
}
define service {
name srv-pnp
register 0
action_url /nagios/pnp/index.php?host=$HOSTNAME$&srv=$SERVICEDESC$
}
复制代码
我这里安装的时nagios 3.0.6,所以要在templates.cfg 的最后添加
define host {
name host-pnp
register 0
action_url /nagios/pnp/index.php?host=$HOSTNAME$
}
define service {
name srv-pnp
register 0
action_url /nagios/pnp/index.php?host=$HOSTNAME$&srv=$SERVICEDESC$
}
Since Nagios 3.x it is possible to deactivate the export of environment variables (as part of optimizing the system for maximum performance). Unfortunately this directive has to be enabled to use the default mode. So either you use the default value (which means that the export is enabled) or you define the variable in nagios.cfg
enable_environment_macros=1Additionally the command to process performance data is to be specified in nagios.cfg
service_perfdata_command=process-service-perfdataStarting with Nagios 3.0 it may be useful to enable processing of performance data for hosts as well. Due to changed host check logic Nagios 3 now performs regularly scheduled host checks.
host_perfdata_command=process-host-perfdata
在commands.cfg 添加一下
define command {
command_name process-service-perfdata
command_line /usr/bin/perl /usr/local/nagios/libexec/process_perfdata.pl
}
define command {
command_name process-host-perfdata
command_line /usr/bin/perl /usr/local/nagios/libexec/process_perfdata.pl -d HOSTPERFDATA
}
在一个要使用pnp监控的主机配置文件里,比如 localhost.cfg 修改以下内容
define host{
use linux-server,host-pnp
host_name localhost
alias localhost
address 127.0.0.1
action_url /nagios/pnp/index.php?host=$HOSTNAME$
process_perf_data 1
}
define service{
use local-service,srv-pnp
host_name localhost
service_description PING
check_command check_ping!100.0,20%!500.0,60%
process_perf_data 1
}
RRDs Perl Modules: *** NOT FOUND ***
cp /opt/rrdtool-1.4.5/lib/perl/5.8.8/x86_64-linux-thread-multi/RRDs.pm /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/
cp /opt/rrdtool-1.4.5/lib/perl/5.8.8/x86_64-linux-thread-multi/auto/RRDs/RRDs.so /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/
重新./configure
Nagios 探索之八 —— Nagios的性能分析图表
Nagios监控的侧重点在“此时”服务是否正常,是一个瞬时状态。通过对这个状态的监控和告警,管理员可以第一时间对主机或者服务的故障做处理。但是我们往往也非常关心主机的性能以及服务的响应时间等情况,这些情况是一个持续的变化曲线,并非一个实时的值,如果通过查看日志数据来分析的话,既繁琐有抽象,所以,我们希望Nagios可以帮我们做这份工作,然后将报表提交给我们,这样就非常方便了。这就是我今天要介绍的Nagios的相关开源项目——PNP(http://ederdrom.de/doku.php/nagios/pnp_en)。
PNP是一个小巧的开源软件包,它是基于PHP和PERL,利用rrdtool将Nagios采集的数据绘制成图表。如果你要安装PNP,那么准备工作有如下3项:
1、整合Apache和PHP(本文使用版本:Apache 2.2.3PHP 5.1.6)
2、安装rrdtools (本文使用版本:RRDTools 1.2.23)
3、安装Perl (本文使用版本: Perl5 )
关于这3项工作的方法,网络上有很多精彩的文章介绍,我就不多说了,下面介绍一下PNP的工作原理,顺便将安装配置的内容也描述如下。
要介绍PNP工作原理,首先要说明一下Nagios提供的数据接口,也就是PNP的数据来源。在前面的文章中,我提到过,在定义host或service中都有一个定义项,名为process_perf_data,其值可以定义为0或1,其作用是是否启用Nagios的数据输出功能。如果你将此项赋值为1,那么Nagios就会将收集的数据写入到某个文件中,以备提取。所以,如果你想让Nagios将数据输出的话,首先要将Nagios的主配置文件nagios.cfg中相关的配置修改:
process_performance_data=1
service_perfdata_command=process-service-perfdata#默认此句被注释掉了
如果想要对某个监控对象做数据图表,则需在所对应的host或者service定义中(一般写在hosts.cfg或者services.cfg文件中),包含如下的定义:
process_perf_data 1
这样,Nagios就会调用相应的命令来输出数据了。Nagios的command定义中默认有一项“process-service-perfdata”,该命令声明了Nagios输出哪些值到输出的文件中。不过其定义相对简单,PNP提供了一个perl脚本,更详尽的定义了一个输出数据的方法。如果要使用PNP的话,我们需要在command的定义中,将“process-service-perfdata”命令对应的执行命令行的内容替换成该脚本:
define command{
command_name process-service-perfdata
command_line /usr/local/nagios/libexec/process_perfdata.pl
}
这样设置了之后,Nagios就会利用PNP提供的脚本进行相关的工作了。
细心的看管大概已经发现了,刚刚定义命令时用到的脚本“process_perfdata.pl”现在还不存在。我们现在就来安装,也就PNP的软件包(本文用的版本是pnp-0.3.3.tar.gz)。安装方法很简单,过程也很顺利(我的系统安装时选择了开发工具,谢天谢地!)
./configure --with-rrdtool=/usr/local/rrdtool/bin/rrdtool --with-perfdata-dir=/usr/local/nagios/share/perfdata/
make all
make install
安装结束之后,再去检查一下Nagios的插件目录(libexec),就会发现多了一个名为“process_perfdata.pl”的脚本。
ok,现在执行一下Nagios配置检查命令
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
如果没有什么错误,那么我们重新启动Nagios。
/etc/init.d/nagios restart
验收一下成果,在浏览器的地址栏中输入:
http://IP/nagios/pnp/
PHP GD Support no found 是因为php-gd模块没装,如果你的系统支持yum,可直接用yum install -y php-gd安装,否则可能只有编译安装了。
templates/check_http.php
templates.dist/check_http.php
templates/default.php
templates.dist/default.php
The template default.php takes an exceptional position as it is used every time no other applicable template is found.
008000 green00FF00
http://www.colorcombos.com/combotester.html顏色測試
页:
[1]