SNMP Reports How-To

转载 2007年09月25日 15:32:00


From OpenNMS

This guide asumes that you know how to play with RRDTOOL and that you are somewhat familiar with OpenNMS. All the examples presented here were tested on Redhat Linux 7.3, version 1.0 of OpenNMS with Net-SNMP 4.2.3 agents running on the managed stations.

I tried to be as accurate as possible, so read this material at your own risk.


Jose Vicente Nunez Zuleta (
Newbreak LLC System Administrator
Newbreak LLC



Capture the appropiate data using SNMP (edit datacollection-config.xml)

You will need to define the OIDs you want to capture in the file datacollection-config.xml file. In our example we want to capture the following Net-SNMP OIDs (memory, host uptime and interface traffic):

 <!-- Net-SNMP memory stats, --> 
 <group name="ucd-memory" ifType="ignore">
 <!-- Total Swap Size configured for the host. -->
 <mibObj oid="." instance="0" alias="memTotalSwap" type="integer" />   
 <!-- Available Swap Space on the host. --> 
 <mibObj oid="." instance="0" alias="memAvailSwap" type="integer" />   
 <!-- Total Real/Physical Memory Size on the host. -->
 <mibObj oid="." instance="0" alias="memTotalReal" type="integer" />  
 <!-- Available Real/Physical Memory Space on the host. -->
 <mibObj oid="." instance="0" alias="memAvailReal" type="integer" />  
 <!-- Error flag.  1 indicates very little swap space left -->
 <mibObj oid="." instance="0" alias="memSwapError" type="integer" />

 <!-- Net-SNMP system stats, -->
 <group name="ucd-systemStats" ifType="ignore">
 <!-- Amount of memory swapped to disk (kB/s). -->
 <mibObj oid="." instance="0" alias="ssSwapOut" type="integer" />  
 <!-- percentages of user CPU time. -->
 <mibObj oid="." instance="0" alias="ssCpuUser" type="integer" />  
 <!-- percentages of user CPU system. -->
 <mibObj oid="." instance="0" alias="ssCpuSystem" type="integer" / 
 > <!-- percentages of user CPU idle. -->
 <mibObj oid="." instance="0" alias="ssCpuIdle" type="integer" /> 

 <group  name = "mib2-interfaces-net-snmp" ifType = "all">
 <mibObj oid="." instance="ifIndex" alias="ifInOctets"    type="counter"/ >
 <mibObj oid="." instance="ifIndex" alias="ifInUcastPkts" type="counter"/ >
 <mibObj oid="." instance="ifIndex" alias="ifInNUcastPkts" type="counter"/>
 <mibObj oid="." instance="ifIndex" alias="ifInErrors"    type="counter"/>
 <mibObj oid="." instance="ifIndex" alias="ifOutOctets"   type="counter"/>
 <mibObj oid="." instance="ifIndex" alias="ifOutDiscards" type="counter"/>
 <mibObj oid="." instance="ifIndex" alias="ifOutErrors"   type="counter"/>

Then make sure your OIDs make it into the "systemDef" tag:

 <systemDef name = "Net-SNMP">
 <!-- <sysoidMask>.</sysoidMask> -->

Please note than if a given OID cannot be retrieved (for example the SNMP agent doesn't support it) then the RRDtool file is not created (normally stored in /var/opennms/rrd/snmp/)

Additional notes
Make sure <sysoidMask> matches your systems oid or else it will not find it.

$ snmpget -v2c -On -c <community> <host> sysObjectID.0
. = OID: .

would give you:


Edit the snmp graphic properties (file

Check your RRDTOOL files

You need to define your custom graphics as follow:

choose the name you will use for the "reports" property
which rrdtool files you will use in your graphic
use 'interface' if the stat is related with each network interface, use 'node' if affects the whole node.

NOTE: Beginning with version 1.3.2 the types are interfaceSnmp and nodeSnmp instead of interface and node.

database values, currently only ifSpeed
This is the command line you pass to rrdtool. Actualy rrdtool is called by a servlet, so you can test your graphics before adding them to this file.

One way to know wich datasources exist on your rddtool file (used in the DEF part of the rrdtool command line) is to get the information from the rrdtool file like this:

[root@lnxdev0001 16]# rrdtool info hrSystemUptime.rrd
filename = "hrSystemUptime.rrd"
rrd_version = "0001"
step = 300
last_update = 1026942859
ds[hrSystemUptime].type = "GAUGE"
ds[hrSystemUptime].minimal_heartbeat = 600
ds[hrSystemUptime].min = NaN
ds[hrSystemUptime].max = NaN
ds[hrSystemUptime].last_ds = "UNKN"
ds[hrSystemUptime].value = 2.0296406018e+10
ds[hrSystemUptime].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 = 7.8203629928e+08
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.8068611333e+07
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 = 7.8338616000e+07
rra[3].cdp_prep[0].unknown_datapoints = 0

As you can see, the ds is 'hrSystemUptime'

If for some reason one of the rrdtool files that are part of a graphic definition is missing, then the graphic doesn't show up at all in the web console.

Remember than you can always check the contents of a rrdtool file typing:

rrdtool dump hrSystemUptime.rrd (shows a huge amount of data).

Add your graphic definitions

You can always check if the graphics you want to plot are accurate by running the rrdtool command line; Here is an example to graph the host uptime by hand:

 rrdtool graph uptime.png --title "Host uptime" --vertical-label /
 Days "DEF:timeticks=hrSystemUptime.rrd:hrSystemUptime: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"

As you can see in the next lines, you will "copy and paste" part of this line in the graphic definition.

Here is the graphic configuration to caputure the host uptime, memory ussage and link accuracy, file

#### Newbreak LLC Custom reports. Jose Vicente Nunez Zuleta ( #####
# Be very carefull with trailing spaces, otherwise you can get problems with the graphics!!!

# Get the Uptime if the host uses Net-SNMP ( To get the graphic manually:
report.netsnmp.uptime.command=--title "Host uptime" /
  --vertical-label Days /
  DEF:timeticks={rrd1}:hrSystemUptime: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" /

# Get the Memory statistics if the host uses Net-SNMP (
report.netsnmp.memory.command=--title "Host memory usage" /
  --vertical-label bytes /
  DEF:mtotalSwap={rrd1}:memTotalSwap:AVERAGE /
  DEF:mavailSwap={rrd2}:memAvailSwap:AVERAGE /
  DEF:mtotalReal={rrd3}:memTotalReal:AVERAGE /
  DEF:mavailReal={rrd4}:memAvailReal:AVERAGE /
  CDEF:totalSwap=mtotalSwap,1024,* /
  CDEF:availSwap=mavailSwap,1024,* /
  CDEF:totalReal=mtotalReal,1024,* /
  CDEF:availReal=mavailReal,1024,* /
  LINE3:totalSwap#FF0000:"Total swap" /
  LINE1:availSwap#00FF00:"Available swap" /
  LINE3:totalReal#0000FF:"Total real" /
  LINE1:availReal#000000:"Available real" /
  GPRINT:totalSwap:AVERAGE:"Avg  //: %8.1lf %s" /
  GPRINT:totalSwap:MIN:"Min  //: %8.1lf %s" /
  GPRINT:totalSwap:MAX:"Max  //: %8.1lf %s" /
  GPRINT:availSwap:AVERAGE:"Avg  //: %8.1lf %s" /
  GPRINT:availSwap:MIN:"Min  //: %8.1lf %s" /
  GPRINT:availSwap:MAX:"Max  //: %8.1lf %s" /
  GPRINT:totalReal:AVERAGE:"Avg  //: %8.1lf %s" /
  GPRINT:totalReal:MIN:"Min  //: %8.1lf %s" /
  GPRINT:totalReal:MAX:"Max  //: %8.1lf %s" /
  GPRINT:availReal:AVERAGE:"Avg  //: %8.1lf %s" /
  GPRINT:availReal:MIN:"Min  //: %8.1lf %s" /
  GPRINT:availReal:MAX:"Max  //: %8.1lf %s" /

# Calculate the network accuracy using SNMP (
# Check the following man pages for more info on rrdtool graph:
# - rrdgraph_graph
# - rrdgraph
# - rrdgraph_examples
# Also if you forgot anbout the RPN notation (like me :) ) then go to:
# -
# Use CDEF to calculate this expression:
# accuracy = 100 - ( (DifInErr*100) / (DifInUcast + DifInNUcast) )
# In my case, Net-SNMP doesn't show up the ifInNUcastPkts OID on Linux (Solaris works fine)
# but the ammount of traffic is very low, so even taking out that value the estimate is good.
report.netsnmp.accuracy.command=--title "Link accuracy" /
  DEF:error={rrd1}:ifInErrors:AVERAGE /
  DEF:ucast={rrd2}:ifInUcastPkts:AVERAGE /
  CDEF:accuracy=100,error,100,*,ucast,/,- /
  LINE2:accuracy#FF0000:"% Accuracy" /
  GPRINT:accuracy:AVERAGE:"Avg  //: %8.1lf %s" /
  GPRINT:accuracy:MIN:"Min  //: %8.1lf %s" /
  GPRINT:accuracy:MAX:"Max  //: %8.1lf %s" /

# If you are sure than all your machines have information about multicast traffic, then:
# DEF:nucast={rrd3}:ifInNUcastPkts:AVERAGE /
# CDEF:accuracy=100,error,100,*,ucast,nucast,+,/,- /

Add New Reports to the reports Property

Finally, don't forget to add the reports into the value of the reports property.

#report keys, list ALL prefab reports here!
reports=traffic, octets, errors, discards, avgbusy5, freemem, /
  bufferfails, kerneltasks, kernelmem, /
  cpuPercentBusy, /
  novell.numberOfNLMsLoaded, novell.openFiles, novell.licensedConnections, /
  memory, /
  novell.codeDataMemory, novell.cacheBuffers, /
  novell.diskSpaceSys, novell.diskSpaceVol2, /
  winnt2k.diskSpaceC, winnt2k.diskSpaceD, /
  checkpoint.pktsAccepted, checkpoint.pktsRejected, /
  checkpoint.pktsDropped, checkpoint.pktsLogged, /
  loadavg, netsnmp.uptime, netsnmp.memory, netsnmp.accuracy /

Our reports are netsnmp.uptime, netsnmp.memory, netsnmp.accuracy on the last line. If you miss this step, you will get web exceptions when attempting to run performance reports. The exceptions will look something like the following:

Missing Parameter

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

The following parameters are required:

Restart OpenNMS

/etc/init.d/opennms restart
/etc/init.d/tomcat4 restart

Probably you will have to wait a couple of minutes before you get useful data to display.


Tutorial on how to use the RPN notation:

Check the following man pages for more info on rrdtool graph:



Oracle EBS R12 how to call standard API/packages from custom form or reports

Oracle EBS R12 how to call standard API/packages from custom form or reports Okay guys and gals ...

FAQ: How to Use AWR reports to Diagnose Database Performance Issues [ID 1359094.1]

FAQ: How to Use AWR reports to Diagnose Database Performance Issues [ID 1359094.1]   ...

SNMP--How to install SNMP extension agent DLL(如何安装SNMP扩展代理DLL)

英文原文地址:   How to in...

SNMP--How to develop a SNMP extension agent DLL(如何开发一个SNMP扩展代理DLL)

英文网址为: 本文翻译只是出于...

How to Use Google AdSense Ads on Responsive Websites

How to Use Google AdSense Ads on Responsive Websites Learn how to make your Google AdSense ads resp...

How to parse JSON in Java

From: How to Parse JSON in ...