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

nagios插件pnp安装

[复制链接]

尚未签到

发表于 2019-1-15 08:59:32 | 显示全部楼层 |阅读模式
  1、安装rrdtool
  # tar zxvf rrdtool-1.4.5.tar.gz && cd rrdtool-1.4.5 && ./configure --prefix=/usr/local/rrdtool && make && make install
  2、安装pnp
  tar zxvf pnp-0.4.13.tar.gz && cd pnp-0.4.13 && ./configure --with-nagios-user=nagios  --with-nagios-group=nagios  --with-rrdtool=/usr/local/rrdtool/bin/rrdtool --with-perfdata-dir=/usr/local/nagios/share/perfdata && make all && make install && make install-config && make install-init
安装完成,PNP默认文件放置情况如下:
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/local/bin/rrdtool (Version 1.4.5)
  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/

ps:RRDs Perl Modules:                *** NOT FOUND ***
在这里我遇到一个很奇怪的问题,由于没有安装rrds perl模块,导致pnp出图的数据是乱码,附上图片:

后来通过yum install rrdtool-perl就恢复正常了,有图有真相


3、配置PNP,创建默认配置文件
# cd /usr/local/nagios/etc/pnp/
# cp process_perfdata.cfg-sample process_perfdata.cfg
# cp npcd.cfg-sample npcd.cfg
# cp rra.cfg-sample rra.cfg
# chown -R nagios:nagios /usr/local/nagios/etc/pnp
修改process_perfdata.cfg文件
vim /usr/local/nagios/etc/pnp/process_perfdata.cfg
LOG_FILE = /usr/local/nagios/var/perfdata.log
#
# Loglevel 0=silent 1=normal 2=debug
#
LOG_LEVEL = 2
这里将日志级别改为2,即debug模式。
4、修改Nagios配置文件
1、增加小太阳图标
修改templates.cfg,增加一个定义PNP的host和service。修改后的内容如下:
define host {
  name       host-pnp
  register   0
#action_url /nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_' class='tips' rel='/nagios/index.php/popup?host=$HOSTNAME$&srv=_HOST_
action_url /nagios/pnp/index.php?host=$HOSTNAME$
process_perf_data 1
}
ps:我这里只添加了主机的小太阳图标,每当添加某主机的服务的时候,都会自动生成该服务的数据文件





  2、修改commands.cfg,定义host-perfdata
  define command{
  command_name  process-host-perfdata
  command_line  /usr/local/nagios/libexec/process_perfdata.pl
  }
  3、让主机引用host-perfdata
  root># cat hosts.cfg
  define host{
  use     host-pnp
  host_name               xx
  alias                    xx(x)
  address                  xx
  contact_groups            shyygroup
  check_command           check-host-alive
  max_check_attempts       5
  notification_interval       10
  notification_period        24x7
  notification_options       d,u,r
  }
  4、重启nagios服务后,在这个目录下会产生2个主机的目录
  ls /usr/local/nagios/share/perfdata/
  xxjshyy  xxysix
  cd xxjshyy
  -rw-rw-r-- 1 nagios nagioscmd 1151496 Dec 21 16:13 Current_Load.rrd
  -rw-rw-r-- 1 nagios nagioscmd   12165 Dec 21 16:13 Current_Load.xml
  -rw-rw-r-- 1 nagios nagioscmd  384952 Dec 21 16:11 Java_9800.rrd
  -rw-rw-r-- 1 nagios nagioscmd   11208 Dec 21 16:11 Java_9800.xml
  -rw-rw-r-- 1 nagios nagioscmd  384952 Dec 21 16:12 Java_9801.rrd
  -rw-rw-r-- 1 nagios nagioscmd   11208 Dec 21 16:12 Java_9801.xml
  -rw-rw-r-- 1 nagios nagioscmd  384952 Dec 18 17:35 mysql_3306.rrd
  -rw-rw-r-- 1 nagios nagioscmd  384952 Dec 21 16:11 Mysql_3306.rrd
  -rw-rw-r-- 1 nagios nagioscmd   11199 Dec 18 17:35 mysql_3306.xml
  -rw-rw-r-- 1 nagios nagioscmd   11202 Dec 21 16:11 Mysql_3306.xml
  -rw-rw-r-- 1 nagios nagioscmd  384952 Dec 21 16:12 Nrpe_5666.rrd
  -rw-rw-r-- 1 nagios nagioscmd   11198 Dec 21 16:12 Nrpe_5666.xml
  -rw-rw-r-- 1 nagios nagioscmd  768224 Dec 21 16:14 Ping.rrd
  -rw-rw-r-- 1 nagios nagioscmd   11702 Dec 21 16:14 Ping.xml
  -rw-rw-r-- 1 nagios nagioscmd  384952 Dec 21 16:14 sda3.rrd
  -rw-rw-r-- 1 nagios nagioscmd   11170 Dec 21 16:14 sda3.xml
  -rw-rw-r-- 1 nagios nagioscmd 1534768 Dec 21 16:13 traffic.rrd
  -rw-rw-r-- 1 nagios nagioscmd   12701 Dec 21 16:13 traffic.xml
  -rw-rw-r-- 1 nagios nagioscmd  384952 Dec 21 16:12 Users.rrd
  -rw-rw-r-- 1 nagios nagioscmd   11120 Dec 21 16:12 Users.xml
  ps:点击小太阳也能会报以下这种错误:
Deprecated: Assigning the return value of new by reference is deprecated in /usr/local/nagios/share/pnp/include/function.inc.php on line 1026

Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Chongqing' for 'CST/8.0/no DST' instead in /usr/local/nagios/share/pnp/include/function.inc.php on line 557

Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Chongqing' for 'CST/8.0/no DST' instead in /usr/local/nagios/share/pnp/include/function.inc.php on line 559

Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Chongqing' for 'CST/8.0/no DST' instead in /usr/local/nagios/share/pnp/include/function.inc.php on line 563

Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Chongqing' for 'CST/8.0/no DST' instead in /usr/local/nagios/share/pnp/include/function.inc.php on line 565

Deprecated: Function eregi() is deprecated in /usr/local/nagios/share/pnp/include/function.inc.php on line 1502
  解决:
这是因为pnp-0.4.14对PHP 5.3.0的支持还不是很好,其中有几个bug需要修改:
根据错误提示打开
vi /usr/local/nagios/share/pnp/include/function.inc.php
找到行1541修改为
if($level == 2 && $type == "complete" && preg_match("/^NAGIOS_/",$tag)){
还会有两处错误需要修改,根据提示找到对应行进行修改:
line 556: 添加:date_default_timezone_set('UTC');
line 1032:修改为$pdf = new PDF('P', 'mm', 'A4'); 删除&
再重新重启nagios,应该就能看到图表了




运维网声明 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-663415-1-1.html 上篇帖子: nagios监控客户端 下篇帖子: nagios的错误
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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