当前位置: > Linux服务器 > 监控工具 >

(图)nagios安装与配置pnp4nagios-0.6.6

时间:2014-10-26 01:03来源:linux.it.net.cn 作者:it

 nagios配合PNP,可以创造出绚烂多彩的输出,只要你的脚本符合perfdata规则,那么rrdtool就可以出数据,PNP就可以用图给你画出来。
    下面就开始nagios安装配置pnp4nagios-0.6.6之旅吧。

1、下载安装 pnp4nagios-0.6.6.tar.gz
 

复制代码代码如下:
nagios $> wget http://cdnetworks-kr-1.dl.sourceforge.net/project/pnp4nagios/PNP-0.6/pnp4nagios-0.6.6.tar.gz

nagios $> apt-get install rrdtool librrds-perl
nagios $> tar zxvf  pnp4nagios-0.6.6.tar.gz
nagios $> cd pnp4nagios-0.6.6
nagios $> ./configure --with-nagios-user=nagios --with-nagios-group=nagcmd
nagios $> make all
nagios $> make install
nagios $> make install-webconf
nagios $> make install-config
nagios $> make install-init

2、创建配置文件
 

复制代码代码如下:
nagios $> cd /usr/local/pnp4nagios/etc
nagios $> mv misccommands.cfg-sample  misccommands.cfg
nagios $> mv nagios.cfg-sample  nagios.cfg
nagios $> mv npcd.cfg-sample npcd.cfg
nagios $> mv process_perfdata.cfg-sample  process_perfdata.cfg
nagios $> mv rra.cfg-sample rra.cfg

nagios $>  cd pages
nagios $> mv web_traffic.cfg-sample web_traffic.cfg

nagios $> cd ../check_commands
nagios $> mv check_all_local_disks.cfg-sample  check_all_local_disks.cfg
nagios $> mv check_nrpe.cfg-sample  check_nrpe.cfg
nagios $> mv check_nwstat.cfg-sample  check_nwstat.cfg

3、重启服务
 

复制代码代码如下:
nagios $> /etc/init.d/npcd restart

4、修改 nagios 的配置文件.打开performance_data
nagios $> cd /usr/local/nagios/etc
nagios $> vim nagios.cfg
#打开注视项:
 

复制代码代码如下:
process_performance_data=1
host_perfdata_command=process-host-perfdata
service_perfdata_command=process-service-perfdata

5、修改 commands.cfg
nagios $> cd /usr/local/nagios/etc/objects
nagios $> vim commands.cfg
##添加
 

复制代码代码如下:
# 'process-host-perfdata' command definition
define command{
        command_name    process-host-perfdata
        command_line    /usr/local/pnp4nagios/libexec/process_perfdata.pl
        }
# 'process-service-perfdata' command definition
define command{
        command_name    process-service-perfdata
        command_line    /usr/local/pnp4nagios/libexec/process_perfdata.pl
        }

6、添加小太阳模版,镶嵌在nagios页面上。
nagios $> vim templates.cfg
 

复制代码代码如下:
## 在最后添加
define host {
name       host-pnp
action_url /pnp4nagios/graph?host=$HOSTNAME$&srv=_HOST_
register   0
}
define service {
name       srv-pnp
action_url /pnp4nagios/graph?host=$HOSTNAME$&srv=$SERVICEDESC$
register   0
}

7、修改 hosts.cfg 和 services.cfg
nagios $> cd /usr/local/nagios/etc/eric.com
 

复制代码代码如下:
#修改hosts.cfg
nagios $> vim hosts.cfg
define host{
        use               linux-server,host-pnp  
        host_name         eric.com
        alias             eric.com
        address           192.168.6.101
        }

# 修改 services.cfg
define service{
        use                     local-service,srv-pnp      
        host_name               eric.com
        service_description     PING
        check_command           check_ping!100.0,20%!500.0,60%
}

8、重启 nagios 服务
 

复制代码代码如下:
nagios $> /etc/init.d/nagios restart

效果图如下:
nagios-pnp

(责任编辑:IT)
------分隔线----------------------------