snmp_h_set()


Open a brief PATROL SNMP session with default parameters to set variables in the SNMP Management Information Base (MIB).

Syntax

snmp_h_set(host,objectid1 type1 value1,
[...objectidn typen valuen])

Parameter

Parameter

Definition

host

name of the computer to which the SNMP set-request is submitted The host must be a name known to the local computer in the /etc/hosts file, the Domain Name System (DNS), the Network Information Service (NIS), or an IP address.

objectidn

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

typen

character string indicating the objectidn type

*Valid Values* 
integer 
string

valuen

value assigned to objectidn

Description

The snmp_h_set() function is the equivalent of the following series of PSL function calls:

 

session = snmp_open(host);
snmp_set(session,objectid1 type1 value1,...,
objectidn typen valuen);
snmp_close(session);

 

The snmp_h_set() function performs the following tasks:

  • opens an SNMP session on host (For the default parameters used to open the session, see snmp_open().)
  • sends an SNMP set-request to the session to set specified variables in the Management Information Base (MIB)
  • closes the SNMP session

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

The snmp_h_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_h_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

 

When the snmp_h_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

 

error message

When the snmp_h_set() function fails to set the PATROL SNMP MIB variable because of an invalid objectid the following message is returned: 

There is no such variable name in this MIB.

Example

The following example uses the snmp_h_set() function to set a value in the PATROL MIB:

if (snmp_h_get(myhost,MIBaddr)) {
snmp_h_set(myhost,MIBaddr . " " . newtype . " " . newvalue);
}

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*