snmp_set()


Set variables in the PATROL SNMP Management Information Base (MIB).

Syntax

snmp_set(session,
objectid1 [lengthn] type1 value1,
[...,objectidn lengthn typen valuen])

Parameter

Parameter

Definition

session

ID of the SNMP session to which the SNMP set-request is submitted The session is the ID returned when an snmp_open() function is executed.

objectidn

character string SNMP object identifier for the variable whose value is to be changed

lengthn

optional integer used for typen = character to indicate the length of the character string This parameter is provided to support multiline strings. The snmp_set() function will return an error if the text string valuenis not greater than or equal to lengthn characters.

typen

character string indicating the objectidn type

*Valid Values* 
integer 
string

valuen

value to be assigned to the MIB variable objectidn

Description

The snmp_set() function sends an SNMP set-request to session to set specified variables in the Management Information Base (MIB). 

The snmp_set() function requires that the SNMP session community property be "private." The community property is set when the SNMP session is opened with the snmp_open() function. 

The three parts of the snmp_set() function variable replacement, objectidntypen, and valuen must be separated by spaces.

Return Values

The snmp_set() function returns the new value of the MIB variable, or when an error occurs, the NULL string or an error message.

MIB variable value

The snmp_set() function returns the new value of an SNMP MIB variable in the following format:

 

name type length value

Field

Definition

name

name of an SNMP MIB variable

type

character string indicating the name type

length

length of the value

value

value of name

errno variable

When the snmp_set() function fails to set the PATROL SNMP MIB variable, it can return the NULL and set the PSL errno to one of the following values:

errno Value

Description

0

E_PSL_NO_ERROR

  • invalid string length
  • no parameter
  • redundancy of snmp_set with the same parameter
  • multiple objects using the same oid
  • using set to register an snmp manager

95

E_PSL_TIMEOUT 
request timed out

96

E_PSL_BAD_FUNCTION_PARAMETER

  • bad object id
  • invalid object type
  • no object type
  • no object value

93

E_PSL_NO_SUCH_ID

  • bad session id
  • no session ID

100

E_PSL_SNMP_ERROR 
multiple parameters with different oids

 

When the snmp_set() function fails to set the PATROL SNMP MIB variable because of an invalid objectid, length, or type, one of the following messages is returned: 

There is no such variable name in this MIB. 

The value given has the wrong type or length.

Example

The following snmp_set() function will set the SNMP variable .1.3.4.6.4.1.0 to the string "some_text_is_25\nchar_long":

myhost = get("/hostname");
sess = snmp_open(myhost,"","","","",8161);
snmp_set(sess,".1.3.4.6.4.1.0 25 string some_text_is_25\nchar_long");