nagios+plugin+NRPE+PNP快速安装指南
1、准备
安装如下包
sudo apt-get install apache2
sudo apt-get install build-essential
sudo apt-get install libgd2-dev(这个包可能名称有修改)
sudo apt-get install build-essential
sudo apt-get install libgd2-dev(这个包可能名称有修改)
2、安装
(1)建立一个帐号
/usr/sbin/useradd nagios
passwd nagios
在Ubuntu服务器版(6.01或更高版本),创建一个用户组名为nagios(默认是不创建的)。在Ubuntu桌面版上要跳过这一步。
passwd nagios
在Ubuntu服务器版(6.01或更高版本),创建一个用户组名为nagios(默认是不创建的)。在Ubuntu桌面版上要跳过这一步。
/usr/sbin/groupadd nagios
/usr/sbin/usermod -G nagios nagios
创建一个用户组名为nagcmd用于从Web接口执行外部命令。将nagios用户和apache用户都加到这个组中。
/usr/sbin/usermod -G nagios nagios
创建一个用户组名为nagcmd用于从Web接口执行外部命令。将nagios用户和apache用户都加到这个组中。
/usr/sbin/groupadd nagcmd
/usr/sbin/usermod -G nagcmd nagios
/usr/sbin/usermod -G nagcmd www-data
/usr/sbin/usermod -G nagcmd nagios
/usr/sbin/usermod -G nagcmd www-data
(2)下载Nagios和插件程序包
建立一个目录用以存储下载文件
下载Nagios和Nagios插件的软件包
(3)编译与安装Nagios
展开Nagios源程序包
tar xzf nagios-3.0rc1.tar.gz
cd nagios-3.0rc1
cd nagios-3.0rc1
运行Nagios配置脚本并使用先前开设的用户及用户组:
./configure --with-command-group=nagcmd
编译Nagios程序包源码
make all
安装二进制运行程序、初始化脚本、配置文件样本并设置运行目录权限
make install
make install-init
make install-config
make install-commandmode
make install-init
make install-config
make install-commandmode
现在还不能启动Nagios-还有一些要做的...
(4)客户化配置
样例配置文件默认安装在这个目录下/usr/local/nagios/etc,这些样例文件可以配置Nagios使之正常运行,只需要做一个简单的修改...
用你擅长的编辑器软件来编辑这个/usr/local/nagios/etc/objects/contacts.cfg配置文件,更改email地址nagiosadmin的联系人定义信息中的EMail信息为你的EMail信息以接收报警内容。
vi /usr/local/nagios/etc/objects/contacts.cfg
(5)配置WEB接口
安装Nagios的WEB配置文件到Apache的conf.d目录下
make install-webconf
(如果出现错误,是因为apache2的配置文件路径已经修改,解决办法:
手动执行:/usr/bin/install -c -m 644 sample-config/httpd.conf /你etc下apache配置文件夹/nagios.conf
然后修改apache配置文件,添加Include conf/conf.d/*.conf)
创建一个nagiosadmin的用户用于Nagios的WEB接口登录。记下你所设置的登录口令,一会儿你会用到它。
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
重启Apache服务以使设置生效。
/etc/init.d/apache2 reload
3、排错
(1)如果在看弯路拓扑时出现以下问题,是因为没有生成statusmap.cgi等文件;
The requested URL /nagios/cgi-bin/statusmap.cgi was not found on this server
解决方案,确定安装下面的包。
libgd
libgd-devel
libpng
libpng-devel
libjpeg
libjpeg-devel
zlib
zlib-devel
libgd-devel
libpng
libpng-devel
libjpeg
libjpeg-devel
zlib
zlib-devel
回到nagios安装时解压开的目录
#make devclean
# ./configure --with-gd-lib=/usr/lib --with-gd-inc=/usr/include
接下来
#./configure --with-command-group=nagcmdnext
#make all; make install; make install-init; make install-config; make install-commandmode; make install-webconf
重新回到你的nagios的sbin目录查看几个cgi脚本有没有生成。
(2)网页上看不到3Dmap链接的时候
在/usr/local/nagios/share/site.php中,手动加入:
<li><a href="<?php echo $cfg["cgi_base_url"];?>/statuswrl.cgi" target="<?php echo $link_target;?>">3D拓扑图</a></li>
<li><a href="<?php echo $cfg["cgi_base_url"];?>/statuswrl.cgi" target="<?php echo $link_target;?>">3D拓扑图</a></li>
4、编译并安装Nagios插件
(1)展开Nagios插件的源程序包
tar xzf nagios-plugins-1.4.11.tar.gz
cd nagios-plugins-1.4.11
cd nagios-plugins-1.4.11
(2)编译并安装插件
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make all
make install
make all
make install
(3)启动Nagios
把Nagios加入到服务列表中以使之在系统启动时自动启动
ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios
验证Nagios的样例配置文件
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
如果没有报错,可以启动Nagios服务
/etc/init.d/nagios start
(4)登录WEB接口
你现在可以从WEB方式来接入Nagios的WEB接口了,你需要在提示下输入你的用户名(nagiosadmin)和口令,你刚刚设置的,这里用系统默认安装的浏览器,用下面这个超链接
(5)再次排错
缺乏check_snmp插件时
源安装 libnet-snmp-perl,libsnmp15,libsnmp-base,libsnmp-dev,libsnmp-perl,snmp
再执行一次前面插件安装的步骤;
如果出现
check_http.o(.text+0x120b):/home/machielr/nagios-plugins-1.4.13/plugins/check_http.c:789: undefined reference to `np_net_ssl_read'
check_http.o(.text+0x12bd):/home/machielr/nagios-plugins-1.4.13/plugins/check_http.c:828: undefined reference to `np_net_ssl_cleanup'
check_http.o(.text+0x14f4):/home/machielr/nagios-plugins-1.4.13/plugins/check_http.c:734: undefined reference to `np_net_ssl_init'
check_http.o(.text+0x1513):/home/machielr/nagios-plugins-1.4.13/plugins/check_http.c:736: undefined reference to `np_net_ssl_check_cert'
check_http.o(.text+0x151a):/home/machielr/nagios-plugins-1.4.13/plugins/check_http.c:737: undefined reference to `np_net_ssl_cleanup'
等错误
check_http.o(.text+0x120b):/home/machielr/nagios-plugins-1.4.13/plugins/check_http.c:789: undefined reference to `np_net_ssl_read'
check_http.o(.text+0x12bd):/home/machielr/nagios-plugins-1.4.13/plugins/check_http.c:828: undefined reference to `np_net_ssl_cleanup'
check_http.o(.text+0x14f4):/home/machielr/nagios-plugins-1.4.13/plugins/check_http.c:734: undefined reference to `np_net_ssl_init'
check_http.o(.text+0x1513):/home/machielr/nagios-plugins-1.4.13/plugins/check_http.c:736: undefined reference to `np_net_ssl_check_cert'
check_http.o(.text+0x151a):/home/machielr/nagios-plugins-1.4.13/plugins/check_http.c:737: undefined reference to `np_net_ssl_cleanup'
等错误
解决方法:
查一下这个包有没有装 libssl-dev ,要是有装在做下面的步骤。
在 Make 出错后,用make distclean 在重新Configure 在Make all 一切正常了。
查一下这个包有没有装 libssl-dev ,要是有装在做下面的步骤。
在 Make 出错后,用make distclean 在重新Configure 在Make all 一切正常了。
5、安装nrpe
(1)解压缩
tar -zxvf nrpe-2.8.1.tar.gz
cd nrpe-2.8.1
tar -zxvf nrpe-2.8.1.tar.gz
cd nrpe-2.8.1
(2)编译
./configure
./configure
输出如下
*** Configuration summary for nrpe 2.8.1 05-10-2007 ***:
General Options:
-------------------------
NRPE port: 5666
NRPE user: nagios
NRPE group: nagios
Nagios user: nagios
Nagios group: nagios
Review the options above for accuracy. If they look okay,
type 'make all' to compile the NRPE daemon and client.
*** Configuration summary for nrpe 2.8.1 05-10-2007 ***:
General Options:
-------------------------
NRPE port: 5666
NRPE user: nagios
NRPE group: nagios
Nagios user: nagios
Nagios group: nagios
Review the options above for accuracy. If they look okay,
type 'make all' to compile the NRPE daemon and client.
可以看到NRPE的端口是5666
(3)下一步是make all
make all
输出如下
*** Compile finished ***
If the NRPE daemon and client compiled without any errors, you
can continue with the installation or upgrade process.
Read the PDF documentation (NRPE.pdf) for information on the next
steps you should take to complete the installation or upgrade.
输出如下
*** Compile finished ***
If the NRPE daemon and client compiled without any errors, you
can continue with the installation or upgrade process.
Read the PDF documentation (NRPE.pdf) for information on the next
steps you should take to complete the installation or upgrade.
(4)接下来安装NPRE插件,daemon和示例配置文件
安装check_nrpe这个插件
make install-plugin
之前说过监控机需要安装check_nrpe这个插件,被监控机并不需要,我们在这里安装它是为了测试的目的
安装check_nrpe这个插件
make install-plugin
之前说过监控机需要安装check_nrpe这个插件,被监控机并不需要,我们在这里安装它是为了测试的目的
安装deamon
make install-daemon
make install-daemon
安装配置文件
make install-daemon-config
make install-daemon-config
(5)安装xinetd脚本
按照安装文档的说明,是将NRPE deamon作为xinetd下的一个服务运行的.在这样的情况下xinetd就必须要先安装好,不过一般系统已经默认装了
[root@dbpi nrpe-2.8.1]# make install-xinetd
输出如下
/usr/bin/install -c -m 644 sample-config/nrpe.xinetd /etc/xinetd.d/nrpe
[root@dbpi nrpe-2.8.1]# make install-xinetd
输出如下
/usr/bin/install -c -m 644 sample-config/nrpe.xinetd /etc/xinetd.d/nrpe
可以看到创建了这个文件/etc/xinetd.d/nrpe
编辑这个脚本
vi /etc/xinetd.d/nrpe
# default: on
# description: NRPE (Nagios Remote Plugin Executor)
service nrpe
{
flags = REUSE
socket_type = stream
port = 5666
wait = no
user = nagios
group = nagios
server = /usr/local/nagios/bin/nrpe
server_args = -c /usr/local/nagios/etc/nrpe.cfg --inetd
log_on_failure += USERID
disable = no
only_from = 127.0.0.1在后面增加监控主机的地址0.111,以空格间隔
}
vi /etc/xinetd.d/nrpe
# default: on
# description: NRPE (Nagios Remote Plugin Executor)
service nrpe
{
flags = REUSE
socket_type = stream
port = 5666
wait = no
user = nagios
group = nagios
server = /usr/local/nagios/bin/nrpe
server_args = -c /usr/local/nagios/etc/nrpe.cfg --inetd
log_on_failure += USERID
disable = no
only_from = 127.0.0.1在后面增加监控主机的地址0.111,以空格间隔
}
改后
only_from = 127.0.0.1 192.168.0.111
only_from = 127.0.0.1 192.168.0.111
(6)编辑/etc/services文件,增加NRPE服务
vi /etc/services
增加如下
# Local services
nrpe 5666/tcp # nrpe
增加如下
# Local services
nrpe 5666/tcp # nrpe
重启xinetd服务
[root@dbpi nrpe-2.8.1]# service xinetd restart
Stopping xinetd: [ OK ]
Starting xinetd: [ OK ]
[root@dbpi nrpe-2.8.1]# service xinetd restart
Stopping xinetd: [ OK ]
Starting xinetd: [ OK ]
(7)查看NRPE是否已经启动
[root@dbpi nrpe-2.8.1]# netstat -at|grep nrpe
tcp 0 0 *:nrpe *:* LISTEN
[root@dbpi nrpe-2.8.1]# netstat -an|grep 5666
tcp 0 0 0.0.0.0:5666 0.0.0.0:* LISTEN
可以看到5666端口已经在监听了
[root@dbpi nrpe-2.8.1]# netstat -at|grep nrpe
tcp 0 0 *:nrpe *:* LISTEN
[root@dbpi nrpe-2.8.1]# netstat -an|grep 5666
tcp 0 0 0.0.0.0:5666 0.0.0.0:* LISTEN
可以看到5666端口已经在监听了
(8)测试NRPE是否则正常工作
之前我们在安装了check_nrpe这个插件用于测试,现在就是用的时候.执行
/usr/local/nagios/libexec/check_nrpe -H localhost
会返回当前NRPE的版本
[root@dbpi nrpe-2.8.1]# /usr/local/nagios/libexec/check_nrpe -H localhost
NRPE v2.8.1
之前我们在安装了check_nrpe这个插件用于测试,现在就是用的时候.执行
/usr/local/nagios/libexec/check_nrpe -H localhost
会返回当前NRPE的版本
[root@dbpi nrpe-2.8.1]# /usr/local/nagios/libexec/check_nrpe -H localhost
NRPE v2.8.1
也就是在本地用check_nrpe连接nrpe daemon是正常的
注:为了后面工作的顺利进行,注意本地防火墙要打开5666能让外部的监控机访问
注:为了后面工作的顺利进行,注意本地防火墙要打开5666能让外部的监控机访问
(9)查看NRPE的监控命令
cd /usr/local/nagios/etc
vi nrpe.cfg
找到下面这段话
# The following examples use hardcoded command arguments...
command[check_users]=/usr/local/nagios/libexec/check_users -w 5 -c 10
command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20
command[check_hda1]=/usr/local/nagios/libexec/check_disk -w 20 -c 10 -p /dev/hda1
command[check_zombie_procs]=/usr/local/nagios/libexec/check_procs -w 5 -c 10 -s Z
command[check_total_procs]=/usr/local/nagios/libexec/check_procs -w 150 -c 200
cd /usr/local/nagios/etc
vi nrpe.cfg
找到下面这段话
# The following examples use hardcoded command arguments...
command[check_users]=/usr/local/nagios/libexec/check_users -w 5 -c 10
command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20
command[check_hda1]=/usr/local/nagios/libexec/check_disk -w 20 -c 10 -p /dev/hda1
command[check_zombie_procs]=/usr/local/nagios/libexec/check_procs -w 5 -c 10 -s Z
command[check_total_procs]=/usr/local/nagios/libexec/check_procs -w 150 -c 200
[]部分是命令名,也就是check_nrpe 的-c参数可以接的内容,等号=后面是实际执行的插件程序(这与commands.cfg中定义命令的形式十分相似,只不过是写在了一行).也就是说check_users就是等号后面/usr/local/nagios/libexec/check_users -w 5 -c 10的简称.
(10)在commands.cfg中增加对check_nrpe的定义
vi /usr/local/nagios/etc/commands.cfg
在最后面增加如下内容
########################################################################
#
# 2007.9.5 add by yahoon
# NRPE COMMAND
#
########################################################################
# 'check_nrpe ' command definition
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
vi /usr/local/nagios/etc/commands.cfg
在最后面增加如下内容
########################################################################
#
# 2007.9.5 add by yahoon
# NRPE COMMAND
#
########################################################################
# 'check_nrpe ' command definition
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
下面就可以在localhosts.cfg中定义对NAGIOS主机cpu负载的监控
define service{
use local-service
host_name NAGIOS
service_description SYSTEMLOAD
check_command check_nrpe!check_load
}
use local-service
host_name NAGIOS
service_description SYSTEMLOAD
check_command check_nrpe!check_load
}
(11)添加新的监控指令
在被监控机上增加check_swap命令的定义
vi /usr/local/nagios/etc/nrpe.cfg
增加下面这一行
command[check_swap]=/usr/local/nagios/libexec/check_swap -w 20% -c 10%
在被监控机上增加check_swap命令的定义
vi /usr/local/nagios/etc/nrpe.cfg
增加下面这一行
command[check_swap]=/usr/local/nagios/libexec/check_swap -w 20% -c 10%
我们知道check_swap现在就可以作为check_nrpe的-c的参数使用了
修改了配置文件,当然要重启.但是
如果你是以独立的daemon运行的nrpe,那么需要手动重启.
如果你是在xinetd或者inetd下面运行的,则不需要.
由于我们是xinetd下运行的,所以不需要重启服务
修改了配置文件,当然要重启.但是
如果你是以独立的daemon运行的nrpe,那么需要手动重启.
如果你是在xinetd或者inetd下面运行的,则不需要.
由于我们是xinetd下运行的,所以不需要重启服务
define service{
use local-service
host_name NAGIOS
service_description SYSTEMSWAP
check_command check_nrpe!check_swap
}
use local-service
host_name NAGIOS
service_description SYSTEMSWAP
check_command check_nrpe!check_swap
}
6、安装pnp
(1)依赖需求
Perl >= 5.x
RRDtool >= 1.x
PHP >= 4.3.8
zlib
GD
php-gd
Nagios 2.x以上版本
PNP-0.4.13
RRDtool >= 1.x
PHP >= 4.3.8
zlib
GD
php-gd
Nagios 2.x以上版本
PNP-0.4.13
(2)安装过程
#tar zxvf ../pnp-0.4.13.tar.gz
#cd pnp-0.4.13
#./configure
注: 这一步注意检查gd的相关软件是否都检测到了,如没有需要手动安装。最后,检查pnp的相关全部配置,全部没问题了再进行下一步安装
#tar zxvf ../pnp-0.4.13.tar.gz
#cd pnp-0.4.13
#./configure
注: 这一步注意检查gd的相关软件是否都检测到了,如没有需要手动安装。最后,检查pnp的相关全部配置,全部没问题了再进行下一步安装
*** Configuration summary for pnp 0.4.13 02-19-2009 ***
General Options:
------------------------- -------------------
Nagios user/group: nagios nagios
Install directory: /usr/local/nagios
HTML Dir: /usr/local/nagios/share/pnp
Config Dir: /usr/local/nagios/etc/pnp
Path to rrdtool: /usr/bin/rrdtool (Version 1.2.23)
RRDs Perl Modules: FOUND (Version 1.2023)
RRD Files stored in: /usr/local/nagios/share/perfdata
process_perfdata.pl Logfile: /usr/local/nagios/var/perfdata.log
Perfdata files (NPCD) stored in: /usr/local/nagios/var/spool/perfdata/
------------------------- -------------------
Nagios user/group: nagios nagios
Install directory: /usr/local/nagios
HTML Dir: /usr/local/nagios/share/pnp
Config Dir: /usr/local/nagios/etc/pnp
Path to rrdtool: /usr/bin/rrdtool (Version 1.2.23)
RRDs Perl Modules: FOUND (Version 1.2023)
RRD Files stored in: /usr/local/nagios/share/perfdata
process_perfdata.pl Logfile: /usr/local/nagios/var/perfdata.log
Perfdata files (NPCD) stored in: /usr/local/nagios/var/spool/perfdata/
#make all
#make install
#make install-config
#make install-init
#make install
#make install-config
#make install-init
(3)配置Nagios使用Bulk Mode来收集Perfdata
为什么要使用Bulk Mode?
Bulk mode is a bit more complicated than the default-mode but reduces the load on the nagios server significantly because the data collector process_perfdata.pl is not invoked for every service.
关于Perfdata的收集模式可以参考这里
为什么要使用Bulk Mode?
Bulk mode is a bit more complicated than the default-mode but reduces the load on the nagios server significantly because the data collector process_perfdata.pl is not invoked for every service.
关于Perfdata的收集模式可以参考这里
配置方法
修改nagios.cfg
#修改此项值为1
process_performance_data=1
修改nagios.cfg
#修改此项值为1
process_performance_data=1
#增加以下配置
#
# service performance data
#
service_perfdata_file=/usr/local/nagios/var/service-perfdata
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$
service_perfdata_file_mode=a
service_perfdata_file_processing_interval=15
service_perfdata_file_processing_command=process-service-perfdata-file
#
# service performance data
#
service_perfdata_file=/usr/local/nagios/var/service-perfdata
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$
service_perfdata_file_mode=a
service_perfdata_file_processing_interval=15
service_perfdata_file_processing_command=process-service-perfdata-file
#
# host performance data starting with Nagios 3.0
#
host_perfdata_file=/usr/local/nagios/var/host-perfdata
host_perfdata_file_template=DATATYPE::HOSTPERFDATA\tTIMET::$TIMET$\tHOSTNAME::$HOSTNAME$\tHOSTPERFDATA::$HOSTPERFDATA$\tHOSTCHECKCOMMAND::$HOSTCHECKCOMMAND$\tHOSTSTATE::$HOSTSTATE$\tHOSTSTATETYPE::$HOSTSTATETYPE$\tHOSTOUTPUT::$HOSTOUTPUT$
host_perfdata_file_mode=a
host_perfdata_file_processing_interval=15
host_perfdata_file_processing_command=process-host-perfdata-file
# host performance data starting with Nagios 3.0
#
host_perfdata_file=/usr/local/nagios/var/host-perfdata
host_perfdata_file_template=DATATYPE::HOSTPERFDATA\tTIMET::$TIMET$\tHOSTNAME::$HOSTNAME$\tHOSTPERFDATA::$HOSTPERFDATA$\tHOSTCHECKCOMMAND::$HOSTCHECKCOMMAND$\tHOSTSTATE::$HOSTSTATE$\tHOSTSTATETYPE::$HOSTSTATETYPE$\tHOSTOUTPUT::$HOSTOUTPUT$
host_perfdata_file_mode=a
host_perfdata_file_processing_interval=15
host_perfdata_file_processing_command=process-host-perfdata-file
配置解释
service/host_perfdata_file 包含performance data的临时文件存放路径
service/host_perfdata_file_template 临时文件的格式。使用nagios宏来定义数据
service/host_perfdata_file_mode a指定数据追加记录到文件中
service/host_perfdata_file_processing_interval 每15秒执行一次
service/host_perfdata_file_processing_command 执行时调用的命令
service/host_perfdata_file 包含performance data的临时文件存放路径
service/host_perfdata_file_template 临时文件的格式。使用nagios宏来定义数据
service/host_perfdata_file_mode a指定数据追加记录到文件中
service/host_perfdata_file_processing_interval 每15秒执行一次
service/host_perfdata_file_processing_command 执行时调用的命令
(4)编辑commands.cfg,增加对process-service/host-perfdata-file命令的定义
define command{
command_name process-service-perfdata-file
command_line $USER1$/process_perfdata.pl --bulk=/usr/local/nagios/var/service-perfdata
}
command_name process-service-perfdata-file
command_line $USER1$/process_perfdata.pl --bulk=/usr/local/nagios/var/service-perfdata
}
define command{
command_name process-host-perfdata-file
command_line $USER1$/process_perfdata.pl --bulk=/usr/local/nagios/var/host-perfdata
}
command_name process-host-perfdata-file
command_line $USER1$/process_perfdata.pl --bulk=/usr/local/nagios/var/host-perfdata
}
(5)Nagios前台页面配置
编辑templates.cfg,增加pnp的主机和service定义
编辑templates.cfg,增加pnp的主机和service定义
define host {
name host-pnp
register 0
action_url /nagios/pnp/index.php?host=$HOSTNAME$
}
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$
}
name srv-pnp
register 0
action_url /nagios/pnp/index.php?host=$HOSTNAME$&srv=$SERVICEDESC$
}
(6)编辑localhosts.cfg,对需要进行pnp绘图的host和service增加pnp的host和service
define host{
use web-server,host-pnp
host_name localhost
alias localhost
address 127.0.0.1
}
use web-server,host-pnp
host_name localhost
alias localhost
address 127.0.0.1
}
define service{
use local-service,srv-pnp
host_name localhost
service_description PING
check_command check_ping!100.0,20%!500.0,60%
}
use local-service,srv-pnp
host_name localhost
service_description PING
check_command check_ping!100.0,20%!500.0,60%
}
(7)全部修改完成以后重新配置Nagios让配置生效
#/etc/init.d/nagios reload
#/etc/init.d/nagios reload
(8)如果在查看pnp图时显示GD库没有安装,请安装php-gd,并重启apache2
本文转自 beansprouts 51CTO博客,原文链接:http://blog.51cto.com/netwalk/224415
,如需转载请自行联系原作者