The SnmpGetNextAction
function retrieves the next SNMP variables in the variable tree from the specified agent. It stores the resulting OIDs in a Netcool/Impact variable named VarIdList
, the resulting values in a Netcool/Impact variable named ValueList
and any error messages in a variable named ErrorString
. The function operates by sending a series of SNMP GETNEXT
commands to the specified agent where each command specifies a single OID for which the next variable in the tree is to be retrieved.
When you call SnmpGetNextAction
, you pass an SNMP data type and, for SNMP v3, any authorization parameters that are required. If you want to override the variable information specified in the SNMP data type, you can also optionally pass a list of OIDs and other information needed to retrieve the data.
The following is the syntax for SnmpGetNextAction
:
SnmpGetNextAction(TypeName, [HostId], [Port], [VarIdList], [Community], [Timeout], [Version], [UserId], [AuthProtocol], [AuthPassword], [PrivPassword], [ContextId], [ContextName])
The following table shows the parameters for SnmpGetNextAction
.
Parameter |
Format |
Description |
TypeName |
String |
Name of the SNMP data type that specifies the hostname, port, OIDs and other information needed to retrieve the SNMP data. |
HostId |
String |
Hostname or IP address of the system where the SNMP agent is running. Overrides value specified in the SNMP data type. |
Port |
Integer |
Port where the SNMP agent is running. Overrides value specified in the SNMP data type. |
VarIdList |
Array |
Optional. Array of strings containing the OIDs of SNMP variables to retrieve from the agent. Overrides values specified in the SNMP data type. |
Community |
String |
Optional. Name of the SNMP write community string. Default is |
Timeout |
Integer |
Optional. Number of seconds to wait for a response from the SNMP agent before timing out. |
Version |
Integer |
Optional. SNMP version number. Possible values are |
UserId |
String |
Required for SNMP v3 authentication. If using SNMP v1 or v2, or v3 without authentication, pass a |
AuthProtocol |
String |
Optional. For use with SNMP v3 authentication only. Possible values are |
AuthPassword |
String |
Optional. For use with SNMP v3 authentication only. Authentication password associated with the specified SNMP User ID. |
PrivPassword |
String |
Optional. For use with SNMP v3 authentication only. Privacy password associated with the specified SNMP User ID. |
ContextId |
String |
Optional. For use with SNMP v3 authentication only. Authentication context ID. |
ContextName |
String |
Optional. For use with SNMP v3 authentication only. Authentication context name. |
The following example shows how to retrieve SNMP variables in the variable tree by calling SnmpGetNextAction
and passing the name of an SNMP data type as an input parameter. In this example, the SNMP data type is named SNMP_PACKED. The data type configuration specifies the OIDs of the variables whose subsequent values in the tree you want to retrieve.
// Call SnmpGetNextAction and pass the name of the SNMP data type that contains // configuration information required to perform the SNMP GETNEXT TypeName = "SNMP_PACKED"; SnmpGetNextAction(TypeName, "192.168.1.1", 161, NULL, NULL, NULL, NULL, NULL, \ NULL, NULL, NULL, NULL, NULL); // Print the results of the SNMP GETNEXT to the policy log Count = 0; While (Count < Length(ValueList)) { Log(VarIdList + ": " + ValueList[Index]); Count = Count + 1; }
The following example shows how to retrieve SNMP variables in the variable tree by calling SnmpGetNextAction
and explicitly overriding the default configuration values set in the SNMP data type.
// Call SnmpGetNextAction and pass the name of the SNMP data type that contains // configuration information required to perform the SNMP GETNEXT TypeName = "SNMP_PACKED"; HostId = "192.168.1.1"; Port = "161"; VarIdList = {".1.3.6.1.2.1.1.5.0", ".1.3.6.1.2.1.1.6.0"}; Community = "private"; Timeout = 15; SnmpGetNextAction(TypeName, HostId, Port, VarIdList, Community, Timeout, NULL, NULL, \ NULL, NULL, NULL, NULL, NULL); // Print the results of the SNMP GETNEXT to the policy log Count = 0; While (Count < Length(ValueList)) { Log(VarIdList + ": " + ValueList[Index]); Count = Count + 1; }
The following example shows how to retrieve retrieve subsequent SNMP variables in the variable tree using SNMP v3 authentication.
// Call SnmpGetNextAction and pass the name of the SNMP data type that contains // configuration information required to perform the SNMP GETNEXT TypeName = "SNMP_PACKED"; HostId = "192.168.1.1"; Port = "161"; VarIdList = {".1.3.6.1.2.1.1.5.0", ".1.3.6.1.2.1.1.6.0"}; Community = "private"; Timeout = 15; Version = 3; UserId = "snmpusr"; AuthProtocol = "MD5_AUTH"; AuthPassword = "snmppwd"; ContextId = "ctx"; SnmpGetNextAction(TypeName, HostId, Port, VarIdList, Community, Timeout, \ Version, UserId, AuthProtocol, AuthPassword, NULL, ContextId, NULL); // Print the results of the SNMP GET to the policy log Count = 0; While (Count < Length(ValueList)) { Log(VarIdList + ": " + ValueList[Index]); Count = Count + 1; }