Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
9 lines (8 sloc) 2.02 KB

Examples

  1. ActiveDiscovery_with_properties_with_enumeration.groovy - This script can be used as an Auto Discovery script for a multi-instance data source. It returns the list of instances with their name and any defined properties. This is an example only as the functionality covered here is already functional with other mechanisms already built.
  2. snmpWalkHelpers.groovy - this script has some helper functions to poll data from a device and return it in a groovy native map of maps. Providing the "wildvalueTerms" tells the script which part of the returned data is the instance id (wildvalue) and which part is the metric OID. If it's one, you can just leave it off. Running this script as is will poll the interfaces table and output the result of the walkAsMap(), then output the structured data, then pretty print the structured data, then flat print the structured data (more details below). Technically, this can be used for SNMP instances that have double indices (or even triple, but I haven't run across one of those in years). If so, set wildValueTerms to 2:
  • snmpMapToTable(walkAsMapResult) converts the output of a walkAsMap() call and returns the structured data.
  • sortSnmpWalkTable(snmpMapToTable_output) sorts, and returns as a list, the keys of the structured data so that the instances can be print out in numeric order by the pprintSnmpWalkTable(snmpMapToTable_output) function.
  • pprintSnmpWalkTable(snmpMapToTable_output) outputs the structured data in an easily readable format. Instances are in numeric order and if the data OID is a single term, outputs the columns in numerical order.
  • flattenSnmpWalkTable(snmpMapToTable_output) converts the structured data to a list of 3-element tuples, each containing the instance id (wildvalue), data OID, and value.
  1. if_listallnames.groovy is an example of how the helper functions can be used. Lines 68-72 are the only appreciable deviation from the helper functions.
You can’t perform that action at this time.