您好,登錄后才能下訂單哦!
煮酒品茶:好久之前寫的文章,放在論壇里,取出來共享之。
Repost:http://deidara.blog.51cto.com/400447/382129
官方文檔網站:http://docs.pnp4nagios.org/pnp-0.4/start
1.下載安裝 pnp4nagios-0.6.6.tar.gz
wget http://jaist.dl.sourceforge.net/project … .19.tar.gz
yum install rrdtool librrds-perl
tar zxvf pnp4nagios-0.6.6.tar.gz
cd pnp4nagios-0.6.6
./configure --with-nagios-user=nagios --with-nagios-group=nagcmd
make all
make install
make install-webconf
make install-config
make install-init
2.創建配置文件
cd /usr/local/pnp4nagios/etc
mv misccommands.cfg-sample misccommands.cfg
mv nagios.cfg-sample nagios.cfg
mv npcd.cfg-sample npcd.cfg
mv process_perfdata.cfg-sample process_perfdata.cfg
mv rra.cfg-sample rra.cfg
cd pages
mv web_traffic.cfg-sample web_traffic.cfg
cd ../check_commands
mv check_all_local_disks.cfg-sample check_all_local_disks.cfg
mv check_nrpe.cfg-sample check_nrpe.cfg
mv check_nwstat.cfg-sample check_nwstat.cfg
3. 重啟服務
/etc/init.d/npcd restart
4.修改 nagios 的配置文件.打開performance_data
cd /usr/local/nagios/etc
vim nagios.cfg
#打開注視項:
process_performance_data=1
host_perfdata_command=process-host-perfdata
service_perfdata_command=process-service-perfdata
5.編譯 commands.cfg
cd /usr/local/nagios/etc/objects
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頁面上。
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
cd /usr/local/nagios/etc/eric.com
#修改hosts.cfg
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 服務
/etc/init.d/nagios restart
效果圖:
品茶:文章是比較老的版本,所以用新的版本會有不同的點。
環境:
OS centos5.8 64bit
nagios nagios3.5
pnp4nagios pnp4nagios-0.6.19
1、/usr/local/pnp4nagios/share/install.php #此為http://ip/pnp4nagios的監測環境頁面,測試通過就刪除頁install.php文件。
PNP4Nagios Environment Tests
PNP4Nagios Version pnp4nagios-0.6.19
Prefix /usr/local/pnp4nagios
Configure Arguments ./configure '--with-rrdtool=/usr/bin/rrdtool'
RRD Storage /usr/local/pnp4nagios/var/perfdata is readable.
RRDtool Binary /usr/bin/rrdtool is executable by PHP
PHP GD extension Pass
PHP function proc_open() Pass
PHP zlib extension Pass
PHP session extension Pass
PHP JSON extension Pass
PHP magic_quotes_gpc Off
PHP socket extension Pass
Apache Rewrite Module PassPHP Version 5.1.6
System Directory /usr/local/pnp4nagios/lib/kohana/system/
Application Directory /usr/local/pnp4nagios/share/application/
Reflection Enabled Pass
Iconv Extension Loaded Pass
URI Determination PassYour environment passed all requirements. Remove or rename the /usr/local/pnp4nagios/share/install.php file now.
2、在command.cfg文件里,默認是有兩段定義的command_name,所以得先注釋。
# 'process-host-perfdata' command definition
#define command{
# command_name process-host-perfdata
# command_line /usr/bin/printf "%b" "$LASTHOSTCHECK$\t$HOSTNAME$\t$HOSTSTATE$\t$HOSTATTEMPT$\t$HOSTSTATETYPE$\t$HOSTEXECUTIONTIME$\t$HOSTOUTPUT$\t$HOSTPERFDATA$\n" >> /usr/local/nagios/var/host-perfdata.out
# }# 'process-service-perfdata' command definition
#define command{
# command_name process-service-perfdata
# command_line /usr/bin/printf "%b" "$LASTSERVICECHECK$\t$HOSTNAME$\t$SERVICEDESC$\t$SERVICESTATE$\t$SERVICEATTEMPT$\t$SERVICESTATETYPE$\t$SERVICEEXECUTIONTIME$\t$SERVICELATENCY$\t$SERVICEOUTPUT$\t$SERVICEPERFDATA$\n" >> /usr/local/nagios/var/service-perfdata.out
# }
3、在創建默認文件名時,有些文件名是不同的。
[root@KTQT objects]# tree /usr/local/pnp4nagios/etc/
/usr/local/pnp4nagios/etc/
|-- background.pdf
|-- check_commands
| |-- check_all_local_disks.cfg
| |-- check_all_local_disks.cfg-sample
| |-- check_nrpe.cfg
| |-- check_nrpe.cfg-sample
| |-- check_nwstat.cfg
| `-- check_nwstat.cfg-sample
|-- config.d
|-- config.php
|-- config.php.0.6.19
|-- config_local.php
|-- misccommands.cfg
|-- misccommands.cfg-sample
|-- nagios.cfg
|-- nagios.cfg-sample
|-- npcd.cfg
|-- npcd.cfg.0.6.19
|-- npcd.cfg.old
|-- pages
| |-- web_traffic.cfg
| `-- web_traffic.cfg-sample
|-- pnp4nagios_release
|-- process_perfdata.cfg
|-- process_perfdata.cfg.0.6.19
|-- process_perfdata.cfg.old
|-- rra.cfg
`-- rra.cfg-sample3 directories, 25 files
4、依賴于以下組件,并更改源。
http php php-gd nagios rrdtool
[root@cwtea yum.repos.d]# cat dag.repo
[dag]
name=Dag RPM Repository for Red Hat Enterprise Linux
baseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag
gpgcheck=1
gpgkey=http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
enabled=1
[root@cwtea yum.repos.d]# yum install rrdtool php-gd
5、command.cfg文件process-host-perfdata command_line add -d HOSTPERFDATA
error:
define command {
command_name process-service-perfdata
command_line /usr/bin/perl /usr/local/pnp4nagios/libexec/process_perfdata.pl
}define command {
command_name process-host-perfdata
command_line /usr/bin/perl /usr/local/pnp4nagios/libexec/process_perfdata.pl -d HOSTPERFDATA
}
三張圖:
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。