⑴安裝完nagios,繼續安裝pnp,要注意rrdtool的安裝。
tar -xvzf pnp-0.4.13.tar.gz
cd pnp-0.4.13
./configure
make all
make install
make install-config
make install-init
---------------------------------------------------------------------------------
FAQ:
*** 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/local/bin/rrdtool (Version 1.2.23)
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/
-----------------------------------------
process_perfdata.pl 安裝在 /usr/local/nagios/share/
配置示例檔案安裝在/usr/local/nagios/libexecs
config.php安裝于/usr/local/nagios/etc/pnp
<a></a>
⑵修改配置檔案
①
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 *
②
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模式
③
修改etc/objects/templates.cfg增加新指令(增加小太陽标記)
#在use的後面添加"host-pnp"即可讓監控圖上的主機名稱旁邊增加一個小太陽的标記,點選此标記即可檢視pnp圖檔。
define host {
name host-pnp
register 0
action_url /nagios/pnp/index.php?host=$HOSTNAME$
process_perf_data 1
}
#還可以在service欄添加srv-pnp,添加後會在相應的欄内增加小太陽。
define service {
name srv-pnp
action_url /nagios/pnp/index.php?host=$HOSTNAME$&srv=$SERVICEDESC$
④
修改etc/nagios.cfg
找到如下幾項,去掉注釋
process_performance_data=1
host_perfdata_command=process-host-perfdata
service_perfdata_command=process-service-perfdata
⑤
修改commands.cfg
# '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
command_name process-service-perfdata
⑥nginx下的安全問題,需作如下配置
修改pnp的web伺服器配置檔案nginx.conf,請注意安全問題,我這裡未做安全驗證。
location /pnp/ {
root /usr/local/nagios/share/;
location ~ .*/.php?$
{
#fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fcgi.conf;
}
如果開啟了open_basedir還需修改php.ini
open_basedir =
"/opt/htdoc:/opt/php/lib/php:/tmp/session:/tmp/upload:/usr/local/nagios/share/pnp:/usr/local/nagios/etc/pnp:/usr/local/nagios/share/perfdata:/usr/local/rrdtool/bin/rrdtool
㈢測試:
為localhost這台主機在主機圖示旁邊添加個小太陽标記
vi /usr/local/nagios/etc/nagios.cfg
#為這個主機增加小太陽标記
define host{
use linux-server,host-pnp
host_name localhost
alias localhost
address 127.0.0.1
}
#重新加載配置檔案
service nagios reload
如果正确此時就會生成pnp檔案
[root@localhost ~]# ls /usr/local/nagios/share/perfdata/localhost/
Current_Load.rrd Current_Users.xml PING.rrd Root_Partition.xml
Current_Load.xml HTTP.rrd PING.xml Swap_Usage.rrd
Current_Users.rrd HTTP.xml Root_Partition.rrd Swap_Usage.xml
打開網頁http://localhost/nagios
點選小太陽就可以看到圖表,同通路http://localhost/nagios/pnp
<a href="http://blog.appleandroid.com/attachment.php?fid=59"></a>
<a href="http://blog.appleandroid.com/attachment.php?fid=60"></a>
FAQ: 注意可能提示這個子產品沒有安裝:
Time/HiRes.pm子產品的安裝:
①執行以下指令安裝該子產品。
#perl -MCPAN -e 'install Time::HiRes'
或安裝Time-HiRes-1.9707.tar.gz
②如果打開pnp頁面提示Hostname is not set,則檢查etc/pnp/裡的sample檔案都更改正确,檢查templates.cfg檔案中url的正确性,還不行就等等,别太心急了,裝完沒那麼快出圖。