pnp4nagios安装
nagios 是3.5+
1. 检查环境安装:
rpm -q gcc glibc glibc-common gd gd-devel openssl-devel perl httpd php php-gd xinetd rrdtool perl-Time-HiRes
如果环境少包,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. 修改配置文件
-
打开数据记录功能
修改nagios.cfg,修改以下内容:
vim /usr/local/nagios/etc/nagios.cfg
process_performance_data=1
host_perfdata_command=process-host-perfdata #取消注释
service_perfdata_command=process-service-perfdata #取消注释
-
修改数据记录命令,记录到pnp4nagios
修改commands.cfg,修改以下内容:
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文件,添加以下内容 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. 后续权限修补
- 移除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访问权限
sudo chown -R nagios.nagios /var/lib/php
- 修复nagios权限
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认证的密钥文件
5. 重启服务
service httpd restart
sevice nagios restart