The SnmpSetAction
function sets variable values on the specified SNMP agent. If the attempt to set variable fails, it stores the resulting error message in a Netcool/Impact variable named ErrorString. This function operates by sending an SNMP SET
command to the specified agent.
When you call SnmpSetAction
, you pass an SNMP data type, an array of OIDs and the array of values that you want to set. In addition, you can also specify any authorization parameters that are required by SNMP v3.
The following is the syntax for SnmpSetAction
:
SnmpSetAction(TypeName, [HostId], [Port], [VarIdList], ValueList, [Community], [Timeout], [Version], [UserId], [AuthProtocol], [AuthPassword], [PrivPassword], [ContextId], [ContextName])
The following table shows the parameters for SnmpSetAction
.
Parameter |
Format |
Description |
TypeName |
String |
Name of the SNMP data type that specifies the hostname, port, OIDs and other information needed to set 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 |
Array of strings containing the OIDs of SNMP variables to set on the agent. Overrides values specified in the SNMP data type. |
ValueList |
Array |
Array of strings containing the values you want to set. You must specify these values in the same order that the OIDs appear either in the SNMP data type or in the |
Community |
String |
Optional. Name of the SNMP write community string. Default is public. |
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 set SNMP variables by calling SnmpSetAction
and passing the name of an SNMP data type, an array of OIDs and an array of values as input parameters. In this example, the SNMP data type is named SNMP_PACKED
.
// Call SnmpSetAction and pass the name of the SNMP data type that contains // configuration information required to perform the SNMP SET TypeName = "SNMP_PACKED"; HostId = "192.168.1.1"; Port = "161"; VarIdList = {".1.3.6.1.2.1.1.4.0", ".1.3.6.1.2.1.1.5.0"}; ValueList = {"Value_01", "Value_02"}; SnmpSetAction(TypeName, HostId, Port, VarIdList, ValueList, NULL, NULL, \ NULL, NULL, NULL, NULL, NULL, NULL, NULL);
The following example shows how to set SNMP variables using SNMP v3 authentication.
// Call SnmpSetAction and pass the name of the SNMP data type that contains // configuration information required to perform the SNMP SET TypeName = "SNMP_PACKED"; HostId = "192.168.1.1"; Port = "161"; VarIdList = {".1.3.6.1.2.1.1.4.0", " .1.3.6.1.2.1.1.5.0"}; ValueList = {"Value_01", "Value_02"}; Community = "private"; Timeout = 15; Version = 3; UserId = "snmpusr"; AuthProtocol = "MD5_AUTH"; AuthPassword = "snmppwd"; ContextId = "ctx"; SnmpSetAction(TypeName, HostId, Port, VarIdList, ValueList, Community, Timeout, \ Version, UserId, AuthProtocol, AuthPassword, NULL, ContextId, NULL);