设为首页 收藏本站
查看: 1440|回复: 0

Nagios PNP Configuration

[复制链接]

尚未签到

发表于 2015-9-8 08:46:05 | 显示全部楼层 |阅读模式
  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.3  PHP 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 green  00FF00
http://www.colorcombos.com/combotester.html  顏色測試

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-110834-1-1.html 上篇帖子: nagios的安装配置 下篇帖子: nagios监控ip连接数,网卡流量
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表