pnp4nagios安裝
nagios 是3.5+
1. 檢查環(huán)境安裝:
rpm -q gcc glibc glibc-common gd gd-devel openssl-devel perl httpd php php-gd xinetd rrdtool perl-Time-HiRes
如果環(huán)境少包,yum安裝
sudo yum install -y gcc glibc glibc-common gd gd-devel xinetd openssl-devel perl httpd php php-gd xinetd rrdtool perl-Time-HiRes
2. 安裝pnp4nagios插件
cd /opt/
wget http://sourceforge.net/projects/pnp4nagios/files/PNP-0.6/pnp4nagios-0.6.25.tar.gz
tar -zxvf pnp4nagios-0.6.25.tar.gz
cd pnp4nagios-0.6.25
sudo ./configure --prefix=/usr/local/pnp4nagios
sudo make all
sudo make install
sudo make install-webconf
sudo make install-config
sudo make install-init
sudo make fullinstall
cd
3. 修改配置文件
-
打開(kāi)數(shù)據(jù)記錄功能
修改nagios.cfg浴栽,修改以下內(nèi)容:
vim /usr/local/nagios/etc/nagios.cfg
process_performance_data=1
host_perfdata_command=process-host-perfdata #取消注釋
service_perfdata_command=process-service-perfdata #取消注釋
-
修改數(shù)據(jù)記錄命令空镜,記錄到pnp4nagios
修改commands.cfg务傲,修改以下內(nèi)容:
vim /usr/local/nagios/etc/objects/commands.cfg
define command{
command_name process-host-perfdata
command_line /usr/local/pnp4nagios/libexec/process_perfdata.pl -d HOSTPERFDATA
}
define command{
command_name process-service-perfdata
command_line /usr/local/pnp4nagios/libexec/process_perfdata.pl
}
-
添加pnp4nagios記錄模板
修改templates.cfg文件舔株,添加以下內(nèi)容 action_url:
vim /usr/local/nagios/etc/objects/templates.cfg
define service{
name generic-service
active_checks_enabled 1
passive_checks_enabled 1
parallelize_check 1
obsess_over_service 1
check_freshness 0
notifications_enabled 1
event_handler_enabled 1
flap_detection_enabled 1
failure_prediction_enabled 1
process_perf_data 1
retain_status_information 1
retain_nonstatus_information 1
is_volatile 0
check_period 24x7
max_check_attempts 3
normal_check_interval 5
retry_check_interval 2
action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$' class='tips' rel='/pnp4nagios/index.php/popup?host=$HOSTNAME$&srv=$SERVICEDESC$
contact_groups admins
notification_options w,u,c,r
notification_interval 60
notification_period 24x7
register 0
}
define host{
name linux-server
use generic-host
check_period 24x7
check_interval 5
retry_interval 1
max_check_attempts 10
check_command check-host-alive
notification_period workhours
notification_interval 120
notification_options d,u,r
process_perf_data 1
action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_' class='tips' rel='/pnp4nagios/index.php/popup?host=$HOSTNAME$&srv=_HOST_
contact_groups admins
register 0
}
4. 后續(xù)權(quán)限修補(bǔ)
- 移除install.php文件
cd /usr/local/pnp4nagios/share
mv install.php install.php_bak
- 添加懸浮tip
cp /opt/pnp4nagios-0.6.25/contrib/ssi/status-header.ssi /usr/local/nagios/share/ssi/
- 修改php訪問(wèn)權(quán)限
sudo chown -R nagios.nagios /var/lib/php
- 修復(fù)nagios權(quán)限
sudo chown -R nagios.nagios /usr/local/pnp4nagios
sudo chown -R nagios.nagios /usr/local/nagios
- 修改pnp4nagios配置文件
vim /etc/httpd/conf.d/pnp4nagios.conf
AuthUserFile /usr/local/nagios/etc/htpasswd #更改成nagios basic認(rèn)證的密鑰文件
5. 重啟服務(wù)
service httpd restart
sevice nagios restart