SNMP SET

The SNMP SET functions enable the rules file to set SNMP variables in an SNMP agent.

There are two functions for each version of SNMP; one without a _p suffix and one with the suffix. The form without the suffix (for example, snmpset) uses the default port number 161. The form with the suffix (for example, snmpset_p) uses the port number on the SNMP agent specified by the Port property.

Both functions return a value indicating whether the variable was set: 0 means the variable was not set and 1 means the variable was set.

When using the form without the suffix in the rules file, you must include the port number with the IP address of the host, preceded by a colon. Due to a limitation in the rules file processor, the value returned by the form that uses the default port must be used even if it is subsequently ignored.

The syntax of the functions is different for each version of SNMP.

SNMP V1

$success = snmpset($hostname, $OID, $type, $value, $community)
$success = snmpset_p($hostname, $OID, $type, $value, $community, $port)

SNMP V2

$success = snmpset_v2c($hostname, $OID, $type, $value, $community)
$success = snmpset_v2c_p($hostname, $OID, $type, $value, $community, $port)

SNMP V3

$success = snmpset_v3($hostname, $userid, $OID, $type, $value)
$success = snmpset_v3_p($hostname, $userid, $OID, $type, $value, $port)

Object types

In the functions, type has one of the following values:

Type

Description

a

IP address

b

Bit

d

Decimal string

i

Integer

n

Null object

o

Object identifier

s

String

t

Timetick

u

Unsigned

x

Hex string