深入研究MRTG能帮助我们完成什么(待续)

 

在了解Templatesand Filters(模板与过滤)时发现,可以对CISCO MIB参数进行监控。

 

另在查找过程中发现代码中有指向/usr/share/snmp/mibs/目录的部分,这部分留到下次分析。(待续)

 

使用指令cfgmaker

# cfgmaker --host-template=/root/cisco.htp cisco@192.168.0.2 > kkk.cfg

 

cisco.htp文件内容如下:

# cisco.htp

# This host template is for Cisco devices

# cfgmaker --host-template=cisco.htp

# Cisco CPU OID is 1.3.6.1.4.1.9.2.1.58.0

 

if( $sysdescr =~ /cisco/i ) {

$head_lines .= "#---------------------------------------------------------------------\n";

my $target_name = $router_name . ".cpu";

$target_lines .= <<ECHO;

routers.cgi*Icon: cisco-sm.gif

routers.cgi*Description: $sysname

routers.cgi*ShortDesc: $router_name

#-------------------------------------------------

Target[$target_name]: 1.3.6.1.4.1.9.2.1.58.0&1.3.6.1.4.1.9.2.1.58.0:$router_connect

Title[$target_name]: $router_name CPU load

YLegend[$target_name]: Percentage

ShortLegend[$target_name]: %

Legend1[$target_name]: CPU load in %

Legend3[$target_name]: Max Observed CPU load

LegendI[$target_name]: &nbsp;CPU Load:

MaxBytes[$target_name]: 100

UnScaled[$target_name]: dwmy

Options[$target_name]: growright, gauge, nopercent, noo

PageTop[$target_name]: <h1>$router_name CPU load</h1>

     <div><table><tr>

          <td>System:</td>

          <td>$router_name in $html_syslocation</td>

     </tr><tr>

          <td>Maintainer:</td>

          <td>$html_syscontact</td>

     </tr><tr>

          <td>Description:</td>

          <td>$html_sysdescr</td>

     </tr><tr>

          <td>Resource:</td><td>CPU.</td>

     </tr></table></div>

routers.cgi*Icon[$target_name]: chip-sm.gif

routers.cgi*InOut[$target_name]: no

routers.cgi*InSummary[$target_name]: yes

routers.cgi*ShortDesc[$target_name]: CPU

routers.cgi*InCompact[$target_name]: yes

routers.cgi*Mode[$target_name]: cpu

routers.cgi*Options[$target_name]: nototal fixunit

ECHO

}

 

生成了KK.CFG文件后对于CPU的部分COPY出来,另加入之前的mrtg.cfg文件内。

# vi /etc/mrtg/mrtg.cfg

 

加入文件的内容如下:

#---------------------------------------------------------------------

routers.cgi*Icon: cisco-sm.gif

routers.cgi*Description: TSG-RSC6509-F01-1.1

routers.cgi*ShortDesc: 192.168.0.2

#-------------------------------------------------

Target[192.168.0.2.cpu]: 1.3.6.1.4.1.9.2.1.58.0&1.3.6.1.4.1.9.2.1.58.0:cisco@192.168.0.2

Title[192.168.0.2.cpu]: 192.168.0.2 CPU load

YLegend[192.168.0.2.cpu]: Percentage

ShortLegend[192.168.0.2.cpu]: %

Legend1[192.168.0.2.cpu]: CPU load in %

Legend3[192.168.0.2.cpu]: Max Observed CPU load

LegendI[192.168.0.2.cpu]: &nbsp;CPU Load:

MaxBytes[192.168.0.2.cpu]: 100

UnScaled[192.168.0.2.cpu]: dwmy

Options[192.168.0.2.cpu]: growright, gauge, nopercent, noo

PageTop[192.168.0.2.cpu]: <h1>192.168.0.2 CPU load</h1>

     <div><table><tr>

          <td>System:</td>

          <td>192.168.0.2 in </td>

     </tr><tr>

          <td>Maintainer:</td>

          <td></td>

     </tr><tr>

          <td>Description:</td>

          <td>Cisco Internetwork Operating System Software <BR>

 IOS (tm) s72033_rp Software (s72033_rp-IPSERVICES_WAN-M), Version 12.2(18)SXF5, RELEASE SOFTWARE (fc3)<BR>

 Technical Support: http://www.cisco.com/techsupport<BR>

 Copyright (c) 1986-2006 by cisco Systems, Inc.<BR>

 Com</td>

     </tr><tr>

          <td>Resource:</td><td>CPU.</td>

     </tr></table></div>

routers.cgi*Icon[192.168.0.2.cpu]: chip-sm.gif

routers.cgi*InOut[192.168.0.2.cpu]: no

routers.cgi*InSummary[192.168.0.2.cpu]: yes

routers.cgi*ShortDesc[192.168.0.2.cpu]: CPU

routers.cgi*InCompact[192.168.0.2.cpu]: yes

routers.cgi*Mode[192.168.0.2.cpu]: cpu

routers.cgi*Options[192.168.0.2.cpu]: nototal fixunit

 

 

再发布到APACHE上,指令如下:

# LANG=C LC_ALL=C /usr/bin/mrtg/etc/mrtg/mrtg.cfg --lock-file /var/lock/mrtg/mrtg_l --confcache-file/var/lib/mrtg/mrtg.ok

# indexmaker--output=/var/www/mrtg/index.html /etc/mrtg/mrtg.cfg

 

完成后对设备进行监控时,则出现以下

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值