转载自
http://hi.baidu.com/liuxl0305/blog/item/d100da2101248cb74623e8f8.html
准备工作:
安装PHP*
安装 libcgi
tar zxvf cgilib-0.5.tar.gz
cd cgilib-0.5
make
make install
cp libcgi.a /usr/local/lib
cp cgi.h /usr/include
安装zlib libpng freetype libart_lgpl
yum install libart*
yum install freetype
yum install libpng
yum install zlib
安装rrdtool
tar zxvf rrdtool-1.2.6.tar.gz
cd rrdtool-1.2.6
./configure
make
make install
安装pnp
tar zxvf pnp-0.4.14.tar.gz
cd pnp-0.4.14
./configure -- with-rrdtool=/usr/local/rrdtool-1.0.50/bin/rrdtool #这里要制定rrdtool的真实路径
make all
make install
make install-config
make install- init
监控主机设置
①添加apache默认页支持php 格式
vi /etc/httpd/conf/httpd.conf
391 DirectoryIndex index.html index.html.var index.php
②编辑nagios.cfg
vi /usr/local/nagios/etc/nagios.cfg
process_performance_data=1 #改0为1
host_perfdata_command=process-host-perfdata #去掉注释
service_perfdata_command=process-service-perfdata #去掉注释
③修改绘图命令
vim /usr/local/nagios/etc/objects/commands.cfg
将原来command_line后的内容替换
# 'process-host-perfdata' command definition
define command{
command_name process-host-perfdata
command_line /usr/bin/perl /usr/local/nagios/libexec/process_perfdata.pl #这里的process_perfdata.pl要是自己的真实路径
}
# 'process-service-perfdata' command definition
define command{
command_name process-service-perfdata
command_line /usr/bin/perl /usr/local/nagios/libexec/process_perfdata.pl #这里的process_perfdata.pl要是自己的真实路径
}
④修改模板文件templates.cfg
vi /usr/local/nagios/etc/object/templates.cfg
在末尾添加
define host {
name host-pnp
register 0
action_url /nagios/pnp/index.php?host=$HOSTNAME$
}
define service {
name srv-pnp
register 0
action_url /nagios/pnp/index.php?host=$HOSTNAME$&srv=$SERVICEDESC$
}
⑤修改目标主机文件hosts.cfg
添加红色内容
define host {
host_name Oracle-Server-1
alias Oracle Server 1
address 10.1.30.173
check_command check-host-alive
check_interval 5
use linux-server,host-pnp #利用定义的模板文件
action_url /nagios/pnp/index.php?host=$HOSTNAME$
process_perf_data 1
retry_interval 1
max_check_attempts 5
check_period 24x7
process_perf_data 0
retain_nonstatus_information 0
contact_groups sagroup
notification_interval 30
notification_period 24x7
notification_options d,u,r
}
⑥修改服务配置,即需要该服务画图,修改services.cfg
添加红色部分
define service {
host_name Oracle-Server-1
use local-service,srv-pnp
service_description check-load
check_period 24x7
max_check_attempts 4
normal_check_interval 3
retry_check_interval 2
contact_groups sagroup
notification_interval 10
notification_period 24x7
notification_options w,u,c,r
check_command check_nrpe!check_load
process_perf_data 1
}
重启所有服务
apache,nagios等