SNMP报表的显示主要由两个文件,datacollection-config.xml与snmp-graph.properties。
定制SNMP图形报表主要步骤如下:
在datacollection-config.xml文件中定义OID捕获数据,在此例中将捕获系统中CPU的占用情况(蓝色字体部分):
表示OID索引位置,alias表示别名 -->
请注意,确保给定的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
定制的图形报表需定义如下属性:
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(按日期显示大量采集的数据)
可以随时检查定义生成的数据文件产生的图形显示效果,用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中的hrSWRunPerfCPU是datacollection-config.xml文件中MIB的别名。报表的定义的key规则:report.+reports key中定义的报表名称+属性。
最后,为了显示产生的报表,需要在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
su - tomcat -c "/usr/local/tomcat/bin/startup.sh"
/usr/local/opennms/source/work/bin/opennms.sh restart
大约过一两分钟RDD数据文件就会生成。
如果只是修改snmp-graph.properties文件,则不需重启OpenNMS,因为报表程序每次会重新读取此文件。