SNMP package guide
Read, write and walk SNMPv1 and SNMPv2c agent objects.
Version 2.17.1. Installed versions can differ. Examples are illustrative and not tested.
Prerequisites
Install the package on the Device with a compatible Mercury. You need an SNMP v1 or v2c agent that the Device can reach over UDP. SNMPv3 is not supported. The Run account needs name lookup (DNS) and network access, and the firewall must allow the UDP port. Local and private addresses are allowed. No session is used.
Set up a test agent with the example objects and values first; a host name does not create one. Single-value OIDs usually need an instance suffix, such as the trailing .0 in sysDescr 1.3.6.1.2.1.1.1.0.
Prepare Credential $readCommunity$ and, for Set, $writeCommunity$ from approved test credentials. A community string (the SNMP password) is sent without encryption in v1 and v2c: use an approved test network and protect read and write community strings.
Get returns text. Walk returns a String Dictionary and a List of OIDs in order. Non-text values come back as text; check the format before you convert them. TimeTicks are hundredths of a second. Set makes a real write. It has no outputs and does not read the value back. Numbers must fit the data type and the agent's access rules. Do not assume that any OID is writable.
Get, Set and Walk fail if the agent returns an error, the community string is wrong, UDP is blocked or the time runs out.
Shared fields
Get, Set and Walk use these fields.
| Input | Editor field | Type; default | When / required | Use |
|---|---|---|---|---|
host | Host | Stringdefault "" | Required. | Agent host name, such as agent.example.com. |
port | Port | Numberdefault 161 | - | Agent UDP port, 1 through 65535; normally 161, or 1161 for a test agent. |
community | Community string | Credentialdefault Password public | - | The Credential Password is the community string; Username is ignored. An empty Password uses public. Use the read community for Get and Walk, the write community for Set. |
version | SNMP version | Snmpdefault V2c | - | V1 (SNMPv1) or V2c (SNMPv2c), the same as the agent. No SNMPv3. |
timeout | Timeout (seconds) | Numberdefault 5 | - | Positive whole seconds for each request, such as 5. Zero or less fails. |
oid | OID | Stringdefault "" | Required. | Numeric dotted OID, such as sysDescr 1.3.6.1.2.1.1.1.0; a leading period is accepted. Names from a MIB are not supported. Walk uses a subtree root, such as 1.3.6.1.2.1.1. |
Actions
Get (snmpGet)
Read one value at a known OID. For tables, use Walk.
Inputs
Uses the shared fields.
Outputs
| Output | Type | Meaning |
|---|---|---|
result | String | The first returned value as text, or empty if the answer has no values. |
Example
Set up a test agent at agent.example.com, UDP port 1161, with sysDescr 1.3.6.1.2.1.1.1.0 set to OCTET_STRING Sample agent. Select Credential $readCommunity$ with the read community string in Password. Set Host = agent.example.com, Port = 1161, Community string = $readCommunity$, SNMP version = V2c, Timeout (seconds) = 5, OID = 1.3.6.1.2.1.1.1.0. Bind result to String $description$.
Expected result
$description$ is Sample agent.
Set (snmpSet)
Write a value of a chosen type to the agent. The agent changes: test only on a writable test object.
Inputs
Also uses the shared fields.
| Input | Editor field | Type; default | When / required | Use |
|---|---|---|---|---|
data | Data type | Snmpdefault OCTET_ | - | Choose OCTET_ for text; INTEGER for signed 32-bit decimal; GAUGE32, COUNTER32 or TIME_ for unsigned 32-bit decimal; IP_ for an IP address; or OID for a numeric dotted object identifier. TIME_TICKS counts hundredths of a second. |
value | Value | Stringdefault "" | Required. | Enter text that fits Data type and the agent's writable object, for example sample-node for OCTET_STRING or 99 for TIME_TICKS. Signed integer range is -2147483648 through 2147483647; unsigned range is 0 through 4294967295. Invalid or out-of-range values fail. |
Outputs
No outputs. The write is logged with its host and OID. To confirm it, read the OID with Get.
Example
Prepare a test agent at agent.example.com, port 1161, with writable sysName 1.3.6.1.2.1.1.5.0. Select Credential $writeCommunity$ with the write community string in Password. Set Host = agent.example.com, Port = 1161, Community string = $writeCommunity$, SNMP version = V2c, Timeout (seconds) = 5, OID = 1.3.6.1.2.1.1.5.0, Data type = OCTET_STRING, Value = sample-node. Read the same OID with Get afterward.
Expected result
The agent stores sample-node if it accepts the write, and Get reads that text. A read-only object or a type the agent does not accept fails. Invalid values fail before anything is sent. Nothing is undone.
Walk (snmpWalk)
Read all objects under a subtree root, in agent order. The root only limits the walk; its own value is not read.
Inputs
Uses the shared fields.
Outputs
| Output | Type | Meaning |
|---|---|---|
result | Dictionary | Dotted OID keys and String values. |
oids | List | List of String OIDs in the order returned by the agent. Use it when order matters; the Dictionary does not keep the order. |
Example
Set up a test agent at agent.example.com, port 1161, containing sysDescr 1.3.6.1.2.1.1.1.0 = Sample agent and sysName 1.3.6.1.2.1.1.5.0 = sample-node. Set Host = agent.example.com, Port = 1161, Community string = $readCommunity$, SNMP version = V2c, Timeout (seconds) = 5, OID = 1.3.6.1.2.1.1. Bind Values by OID to Dictionary $values$ and OIDs in order to List $oids$.
Expected result
The Dictionary holds these OID keys with String values, and the List holds the same OIDs in order. Objects outside the subtree are left out. An empty subtree gives an empty Dictionary and List. The number and order of results depend on the agent.