Nagios+pnp4nagios+rrdtool 安装配置nagios(一)
基于的軟件版本
Apache-2.0.63? php-5.3.2?nagios-3.2.3? nagios-plugins-1.4.15? rrdtool-1.4.5?nrpe-2.12
pnp4nagios-0.4.13?check_mysql_health
?
服務器端
1、安裝前準備
(1)創建nagios用戶和用戶組
[root@localhost ~]#useradd -s /sbin/nologin nagios?
[root@localhost ~]#mkdir /usr/local/nagios
[root@localhost ~]# chown –R ?nagios.nagios/usr/local/nagios
(2)開啟系統sendmail服務 (自行選擇)
?在nagios監控服務器上開啟sendmail服務的主要作用是讓nagios在檢測到故障時可以發送報警郵件,目前幾乎所有的linux發行版本都默認自帶了sendmail服務,所以,在安裝系統時只需開啟sendmail服務即可,并且不需要在sendmail上做任何配置。
2、編譯安裝Nagios
[root@localhost ~]# tar -zxvf nagios-3.2.3.tar.gz
[root@localhost ~]# cd nagios-3.2.3
[root@localhost nagios-3.2.3]#./configure --prefix=/usr/local/nagios??
#指定nagios的安裝目錄,這里指定nagios安裝到/usr/local/nagios目錄
[root@localhost nagios-3.2.3]#make all??
[root@localhost nagios-3.2.3]#make install???
????
# make install用來安裝nagios的主程序,CGI和HTML文件
[root@localhost nagios-3.2.3]# make install-init???
#通過make install-init命令可以在/etc/rc.d/init.d目錄下創建nagios啟動腳本
[root@localhost nagios-3.2.3]# make install-commandmode??
#通過make install-commandmode命令來配置目錄權限
[root@localhost nagios-3.2.3]# make install-config???
#make install-cofig命令用來安裝nagios示例配置文件,這里安裝的路徑是/usr/local/nagios/etc
3、Nagios目錄介紹
目錄對應的功能說明如下:
?
bin:可執行程序所在目錄
?
etc:配置文件所在目錄
?
sbin:cgi文件所在目錄,也就是執行外部命令所需文件所在目錄
?
share:網頁文件所在目錄
?
libexec:外部插件所在目錄
?
var:日志文件,lock等文件所在目錄
?
var/archives:日志自動歸檔目錄
?
var/rw:用來存放外部命令文件的目錄
4、?安裝Nagios插件
?這里下載的版本是nagios-plugins-1.4.15。
?注意:插件版本與nagios版本的關聯并不大。
[root@localhost nagios]#tar –zxvf? nagios-plugins-1.4.15.tar.gz
[root@localhost nagios]#cd? nagios-plugins-1.4.15
[root@localhost nagios-plugins-1.4.15]#./configure --prefix=/usr/local/nagios
[root@localhost nagios-plugins-1.4.15]# make?
[root@localhost nagios-plugins-1.4.15]# make install
?安裝完成,在/usr/local/nagios下的libexec目錄下,生成很多可執行文件,這些正是nagios所需要的插件。
5、安裝與配置apache和php
?apache和php不是安裝nagios所必須的,但是nagios提供了web監控界面,通過web監控界面可以清晰的看到被監控主機、資源的運行狀態,因此,安裝一個web服務是很必要的。
?需要注意的是,nagios在nagios3.1.x版本以后,配置web監控界面時需要php的支持。這里我們下載的nagios版本為nagios-3.2.3,因此在編譯安裝完成apache后,還需要編譯php模塊,這里選取的php版本為php5.3.2。
(1)安裝apache與php
首先安裝apache,步驟如下:
[root@nagiosserver ~]# tar zxvf httpd-2.0.63.tar.gz
[root@nagiosserver ~]#cd httpd-2.0.63
注意:在64位機器上安裝需要加參數--witn-expat=bulitin,否則make時會報錯 /usr/lib/libexpat.so: could not read symbols: File in wrong format? collect2: ld returned 1 exit status。在32位機器上直接./configure --prefix=/usr/local/apache2 就可以
?[root@nagiosserver ~]#./configure --prefix=/usr/local/apache2 --enable-modules=so--enable-rewrite --with-expat=builtin
?[root@nagiosserver ~]#make
[root@nagiosserver ~]#make install
接著安裝php,步驟如下:
[root@nagiosserver ~]# tar zxvf php-5.3.2.tar.gz
[root@nagiosserver ~]#cd php-5.3.2
注意php的編譯參數,如果需要pnp圖表顯示,請看pnp安裝時的注意事項,編譯參數不能用下面的;如果不用pnp圖表直接用下面的就可以
(./configure? --prefix=/usr/local/php--with-apxs2=/usr/local/apache2/bin/apxs --with-zlib-dir=/usr/include/zlib.h--with-gd)
[root@nagiosserver~]#./configure? --prefix=/usr/local/php? --with-apxs2=/usr/local/apache2/bin/apxs
在64位系統上編譯php 如果如果出現如下錯誤
configure: error: libjpeg.(a|so) not found
解決方法:
來源 https://bugs.php.net/bug.php?id=33685
解決方式:
# ln -s /usr/lib64/libjpeg.so /usr/lib/
# ln -s /usr/lib64/libpng.so /usr/lib/
然后繼續編繹安裝即可!
[root@nagiosserver ~]#make
[root@nagiosserver ~]#make install
從安裝步驟可知,apache安裝路徑為/usr/local/apache2,而php安裝路徑為/usr/local/php。
(2)配置apache(apache版本不同,修改可能會不同)
找到apache配置文件/usr/local/apache2/conf/httpd.conf?
找到:
User nobody
Group #-1
修改為
User nagios
Group nagios
然后找到
DirectoryIndex index.html index.html.var
修改為
DirectoryIndex index.html index.php
接著增加如下內容:注意下面的 .php,前面有空格
AddType application/x-httpd-php .php
為了安全其間,一般情況下要讓nagios的web監控界面必須經過授權才能訪問,這需要增加驗證配置,即在httpd.conf文件最后添加如下信息:
#setting for nagios
ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"
?<Directory "/usr/local/nagios/sbin">
???? AuthType Basic
???? Options ExecCGI
???? AllowOverride None
???? Order allow,deny
???? Allow from all
???? AuthName "Nagios Access"
AuthUserFile /usr/local/nagios/etc/htpasswd
???? Require valid-user
?</Directory>
Alias /nagios "/usr/local/nagios/share"
?<Directory "/usr/local/nagios/share">
???? AuthType Basic
???? Options None
???? AllowOverride None
???? Order allow,deny
???? Allow from all
???? AuthName "nagios Access"
AuthUserFile /usr/local/nagios/etc/htpasswd
???? Require valid-user
?</Directory>
(3)創建apache目錄驗證文件
? 在上面的配置中,指定了目錄驗證文件htpasswd,下面要創建這個文件:
?[root@localhost nagios]#/usr/local/apache2/bin/htpasswd?-c/usr/local/nagios/etc/htpasswd nagios?????
?New password: (輸入密碼)?????
?Re-type new password: (再輸入一次密碼)?????
?Adding password for user ixdba
?這樣就在/usr/local/nagios/etc目錄下創建了一個htpasswd驗證文件,當通過http://ip/nagios/訪問時就需要輸入用戶名和密碼了。
?最后,啟動服務:?
?[root@ nagiosserver ~]#/usr/local/apache2/bin/apachectl? start
啟動服務可能會出現如下錯誤:
? httpd: Could notdetermine the server's fully qualified domain name, using 127.0.0.1 forServerName
解決很簡單 在httpd.conf里有一段 #ServerName www.example.com:80去掉#號就可以?
一、nagios配置過程詳解
1、nagios默認配置文件介紹
?nagios安裝完畢后,默認的配置文件在/usr/local/nagios/etc目錄下
2、配置文件之間的關系
?在nagios的配置過程中涉及到的幾個定義有:主機、主機組,服務、服務組,聯系人、聯系人組,監控時間,監控命令等,從這些定義可以看出,nagios各個配置文件之間是互為關聯,彼此引用的。
?成功配置出一臺nagios監控系統,必須要弄清楚每個配置文件之間依賴與被依賴的關系,最重要的有四點:
?第一:定義監控哪些主機、主機組、服務和服務組
?第二:定義這個監控要用什么命令實現,
?第三:定義監控的時間段,
?第四:定義主機或服務出現問題時要通知的聯系人和聯系人組。
?
3、開始配置nagios
?為了能更清楚的說明問題,同時也為了維護方便,建議將nagios各個定義對象創建獨立的配置文件:
?即為:
?創建hosts.cfg文件來定義主機和主機組
?創建services.cfg文件來定義服務
?用默認的contacts.cfg文件來定義聯系人和聯系人組
?用默認的commands.cfg文件來定義命令
?用默認的timeperiods.cfg來定義監控時間段
?用默認的templates.cfg文件作為資源引用文件
? (1)templates.cfg文件
?
?nagios主要用于監控主機資源以及服務,在nagios配置中稱為對象,為了不必重復定義一些監控對象,Nagios引入了一個模板配置文件,將一些共性的屬性定義成模板,以便于多次引用。這就是templates.cfg的作用。
?下面詳細介紹下templates.cfg文件中每個參數的含義:
(2)resource.cfg文件
?resource.cfg是nagios的變量定義文件,文件內容只有一行:
?
?其中,變量$USER1$指定了安裝nagios插件的路徑,如果把插件安裝在了其它路徑,只需在這里進行修改即可。需要注意的是,變量必須先定義,然后才能在其它配置文件中進行引用。
(3)理解Nagios宏及其工作機制
Nagios配置非常靈活,繼承和引用是一大特征,另一個重要特征就是可以在命令行的定義里使用宏,通過定義宏,nagios可以靈活的獲取主機、服務和其它對象的信息。
宏的工作機制
在執行命令之前,nagios將對命令里的每個宏替換成它們應當取得的值。這種宏替換發生在Nagios執行各種類型的宏時候。例如主機和服務的檢測、通知、事件處理等。
?
宏的分類:
默認宏、按需而成的宏、用戶自定制宏等。
?
默認宏:
主機IP地址宏
當在命令定義中使用主機或服務宏時,宏將要執行所用的值指向主機或服務所帶有值??聪旅孢@個例子,假定在check_ping命令定義里使用了一個主機對象,例如這樣:
那么執行這個主機檢測命令時展開并最終執行的將是這樣的:
命令參數宏
同樣你可以向命令傳遞參數,這樣可以保證命令定義更具通用性。參數指定在對象(象主機或服務)中定義,用一個“!”來分隔,例如這樣:
在上例中,服務的檢測命令中含有兩個參數(請參考$ARGn$宏),而$ARG1$宏將是"200.0,80%",同時$ARG2$將是"400.0,40%"(都不帶引號)。假定使用之前的主機定義并這樣來定義你的check_ping命令:
那么對于服務的檢測命令最終將是這樣子的:
?
Nagios可用的全部的宏
主機宏
$HOSTNAME$? 主機簡稱(如"web"),取自于主機定義里的host_name域
$HOSTADDRESS$? 主機地址。取自于主機定義里的address域
服務宏
$SERVICESTATE$ 服務狀態描述,有w,u,c
$SERVICEDESC$?? 對當前服務的描述??
聯系人宏
$CONTACTNAME$?? 表示聯系人,在聯系人文件中定義
通知宏
$NOTIFICATIONTYPE$??? 返回下面信息:("PROBLEM","RECOVERY", "ACKNOWLEDGEMENT", "FLAPPINGSTART","FLAPPINGSTOP", "FLAPPINGDISABLED","DOWNTIMESTART", "DOWNTIMEEND", or"DOWNTIMECANCELLED").
日期/時間宏
$LONGDATETIME$? 當前的日期/時間戳
文件宏
$LOGFILE$? 日志文件的保存位置。
$MAINCONFIGFILE$? 主配置文件的保存位置。
其他宏
$ADMINEMAIL$? 全局的管理員EMail地址
$ARGn$? 指向第n個命令傳遞參數(通知、事件處理、服務檢測等)。Nagios支持最多32個參數宏
?
(4)commands.cfg文件
?此文件默認是存在的,無需修改即可使用,當然如果有新的命令需要加入時,在此文件進行添加即可。這里并未列出文件的所有內容,僅僅介紹了配置中用到的一些命令。?
(5) hosts.cfg文件
?此文件默認不存在,需要手動創建,hosts.cfg主要用來指定被監控的主機地址以及相關屬性信息,一個配置好的實例如下:
(6) services.cfg文件
?此文件默認也不存在,需要手動創建,services.cfg文件主要用于定義監控的服務和主機資源,例如監控http服務、ftp服務、主機磁盤空間、主機系統負載等等。
(7) contacts.cfg文件
?contacts.cfg是一個定義聯系人和聯系人組的配置文件,當監控的主機或者服務出現故障,nagios會通過指定的通知方式(郵件或者短信)將信息發給這里指定的聯系人或者使用者。
(8)timeperiods.cfg文件
?此文件只要用于定義監控的時間段,下面是一個配置好的實例:
(9) cgi.cfg文件
?此文件用來控制相關cgi腳本,如果想在nagios的web監控界面執行cgi腳本,例如重啟nagios進程、關閉nagios通知、停止nagios主機檢測等,這時就需要配置cgi.cfg文件了。
?由于nagios的web監控界面驗證用戶為ixdba,所以只需在cgi.cfg文件中添加此用戶的執行權限就可以了,需要修改的配置信息如下:
(10) nagios.cfg文件
? Nagios.cfg默認的路徑為/usr/local/nagios/etc/nagios.cfg,是nagios的核心配置文件,所有的對象配置文件都必須在這個文件中進行定義才能發揮其作用,這里只需將對象配置文件在Nagios.cfg文件中進行引用即可。
1、驗證Nagios配置文件的正確性
?
? nagios在驗證配置文件方面做的非常到位,只需通過一個命令即可完成:
?
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
?
?Nagios提供的這個驗證功能非常有用,在錯誤信息中通常會打印出錯誤的配置文件以及文件中的哪一行,這使得nagios的配置變得非常容易,報警信息通常是可以忽略的,因為一般那些只是建議性的。
2、 啟動與停止nagios
(1)啟動nagios
在啟動nagios 前 修改/etc/passwd,文件最后nagios:x:501:501::/home/nagios:/sbin/nlogin
?改為
?nagios:x:501:501::/home/nagios:/bin/bash
否則報如下錯誤
?Startingnagios:This account is currently not available.
?done.
?
?修改/etc/cgi.cfg
vi? ? /usr/local/nagios/etc/cgi.cfg
里面有配置
use_authentication=1 ??#把1修改為0,保存
?為了保障系統的安全性,nagios設置了這個參數,默認為1,改為0即可
?通過初始化腳本啟動nagios
/etc/init.d/nagios start
?或者
Service nagios start
? ? ?手工方式啟動nagios
?通過nagios命令的“-d”參數來啟動nagios守護進程:
/usr/local/nagios/bin/nagios -d/usr/local/nagios/etc/nagios.cfg
?
(2)關閉nagios
???通過初始化腳本關閉nagios服務
?/etc/init.d/nagios stop
或者
?Service nagios stop
? ???通過kill方式關閉nagios
?kill <nagios_pid>
2、啟動與停止nagios
???通過初始化腳本來重啟nagios
/etc/rc.d/init.d/nagios reload
/etc/rc.d/init.d/nagios restart
4、 nagios性能分析圖表
?
(1)nagios性能分析圖表的作用
? ??Nagios對服務或主機監控的是一個瞬時狀態,有時候系統管理員如果需要了解主機在一段時間內的性能以及服務的響應狀態,并且形成圖表時,就需要通過查看日志數據來分析,但是這種方式不但繁瑣,而且抽象,不過幸運的是,PNP可以幫助我們來完成這個工作。
?
(2) PNP的概念與安裝環境
? ? ?PNP是一個小巧的開源軟件包,它基于PHP和PERL,PNP可以利用rrdtool工具將Nagios采集的數據繪制成相關的圖表,然后顯示主機或者服務在一段時間內的運行狀況。
?PNP官方網站為:http://www.pnp4nagios.org
?如果要安裝PNP,首先需要安裝如下環境:
?1:整合后的apache和PHP環境,需支持GD、zlib
? 不然當點擊太陽小圖標時,會遇到如下錯誤,
??1 PHP zlib Support not found?
安裝php 時未指定zlib庫,或者是未安裝zlib (whereis zlib 判斷是否安裝了zlib)
2? PHP gd support not found?
?如果 gd庫是rpm安裝的 用參數 --with-gd
在上面安裝PHP 時應該這樣指定
./configure? --prefix=/usr/local/php--with-apxs2=/usr/local/apache2/bin/apxs --with-zlib-dir=/usr/include/zlib.h--with-gd
如果沒有性能分析圖表,就不用參數 --with-zlib-dir? --with-gd
?2:安裝rrdtool工具
?3:安裝perl
?
(3)安裝PNP
?
RRDtool是一個圖表生成工具,可以從http://www.mrtg.org/rrdtool/獲得信息。
?
這里下載的版本是rrdtool-1.4.5.tar.gz,安裝過程如下:
?
[root@nagios rrdtool]# tar zxvf rrdtool-1.4.5.tar.gz??
[root@nagios rrdtool]# cdrrdtool-1.4.5?
[root@nagios rrdtool-1.4.5]# ./configure--prefix=/usr/local/rrdtool?
[root@nagios rrdtool-1.4.5]#make?
[root@nagios rrdtool-1.4.5]# make install?
?
接著安裝PNP,這里下載的版本是pnp-0.4.13.tar.gz,安裝過程如下:
[root@nagios pnp]#tar -xvzfpnp-0.4.13.tar.gz?
[root@nagios pnp]#cd pnp-0.4.13?
[root@nagios 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?
[root@nagios pnp-0.4.13]#make all?
[root@nagios pnp-0.4.13]#make install?
[root@nagios pnp-0.4.13]#make install-config?
[root@nagios pnp-0.4.13]#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/
-------------------------------------------------------------------------
?
(4)設置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 *
② 修改process_perfdata.cfg文件
vi /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模式。
?
(5)修改nagios配置文件
①增加小太陽標示
修改templates.cfg,增加一個定義PNP的hosts和services
define host {
? ? ? ? name ? ? ?hosts-pnp
? ? ? ? register ? 0
? ? ? ? action_url/nagios/pnp/index.php?host=$HOSTNAME$
? ? ? ? process_perf_data ?? ? ? ? ? ? 1
?
}
define service {
? ? ? ? name ? ? ?services-pnp
? ? ? ? register ? 0
? ? ? ? action_url/nagios/pnp/index.php?host=$HOSTNAME$&srv=$SERVICEDESC$
? ? ? ? process_perf_data ?? ? ? ? ? ? 1
?
}
②修改nagios.cfg
找到如下幾項,去掉注釋,修改后信息如下:
process_performance_data=1?
host_perfdata_command=process-host-perfdata?
service_perfdata_command=process-service-perfdata
?
③修改commands.cfg,把文件最后定義的注釋掉,添加如下信息,用process_perfdata.pl讀取host、service信息
?
# '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
}
?
?
④修改hosts.cfg文件和services.cfg文件
?
define host{
? ? ? ? use ? ? ?? ? ? ? ? ? linux-server,hosts-pnp
? ? ? ? host_name ? ?? ? ? ? ? web
? ? ? ? alias ? ? ?? ? ? ? ? ?ixdba-web
? ? ? ? address ? ? ?? ? ? ? ?192.168.12.251
? ? ? ? }
?
define host{
? ? ? ? use ? ? ?? ? ? ? ? ? linux-server,hosts-pnp
? ? ? ? host_name ? ?? ? ? ? ? mysql
? ? ? ? alias ? ? ?? ? ? ? ? ? ixdba-mysql
? ? ? ? address ? ? ?? ? ? ? ? 192.168.12.237
? ? ? ? }
?
define service{
? ? ? ? use ? ? ?? ? ? ? ? ? local-service,services-pnp
? ? ? ? host_name ? ?? ? ? ? ? ? mysql
? ? ? ? service_description ?? ? ? ? SSH
? ? ? ? check_command ? ?? ? ? ? ? check_ssh
? ? ? ? }
define service{
? ? ? ? use ? ? ?? ? ? ? ? local-service,services-pnp
? ? ? ? host_name ? ?? ? ? ? ? ? ? web
? ? ? ? service_description ?? ? ? ? ? http
? ? ? ? check_command ? ?? ? ? ? ? ? check_http
? ? ? ? }
?
(5)測試PNP功能
?
所有配置完成之后,重新檢查nagios配置文件是否正確,然后重啟nagios
/etc/init.d/nagios restart
如果配置正確,此時就會生成響應主機的pnp文件
[root@nagios web]# pwd
/usr/local/nagios/share/perfdata/web
[root@gaojf web]# ls
http.rrd ?http.xml ?PING.rrd ?PING.xml?SSHD.rrd ?SSHD.xml
最后打開網頁:
打開網頁http://IP/nagios,選擇主機選項,然后點擊小太陽就可以看到圖表,或者訪問http://ip/nagios/pnp也可以直接訪問圖表信息。如下圖所示:
?點擊小太陽報錯
Deprecated:Assigning the return value of new by reference is deprecated in /usr/local/nagios/share/pnp/include/function.inc.phpon line 1026
Warning: date() [function.date]:It is not safe to rely on the system's timezone settings. You are *required* touse the date.timezone setting or the date_default_timezone_set() function. Incase you used any of those methods and you are still getting this warning, youmost 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.phpon line 557
Warning: date() [function.date]:It is not safe to rely on the system's timezone settings. You are *required* touse the date.timezone setting or the date_default_timezone_set() function. Incase you used any of those methods and you are still getting this warning, youmost 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.phpon line 559
Warning: date() [function.date]:It is not safe to rely on the system's timezone settings. You are *required* touse the date.timezone setting or the date_default_timezone_set() function. Incase you used any of those methods and you are still getting this warning, youmost 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.phpon line 563
Warning: date() [function.date]:It is not safe to rely on the system's timezone settings. You are *required* touse the date.timezone setting or the date_default_timezone_set() function. Incase you used any of those methods and you are still getting this warning, youmost 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.phpon line 565
Warning: date() [function.date]:It is not safe to rely on the system's timezone settings. You are *required* touse the date.timezone setting or the date_default_timezone_set() function. Incase you used any of those methods and you are still getting this warning, youmost 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.phpon line 563
Warning: date() [function.date]:It is not safe to rely on the system's timezone settings. You are *required* touse the date.timezone setting or the date_default_timezone_set() function. Incase you used any of those methods and you are still getting this warning, youmost 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.phpon line 565
Warning: date() [function.date]:It is not safe to rely on the system's timezone settings. You are *required* touse the date.timezone setting or the date_default_timezone_set() function. Incase you used any of those methods and you are still getting this warning, youmost 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.phpon line 563
Warning: date() [function.date]:It is not safe to rely on the system's timezone settings. You are *required* touse the date.timezone setting or the date_default_timezone_set() function. Incase you used any of those methods and you are still getting this warning, youmost 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.phpon line 565
Warning: date() [function.date]:It is not safe to rely on the system's timezone settings. You are *required* touse the date.timezone setting or the date_default_timezone_set() function. Incase you used any of those methods and you are still getting this warning, youmost 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.phpon line 563
Warning: date() [function.date]:It is not safe to rely on the system's timezone settings. You are *required* touse the date.timezone setting or the date_default_timezone_set() function. Incase you used any of those methods and you are still getting this warning, youmost 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.phpon line 565
Warning: date() [function.date]:It is not safe to rely on the system's timezone settings. You are *required* touse the date.timezone setting or the date_default_timezone_set() function. Incase you used any of those methods and you are still getting this warning, youmost 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.phpon line 563
Warning: date() [function.date]:It is not safe to rely on the system's timezone settings. You are *required* touse the date.timezone setting or the date_default_timezone_set() function. Incase you used any of those methods and you are still getting this warning, youmost 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.phpon line 565
?
?
這是因為pnp-0.4.14對PHP 5.3.2的支持還不是很好,其中有幾個bug需要修改:
根據錯誤提示打開
vi /usr/local/nagios/share/pnp/include/function.inc.php
根據提示找到對應行進行修改,提示1026行錯誤,其他是date錯誤 從557開始
?根據報錯信息 添加
line 556: 添加:date_default_timezone_set('UTC');
line 1026:修改為$pdf = new PDF('P', 'mm', 'A4'); 刪除&
?
改完之后 重啟nagios? 又出現如下錯誤
Deprecated:Function eregi() is deprecated in /usr/local/nagios/share/pnp/include/function.inc.phpon line 1504
Deprecated: Function eregi() is deprecated in /usr/local/nagios/share/pnp/include/function.inc.phpon line 1504
Deprecated: Function eregi() is deprecated in /usr/local/nagios/share/pnp/include/function.inc.phpon line 1504
Deprecated: Function eregi() is deprecated in /usr/local/nagios/share/pnp/include/function.inc.phpon line 1504
Deprecated: Function eregi() is deprecated in /usr/local/nagios/share/pnp/include/function.inc.phpon line 1504
Deprecated: Function eregi() is deprecated in /usr/local/nagios/share/pnp/include/function.inc.phpon line 1504
Deprecated: Function eregi() is deprecated in /usr/local/nagios/share/pnp/include/function.inc.phpon line 1504
Deprecated: Function eregi() is deprecated in /usr/local/nagios/share/pnp/include/function.inc.phpon line 1504
提示eregi()函數有誤??
找到行1504附近修改為
if($level == 2 && $type == "complete" &&preg_match("/^NAGIOS_/",$tag)){
?
再重新重啟nagios,應該就能看到圖表了
?
轉載于:https://www.cnblogs.com/dyllove98/p/3161559.html
總結
以上是生活随笔為你收集整理的Nagios+pnp4nagios+rrdtool 安装配置nagios(一)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: sl启动项设置错误
- 下一篇: Cocos2d-x--Box2D绘制出两