4.配置apache,使其能够web访问
yum安装完成后会在apache上生成配置文件/etc/httpd/conf.d/mrtg.conf,配置如下:
[root@srv10100173 mrtg]# cat /etc/httpd/conf.d/mrtg.conf
#
# This configuration file maps the mrtg output (generated daily)
# into the URL space. By default these results are only accessible
# from the local host.
#
Alias /mrtg /usr/local/mrtg/share
<Location /mrtg>
Order deny,allow
# Deny from all
Allow from all
Allow from 127.0.0.1
Allow from ::1
# Allow from .example.com
</Location>
我们可以通过http://ip/mrtg访问了,效果如下:
通过以上我们就可以实时查看交换机的流量信息了,但是我们要想实现流量监控报警,我们就需要nagios读取mrtg监控的流量信息来实现了
在新版的nagios中,有check_mrtg和check_mrtgtraf这两个插件,并且相关参数已经配置好了,我们可以直接调用。 1.首先我们要定义交换机和监控服务
我们可以直接修改/usr/local/nagios/etc/switch.cfg这个文件
vim /usr/local/nagios/etc/switch.cfg
define host{
use generic-switch ; Inherit default values from a template
host_name huawei-ER-3100 ; The name we‘re giving to this switch
alias huawei-ER-3100 ; A longer name associated with the switch
address 10.10.15.1 ; IP address of the switch
hostgroups switches ; Host groups this switch is associated with
}
define service{
use generic-service ; Inherit values from a template
host_name huawei-ER-3100
service_description Interface 1794 Bandwidth Usage
check_command check_local_mrtgtraf!/usr/local/mrtg/share/10.10.15.1_1794.log!AVG!1000000,1000000!5000000,5000000!10
}
其中10.10.15.1_1794.log的1794表示交换机的1794端口,我们可以根据mrtg监测的有效信息进行配置。
"AVG"参数的意思是取带宽的统计平均值,"1000000,1000000"参数是指流入的告警门限 (以字节为单位),"5000000,5000000"是输出流量紧急状态门限(以字节为单位),"10"是指如果MRTG日志如果超过10分钟没有数据 返回一个紧急状态(应该每5分钟更新一次)
2.检查nagios配置文件并重启
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
service nagios restart