nagios 安裝完了,只有數字輸出監控內容是不是不炫麗呢?是不是想像CACTI 一樣出炫麗的圖呢?那你可以選擇PNP,他可以滿足你的需求,只要你的指令碼符合perfdata規則,那麼rrdtool就可以出資料,PNP就可以用圖給你畫出來。

1.下載安裝 pnp4nagios-0.6.6.tar.gz

nagios $> wget http://cdnetworks-kr-1.dl.sourceforge.net/project/pnp4nagios/PNP-0.6/pnp4nagios-0.6.6.tar.gz

nagios $> apt-get install rrdtool librrds-perl
nagios $> tar zxvf  pnp4nagios-0.6.6.tar.gz
nagios $> cd pnp4nagios-0.6.6
nagios $> ./configure --with-nagios-user=nagios --with-nagios-group=nagcmd
nagios $> make all
nagios $> make install
nagios $> make install-webconf
nagios $> make install-config
nagios $> make install-init

2.建立配置檔案

nagios $> cd /usr/local/pnp4nagios/etc
nagios $> mv misccommands.cfg-sample  misccommands.cfg
nagios $> mv nagios.cfg-sample  nagios.cfg
nagios $> mv npcd.cfg-sample npcd.cfg
nagios $> mv process_perfdata.cfg-sample  process_perfdata.cfg
nagios $> mv rra.cfg-sample rra.cfg

nagios $>  cd pages
nagios $> mv web_traffic.cfg-sample web_traffic.cfg

nagios $> cd ../check_commands
nagios $> mv check_all_local_disks.cfg-sample  check_all_local_disks.cfg
nagios $> mv check_nrpe.cfg-sample  check_nrpe.cfg
nagios $> mv check_nwstat.cfg-sample  check_nwstat.cfg

3. 重啟服務

nagios $> /etc/init.d/npcd restart

4.修改 nagios 的配置檔案.開啟performance_data

nagios $> cd /usr/local/nagios/etc
nagios $> vim nagios.cfg
#開啟注視項:
process_performance_data=1
host_perfdata_command=process-host-perfdata
service_perfdata_command=process-service-perfdata

5.修改 commands.cfg

nagios $> cd /usr/local/nagios/etc/objects
nagios $> vim commands.cfg
##新增
# `process-host-perfdata` command definition
define command{
        command_name    process-host-perfdata
        command_line    /usr/local/pnp4nagios/libexec/process_perfdata.pl
        }
# `process-service-perfdata` command definition
define command{
        command_name    process-service-perfdata
        command_line    /usr/local/pnp4nagios/libexec/process_perfdata.pl
        }

6. 新增小太陽模版,鑲嵌在nagios頁面上。

nagios $> vim templates.cfg
## 在最後新增
define host {
name       host-pnp
action_url /pnp4nagios/graph?host=$HOSTNAME$&srv=_HOST_
register   0
}
define service {
name       srv-pnp
action_url /pnp4nagios/graph?host=$HOSTNAME$&srv=$SERVICEDESC$
register   0
}

7,修改 hosts.cfg 和  色services.cfg

nagios $> cd /usr/local/nagios/etc/eric.com
#修改hosts.cfg
nagios $> vim hosts.cfg
define host{
        use                     linux-server,host-pnp  
        host_name         eric.com
        alias                     eric.com
        address                 192.168.6.101
        }

# 修改 services.cfg
define service{
        use                                     local-service,srv-pnp      
        host_name                       eric.com
        service_description        PING
        check_command            check_ping!100.0,20%!500.0,60%
}

8.重啟 nagios 服務

nagios $> /etc/init.d/nagios restart

效果圖:
pnp圖