3.1 Customizing Snmp Knowledge Scripts

There are several simple ways to customize Snmp Knowledge Scripts to enhance or add functionality. You can check out an existing script from the \AppManager\bin\kp\SNMP folder, perform customizations, and check in the modified script or rename the file to create a new Knowledge Script.

The following list describes how to customize existing Snmp scripts to take advantage of additional functions and features of AppManager SNMP Toolkit.

Enabling SNMP Traffic Tracing

You can enable SNMP Traffic Tracing for all Knowledge Scripts. Turning on Traffic Tracing prints the contents of all SNMP requests or SNMP responses to the mctrace.log file on the AppManager agent. This capability can be used as a debugging tool to determine what is actually being sent or received by AppManager SNMP Toolkit.

To enable SNMP Traffic Tracing for a specific Knowledge Script, locate the Const gintSNMPSectionTraceOn entry and change the value from “0” to “1”. Check out the script, then locate and edit the following block of text accordingly:

'#
'# Constants for SNMP Traffic Tracing 
'# Set gintSNMPSectionTraceOn to 1 to trace SNMP Traffic.
'# Output goes to the AppManager Agent's mctrace.log file.
'# 
Const gintSNMPSectionTraceBit        = 1
Const gintSNMPSectionTraceOn         = 0
Changing default locations of community strings

You can change the default locations of community strings (as defined in the Custom tab of AppManager Security Manager) for all Knowledge Scripts except for AddMIBs and RemoveMIBs:

  • gstrSNMPSecurityLabels lists the labels under which the Knowledge Script searches for community strings, in the order they are listed.

  • gstrSNMPDefaultDevice specifies the Sub-Label used to supply the default community string if one has not been configured for a specific device address.

To edit these values, check out the desired Knowledge Script, then locate and edit the following block of text accordingly:

'#
'# String(s) to use for finding SNMP Community Strings
'#
Const gstrSNMPSecurityLabels      = "SNMP,NetworkDevice"
Const gstrSNMPDefaultDevice       = "Default"
Changing default list separator characters

Many Snmp Knowledge Script parameters are lists: devices, SNMP OIDs, and the like. The characters that serve as list separators can be changed. The defaults are blank and comma.

You can add additional list separator characters, but you cannot delete the comma character.

To edit these values, check out the desired script, then locate and edit the following block of text accordingly:

'#
'# Separators for KS Parameters
'#
Const gstrSNMPListSeparators      = " ,"

If you change gstrSNMPListSeparators, you must also add the <Delim></Delim> option to each script parameter’s XML definition to specify the same separators defined by gstrSNMPListSeparators. If it is not changed in both places, the script will not work correctly.

For the SyncSet script, there is an additional constant: gstrSNMPStringValueSeparators. The default is “,” (comma). This specifies how SNMP values for this script are delimited. Because setting string values may include strings with spaces, only a comma is allowed as a separator. For example:

'#
'# Separators for KS Parameters
'#
Const gstrSNMPListSeparators         = " ,"
Const gstrSNMPStringValueSeparators  = ","
Default empty strings in the Discovery_Snmp script

For the Discovery_Snmp Knowledge Script, there are default strings defined to be used if any of the SNMP device details are empty strings. If sysName.0 is an empty string, “No Name” is shown in the TreeView and the object details. All other object details will show “No Value” if they did not have a value. For example:

'#
'# String(s) to use for SNMP Devices with empty values in System MIB.
'#
Const gstrSNMPNoDeviceName        = "No Name"
Const gstrSNMPNoDeviceValue       = "No Value"
Changing default legend prefix and units for the DeviceReboot script

For the DeviceReboot Knowledge Script, the legend prefix and units in which device uptime is reported can be changed. For example, you could change it to Days by editing the text below and changing the divisor value to 86400.

'#
'# Constants for Datastreams
'#
Const DEVICE_UPTIME_LEGEND       = "Device UpTime"
Const DEVICE_UPTIME_AC           = "Device UpTime (Hours)"
Const DEVICE_UPTIME_UNITS        = "Hours"
Const DEVICE_UPTIME_DIVISOR      = 3600
Changing default legend prefix for SyncGet and SyncGetTable scripts

For the SyncGet and SyncGetTable Knowledge Scripts, the legend prefix can be changed. Locate and edit the text below:

'#
'# Constant for SNMP Generic Scripts Legend Prefix
'#
Const gstrSNMPLegendPrefix        = "SNMP"

NOTE:If you rename a customized Knowledge Script, you cannot access Help using the Help button in the Knowledge Script Properties dialog box. Refer to the Help for the original script for assistance with parameter configuration.