您好,登錄后才能下訂單哦!
官網地址:https://docs.pnp4nagios.org/
前面的文章已經說過,pnp4nagios的Broker模式不支持nagios4x,這里采用Bulk Mode模式
1.RRDtool的安裝,這里使用的是yum安裝
#yum install -y rrdtool*
2.pnp4nagios安裝
#tar -zxvf pnp4nagios-0.6.25.tar.gz
#cd pnp4nagios-0.6.25
#./configure --with-rrdtool=/usr/bin/rrdtool --with-perfdata-dir=/usr/local/nagios/share/perfdata --with-perfdata-spool-dir=/usr/local/nagios/share/spool --with-nagios-user=nagios --with-nagios-group=nagios
#make all
#make install
#make install-config
#make install-init
3.pnp4nagios配置
cd /usr/local/pnp4nagios/etc
mv misccommands.cfg-sample misccommands.cfg
mv nagios.cfg-sample nagios.cfg
mv rra.cfg-sample rra.cfg
cd /usr/local/pnp4nagios/etc/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
#重啟服務
#service npcd restart
4.修改相關配置文件
(1)修改templates.cfg,增加一個定義PNP的host和service
define host {
name host-pnp
register 0
action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_' class='tips' rel='/pnp4nagios/index.php/popup?host=$HOSTNAME$&srv=_HOST_
process_perf_data 1
}
define service {
name srv-pnp
register 0
action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$' class='tips' rel='/pnp4nagios/index.php/popup?host=$HOSTNAME$&srv=$SERVICEDESC$
process_perf_data 1
}
(2)修改nagios.cfg
process_performance_data=1
enable_environment_macros=1
host_perfdata_file=/usr/local/pnp4nagios/var/host-perfdata
service_perfdata_file=/usr/local/pnp4nagios/var/service-perfdata
host_perfdata_file_template=DATATYPE::HOSTPERFDATA\tTIMET::$TIMET$\tHOSTNAME::$HOSTNAME$\tHOSTPERFDATA::$HOSTPERFDATA$\tHOSTCHECKCOMMAND::$HOSTCHECKCOMMAND$\tHOSTSTATE::$HOSTSTATE$\tHOSTSTATETYPE::$HOSTSTATETYPE$
service_perfdata_file_template=DATATYPE::SERVICEPERFDATA\tTIMET::$TIMET$\tHOSTNAME::$HOSTNAME$\tSERVICEDESC::$SERVICEDESC$\tSERVICEPERFDATA::$SERVICEPERFDATA$\tSERVICECHECKCOMMAND::$SERVICECHECKCOMMAND$\tHOSTSTATE::$HOSTSTATE$\tHOSTSTATETYPE::$HOSTSTATETYPE$\tSERVICESTATE::$SERVICESTATE$\tSERVICESTATETYPE::$SERVICESTATETYPE$\tSERVICEOUTPUT::$SERVICEOUTPUT$
host_perfdata_file_mode=a
service_perfdata_file_mode=a
host_perfdata_file_processing_interval=15
service_perfdata_file_processing_interval=15
host_perfdata_file_processing_command=process-host-perfdata-file
service_perfdata_file_processing_command=process-service-perfdata-file
(3)修改commands.cfg
增加如下配置
define command{
command_name process-service-perfdata-file
command_line /usr/local/pnp4nagios/libexec/process_perfdata.pl --bulk=/usr/local/pnp4nagios/var/service-perfdata
}
define command{
command_name process-host-perfdata-file
command_line /usr/local/pnp4nagios/libexec/process_perfdata.pl --bulk=/usr/local/pnp4nagios/var/host-perfdata
}
(4)修改host和service的模版
define host{
name gchost
use host-pnp
max_check_attempts 1
normal_check_interval 2
retry_check_interval 1
check_period 24x7
contact_groups myself_group
notification_interval 2
notification_period 24x7
notification_options d,u,r
check_command check-host-alive
}
define service{
name myself_temp
use srv-pnp
max_check_attempts 2
normal_check_interval 2
retry_check_interval 1
check_period 24x7
notification_interval 2
notification_period 24x7
notification_options w,u,c,r
contact_groups myself_group
check_command check-host-alive
register 0
}
(5)apache配置
#vim /etc/httpd/conf/httpd.conf
Alias /pnp4nagios "/usr/local/pnp4nagios/share"
<Directory "/usr/local/pnp4nagios/share">
AllowOverride None
Order allow,deny
Allow from all
#
# Use the same value as defined in nagios.conf
#
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user
<IfModule mod_rewrite.c>
#Turn on URL rewriting
RewriteEngine On
Options symLinksIfOwnerMatch
#Installation directory
RewriteBase /pnp4nagios/
#Protect application and system files from being viewed
RewriteRule "^(?:application|modules|system)/" - [F]
#Allow any files or directories that exist to be displayed directly
RewriteCond "%{REQUEST_FILENAME}" !-f
RewriteCond "%{REQUEST_FILENAME}" !-d
#Rewrite all other URLs to index.php/URL
RewriteRule "^.*$" "index.php/$0" [PT]
</IfModule>
</Directory>
(6)復制鼠標懸停圖標顯示
cp /usr/local/src/pnp4nagios-0.6.25/contrib/ssi/* /usr/local/nagios/share/ssi/
到這里就可以檢測nagios配置文件無誤后重啟nagios觀看效果
#/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
#/etc/init.d/nagios restart
#/etc/init.d/httpd restart
附上nagios啟動之后可能會遇到的問題以及解決辦法以供參考
1.點擊圖標按鈕如果出現如下提示,執行
#rm -rf /usr/local/pnp4nagios/share/install.php
2.點擊圖標按鈕如果出現如下提示,執行
#chown -R tong:tong /var/lib/php
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。