Nagios部署+远程MySQL监控+PNP图表环境配置(4)

五、nagios下安装GD库
1、freetype
[root@nagios ~]# tar -zxvf freetype-2.4.8.tar.gz
[root@nagios ~]# cd freetype-2.4.8
[root@nagios freetype-2.4.8]# make && make install
2、libjpeg
[root@nagios ~]# yum install libtool -y
[root@nagios ~]# mkdir -p /usr/local/jpeg /include
[root@nagios ~]# mkdir -p /usr/local/jpeg /lib
[root@nagios ~]# mkdir -p /usr/local/jpeg /bin
[root@nagios ~]# mkdir -p /usr/local/jpeg/man/man1/
[root@nagios ~]# tar -zxvf jpegsrc.v6b.tar.gz
[root@nagios ~]# cd jpeg-6b/
[root@nagios jpeg-6b]#./configure --prefix=/usr/local/jpeg –enable-shared
[root@nagios jpeg-6b]# make install
3、libpng
[root@nagios ~]#tar -zxvf libpng-1.5.4.tar.gz
[root@nagios ~]# cd libpng-1.5.4
[root@nagios libpng-1.5.4]# ./configure –prefix=/usr/local/png
[root@nagios libpng-1.5.4]#make && make install
4、gd
[root@nagios ~]# tar -zxvf gd-2.0.35.tar.gz
[root@nagios ~]# cd gd-2.0.35
[root@nagios gd-2.0.35]#./configure –prefix=/usr/local/gd2

OK,gd相关的库已经安装完了,现在将他们整合到php中
[root@nagios ~]# cd php-5.3.2
[root@nagios php-5.3.2]#./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-zlib --with-jpeg-dir=/usr/local/jpeg --with-png-dir=/usr/local/png --with-freetype-dir=/usr/local/freetype --with-gd --enable-magic-quotes --with-iconv --enable-mbstring=all
[root@nagios php-5.3.2]#make && make install
php整合gd库完成。


接着上面的pnp的监控吧:
重启apache2 和 nagios
[root@nagios ~]# /usr/local/apache2/bin/apachectl -k restart
[root@nagios ~]# service nagios restart

***troubshooting:
1、timezone时区
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
这是因为php所取的时间是格林威治标准时间,所以和你当地时间会有出入。

[root@nagios ~]#vim /usr/local/nagios/etc/pnp/config.php
加入下面一行:
date_default_timezone_set(Asia/Chongqing);
[root@nagios ~]# /usr/local/apache2/bin/apachectl -k restart


   
  
2、perl-Time-HiRes 未安装

看看脚本/usr/local/nagios/libexec/process_perfdata.pl能否执行
[root@nagios ~]#/usr/local/nagios/libexec/process_perfdata.pl
Can't locate Time/HiRes.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at /usr/local/nagios/libexec/process_perfdata.pl line 32.
BEGIN failed--compilation aborted at /usr/local/nagios/libexec/process_perfdata.pl line 32.
[root@nagios ~]# yum install perl-Time-HiRes -y 
 
   
 3、php5.3之后eregi() 被preg_match()取代
 


出现下面的问题了
Deprecated: Assigning the return value of new by reference is deprecated in /usr/local/nagios/share/pnp/include/function.inc.php on line 1026

Deprecated: Function eregi() is deprecated in /usr/local/nagios/share/pnp/include/function.inc.php on line 1502
问题的根源是php中有两种正则表示法,一个是posix,一个是perl,php6打算废除posix的正则表示法,所以后来就加了个preg_match。此问题解决办法可以在ereg前面加过滤符,将ereg()变成@ereg()。但是这种问题还是没有从根源上解决,php5.2版本之前ereg使用正常,在5.3之后,就要用preg_match来代替ereg。注意,posix和perl的很明显的区别就是是否加斜杠,后者不能少了“/”。所以改法为:
[root@nagios ~]#vim /usr/local/nagios/share/pnp/include/function.inc.php
1502 if($level == 2 && $type == "complete" && eregi("^NAGIOS_",$tag)){
改为
1502 if($level == 2 && $type == "complete" && preg_match("/^NAGIOS_/",$tag)){
具体可以参考:

[root@nagios ~]# vim /usr/local/nagios/libexec/process_perfdata.pl
在最前面添加下面一行:
use lib qw($prefix/lib/perl)

图片太大,做成pdf附件了。

免费下载地址在

用户名与密码都是

具体下载目录在 /2012年资料/7月/1日/Nagios部署+远程MySQL监控+PNP图表环境配置

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/9968acbe73ad09fb0c73953daace36d0.html