OpenNMS扩展 – SNMP报表配置

来源:互联网 发布:电脑激活windows 编辑:程序博客网 时间:2024/05/08 20:01

OpenNMS扩展 – SNMP报表配置

SNMP报表的显示主要由两个文件,datacollection-config.xmlsnmp-graph.properties

定制SNMP图形报表主要步骤如下:

1.     通过SNMP获取数据(datacollection-config.xml)

datacollection-config.xml文件中定义OID捕获数据,在此例中将捕获系统中CPU的占用情况(蓝色字体部分)

<group name = "windows-host" ifType = "ignore">

    <mibObj oid=".1.3.6.1.2.1.25.3.3.1.2" instance="1" alias="cpuPercentBusy" type="integer" />

       <!-- Drive information is from the hrStorage table. -->

       <!-- I'm cheating and assuming that the second and third -->

       <!-- entries refer to Drive_C and Drive_D -->

     <mibObj oid=".1.3.6.1.2.1.25.2.3.1.3" instance="2" alias="hrDescDisk2"  type="string"/>

     <mibObj oid=".1.3.6.1.2.1.25.2.3.1.4" instance="2" alias="hrUnitsDisk2" type="integer" />

     <mibObj oid=".1.3.6.1.2.1.25.2.3.1.5" instance="2" alias="hrSizeDisk2" type="integer" />

     <mibObj oid=".1.3.6.1.2.1.25.2.3.1.6" instance="2" alias="hrUsedDisk2" type="integer" />

     <mibObj oid=".1.3.6.1.2.1.25.2.3.1.3" instance="3" alias="hrDescDisk3"  type="string"/>

     <mibObj oid=".1.3.6.1.2.1.25.2.3.1.4" instance="3" alias="hrUnitsDisk3" type="integer" />

     <mibObj oid=".1.3.6.1.2.1.25.2.3.1.5" instance="3" alias="hrSizeDisk3" type="integer" />

     <mibObj oid=".1.3.6.1.2.1.25.2.3.1.6" instance="3" alias="hrUsedDisk3" type="integer" />

     <mibObj oid=".1.3.6.1.2.1.25.2.3.1.3" instance="4" alias="hrDescDisk4"  type="string"/>

     <mibObj oid=".1.3.6.1.2.1.25.2.3.1.4" instance="4" alias="hrUnitsDisk4" type="integer" />

     <mibObj oid=".1.3.6.1.2.1.25.2.3.1.5" instance="4" alias="hrSizeDisk4" type="integer" />

     <mibObj oid=".1.3.6.1.2.1.25.2.3.1.6" instance="4" alias="hrUsedDisk4" type="integer" />

        <!-- Memory in KBytes -->

     <mibObj oid=".1.3.6.1.2.1.25.2.2" instance="0" alias="memorySize" type="integer" />

 

        <!-- the total system's CPU resources consumed -->

           <!—instance表示OID索引位置,alias表示别名 -->

          <mibObj oid=".1.3.6.1.2.1.25.5.1.1.1" instance="1" alias="hrSWRunPerfCPU" type="integer" />

</group>

请注意,确保给定的OID能够在系统中找到,否则将不会产生RRDTool文件(RRDTool文件通常存储在$OPENNMS_HOME/share/rrd/snmp/目录下),可通过snmpget检测是否可以找到此OID

[root@localhost /]# snmpget -v 1 -c public 192.168.6.21 .1.3.6.1.2.1.25.5.1.1.1.1

HOST-RESOURCES-MIB::hrSWRunPerfCPU.1 = INTEGER: 482801

2.     编辑SNMP图形属性文件(snmp-graph.properties)

2.1 检查RRDTOOL数据文件

定制的图形报表需定义如下属性:

l         名字(name):用来显示报表的名字。

l         (colunms):显示RRDTool文件中的数据。

l         类型(type:如果状态跟每个网络接口有关联,则使用“interface”类型,如果影响整个结点的,则使用“node”类型。

一种获取RRDTool文件信息的方法是采用rrdtool info 命令行的方式,如下:

[root@localhost 13]#  rrdtool info hrSWRunPerfCPU.rrd

filename = "hrSWRunPerfCPU.rrd"

rrd_version = "0001"

step = 300

last_update = 1211338458

ds[hrSWRunPerfCPU].type = "GAUGE"

ds[hrSWRunPerfCPU].minimal_heartbeat = 600

ds[hrSWRunPerfCPU].min = NaN

ds[hrSWRunPerfCPU].max = NaN

ds[hrSWRunPerfCPU].last_ds = "UNKN"

ds[hrSWRunPerfCPU].value = 3.5009052000e+08

ds[hrSWRunPerfCPU].unknown_sec = 0

rra[0].cf = "AVERAGE"

rra[0].rows = 8928

rra[0].pdp_per_row = 1

rra[0].xff = 5.0000000000e-01

rra[0].cdp_prep[0].value = NaN

rra[0].cdp_prep[0].unknown_datapoints = 0

rra[1].cf = "AVERAGE"

rra[1].rows = 8784

rra[1].pdp_per_row = 12

rra[1].xff = 5.0000000000e-01

rra[1].cdp_prep[0].value = 1.0469351560e+07

rra[1].cdp_prep[0].unknown_datapoints = 0

rra[2].cf = "MIN"

rra[2].rows = 8784

rra[2].pdp_per_row = 12

rra[2].xff = 5.0000000000e-01

rra[2].cdp_prep[0].value = 7.9226661000e+05

rra[2].cdp_prep[0].unknown_datapoints = 0

rra[3].cf = "MAX"

rra[3].rows = 8784

rra[3].pdp_per_row = 12

rra[3].xff = 5.0000000000e-01

rra[3].cdp_prep[0].value = 1.3079840700e+06

rra[3].cdp_prep[0].unknown_datapoints = 0

如果由于某种原因,如果rrdtool数据文件的一部分没有定义或没有数据,则相应的图形也将不会显示在Web上。

记得随时检查rrdtool数据文件的内容,输入:

rrdtool dump hrSWRunPerfCPU.rrd(按日期显示大量采集的数据)

2.2 添加图形定义

可以随时检查定义生成的数据文件产生的图形显示效果,用RRDTool图形生成命令行可以做到:

rrdtool graph hrSWRunPerfCPU.png --title " The total system's CPU resources consumed " --vertical-label /

 Days "DEF:timeticks=hrSWRunPerfCPU.rrd:hrSWRunPerfCPU:AVERAGE" /

 "CDEF:days=timeticks,8640000,/" AREA:days#FF0000:"Days" /

 GPRINT:days:AVERAGE:"Avg  //: %8.1lf %s" GPRINT:days:MIN:"Min  //: %8.1lf %s" /

 GPRINT:days:MAX:"Max  //: %8.1lf %s"

如下是snmp-graph.properties文件中hrSWRunPerfCPU图形报表属性配置:

report.microsoft.hrSWRunPerfCPU.name=CPU resources consumed

report.microsoft.hrSWRunPerfCPU.columns=hrSWRunPerfCPU

report.microsoft.hrSWRunPerfCPU.type=node

report.microsoft.hrSWRunPerfCPU.command=--title="The total system's CPU resources consumed" /

 --vertical-label Days /

  DEF:hrSWRunPerfCPU={rrd1}:hrSWRunPerfCPU:AVERAGE /

  CDEF:days=hrSWRunPerfCPU,8640000,/ /

  AREA:days#FF0000:"Days" /

  GPRINT:days:AVERAGE:"Avg  //: %8.1lf %s" /

  GPRINT:days:MIN:"Min  //: %8.1lf %s" /

  GPRINT:days:MAX:"Max  //: %8.1lf %s" /

 

如果,定义的其中report.microsoft.hrSWRunPerfCPU.columns=hrSWRunPerfCPU中的hrSWRunPerfCPUdatacollection-config.xml文件中MIB的别名。报表的定义的key规则:report.+reports key中定义的报表名称+属性。

3.     添加新报表到报表属性

最后,为了显示产生的报表,需要在snmp-graph.properties文件的reports key 中添加microsoft.hrSWRunPerfCPU,并加逗号与/结束。

#report keys, list ALL prefab reports here!

reports=mib2.bits, mib2.discards, mib2.errors, mib2.HCbits, mib2.packets, /

mib2.tcpopen, mib2.tcperrs, mib2.tcpsegs, /

mib2.traffic-inout, /

mib2.ups-amp, mib2.ups-charge, mib2.ups-temp, mib2.ups-time, mib2.ups-volt, /

mib2printer.lifeCount, mib2printer.powerOnCount, /

apc.load, apc.percent, apc.temp, apc.time, apc.vac, /

checkpoint.pktsAccepted, checkpoint.pktsDropped, checkpoint.pktsLogged, checkpoint.pktsRejected, /

cisco.altigaactsess, cisco.altigacpu, cisco.altigafanspeed, cisco.altigatemp, /

cisco.altigatput, cisco.altigavoltage, cisco.altiga3volt, cisco.altiga5volt, /

cisco.avgbusy5, cisco.bufferfails, cisco.buffhits, cisco.buffmiss, /

cisco.ccmcti, cisco.ccmgs, cisco.ccmgw, cisco.ccmmd, cisco.ccmphones, /

cisco.ccmps, cisco.ccmvm, /

cisco.cike-bits, cisco.cike-dn, cisco.cike-fail, cisco.cike-init, cisco.cike-pkts, /

cisco.cike-p2ex, cisco.cike-p2exinv, cisco.cike-p2exrej, cisco.cike-tunnels, /

cisco.dropsin, cisco.dropsout, cisco.freemem, /

cisco.firewall, cisco.memory, /

cisco.pkts, cisco.protoin, cisco.protoout, cisco.temp, /

cisco.4bb, cisco.80bb, cisco.256bb, cisco.1550bb, /

extreme.currentTemp, /

foundry.actualTemp, foundry.cpuUtil1Min, foundry.dynMemUtil, /

hp.swbuffcorrupt, hp.swbufferfree, hp.swbufferinit, hp.swbuffermin, /

hp.swbuffermiss, hp.swbuffersize, hp.swfreemem, hp.switchcpu, hp.swmemalloc, hp.swtotalmem, /

hpux.cpu, hpux.memory, hpux.numFsMounted, hpux.numProcs, hpux.numUsers, hpux.swap, /

juniper.bufferPoolUtil, juniper.cpu, juniper.temp, /

mge.ambtemp, mge.ambhumid, mge.current, mge.level, mge.temp, mge.time, mge.voltage, /

microsoft.cpuPercentBusy, microsoft.hrDisk2, microsoft.hrDisk3, microsoft.hrDisk4, microsoft.hrSWRunPerfCPU, /

netsnmp.context, /

netsnmp.disk1, netsnmp.disk1percent, netsnmp.disk2, netsnmp.disk2percent, /

netsnmp.disk3, netsnmp.disk3percent, netsnmp.disk4, netsnmp.disk4percent, netsnmp.disk5, netsnmp.disk5percent, /

netsnmp.hrMemory, netsnmp.hrNumUsers, netsnmp.interrupts, /

netsnmp.hrSystemUptime, netsnmp.loadavg, netsnmp.swapinout, /

netBotz.air, netBotz.humid, netBotz.temp, /

nortel.kernelmem, nortel.kerneltasks, /

novell.cacheBuffers, novell.codeDataMemory, novell.diskSpaceSys, /

novell.diskSpaceVol2, novell.licensedConnections, novell.numberOfNLMsLoaded, novell.openFiles, /

sinf.availmem, sinf.mempool, sinf.paging, sinf.processes, sinf.sysmem, /

sinf.cpu0percent, sinf.cpu1percent, sinf.cpu2percent, sinf.cpu3percent, sinf.cputotalpercent, /

sinf.diskfreeC, sinf.diskfreeD, sinf.diskfreeE, sinf.diskfreetotal, /

sinf.exchange-is.vmfreeblks, sinf.exchange-is.users, /

sun.cpuTime, sun.diskxfer, sun.interrupts, sun.packets, sun.paging, sun.procs, /

sun.swap, sun.swapping, /

netsnmp.memStats, /

netsnmp.cpuStats, /

netsnmp.connectNums

我们定义的报表是microsoft.hrSWRunPerfCPU,如果没有在这里定义,当试图运行这个性能报表时,将会在Web页面上抛出一个异常:

Missing Parameter

The request you made was incomplete. It was missing the  report parameter.

The following parameters are required:

report

node

4.     重启TomcatOpenNMS

su - tomcat -c "/usr/local/tomcat/bin/startup.sh"

/usr/local/opennms/source/work/bin/opennms.sh restart

大约过一两分钟RDD数据文件就会生成。

如果只是修改snmp-graph.properties文件,则不需重启OpenNMS,因为报表程序每次会重新读取此文件。

 

原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 秦时之血衣侯传奇 死神:我的斩魄刀是整个地府 武道:从盘古幡开始 火影:我怎么可能是男二 贫僧还俗了 逆流香江时代 我于教坊司中度长生 木叶,我成了大筒木辉夜的小号 长生妖道 大随圣人:从天牢自救开始 重生妖禽,加载了山海经游戏模板 虫族在晶壁系世界 诡雾临城,从眼镜蛇开始进化 重生之学霸男神 华娱,我真不想当明星 我的女友是双胞胎 赛亚人只是路过而已 全民转职,谁敢说剑客是垃圾职业 人在秦时,三无剑客 水浒之换了青天 轴承曝光我成首席科学家 诸神的轻语 超神:每天一个新马甲 逢魔时刻,从满级悟性开始 大主宰之冰封万里 从布斯巴顿到霍格沃茨 大乾镇魔人 足球之我喝口水都能变强 我被七个妖女囚禁了 DC人间之神 绝世唐门之太阳 混在港综世界当枭雄 龙族:蓝染魂穿路明非 超级垂钓养殖系统 stm32移植xcp协议 xcp协议 程女士 Java在一个5个数的数组中,输出逆序数(在一个排列中,如果一对数的前后位置与大小顺序相反,即前面的 在一个5个数的数组中,输出逆序数 http://www.aqdlt.com/ Android应用逆向——分析反编译代码之大神器