Skip to content
Stand with Ukraine flag

SNMP

The SNMP Connector reads data from SNMP manager objects and writes data back to them, forwarding the results to ThingsBoard as device attributes and telemetry.

To enable this connector, add it to the connectors list in tb_gateway.json — see the General Configuration reference.

The connector reads its settings from a JSON file. Below is a full example with two device entries — the first using built-in converters, the second using a custom converter class:

{
"devices": [
{
"deviceName": "SNMP router",
"deviceType": "snmp",
"ip": "snmp.live.gambitcommunications.com",
"port": 161,
"pollPeriod": 5000,
"community": "public",
"attributes": [
{ "key": "ReceivedFromGet", "method": "get", "oid": "1.3.6.1.2.1.1.1.0", "timeout": 6 },
{ "key": "ReceivedFromMultiGet", "method": "multiget", "oid": ["1.3.6.1.2.1.1.1.0","1.3.6.1.2.1.1.2.0"], "timeout": 6 },
{ "key": "ReceivedFromGetNext", "method": "getnext", "oid": "1.3.6.1.2.1.1.1.0", "timeout": 6 },
{ "key": "ReceivedFromMultiWalk", "method": "multiwalk", "oid": ["1.3.6.1.2.1.1.1.0","1.3.6.0.1.2.1"] },
{ "key": "ReceivedFromBulkWalk", "method": "bulkwalk", "oid": ["1.3.6.1.2.1.1.1.0","1.3.6.1.2.1.1.2.0"] },
{
"key": "ReceivedFromBulkGet",
"method": "bulkget",
"scalarOid": ["1.3.6.1.2.1.1.1.0","1.3.6.1.2.1.1.2.0"],
"repeatingOid": ["1.3.6.1.2.1.1.1.0","1.3.6.1.2.1.1.2.0"],
"maxListSize": 10
}
],
"telemetry": [
{ "key": "ReceivedFromWalk", "community": "private", "method": "walk", "oid": "1.3.6.1.2.1.1.1.0" },
{ "key": "ReceivedFromTable", "method": "table", "oid": "1.3.6.1.2.1.1" }
],
"attributeUpdateRequests": [
{ "attributeFilter": "dataToSet", "method": "set", "oid": "1.3.6.1.2.1.1.1.0" },
{ "attributeFilter": "dataToMultiSet", "method": "multiset", "mappings": { "1.2.3": "10", "2.3.4": "${attribute}" } }
],
"serverSideRpcRequests": [
{ "requestFilter": "setData", "method": "set", "oid": "1.3.6.1.2.1.1.1.0" },
{ "requestFilter": "multiSetData", "method": "multiset" },
{ "requestFilter": "getData", "method": "get", "oid": "1.3.6.1.2.1.1.1.0" },
{ "requestFilter": "runBulkWalk", "method": "bulkwalk", "oid": ["1.3.6.1.2.1.1.1.0","1.3.6.1.2.1.1.2.0"] }
]
},
{
"deviceName": "SNMP router",
"deviceType": "snmp",
"ip": "127.0.0.1",
"pollPeriod": 5000,
"community": "public",
"converter": "CustomSNMPConverter",
"attributes": [
{ "key": "ReceivedFromGetWithCustomConverter", "method": "get", "oid": "1.3.6.1.2.1.1.1.0" }
],
"telemetry": [
{ "key": "ReceivedFromTableWithCustomConverter", "method": "table", "oid": "1.3.6.1.2.1.1.1.0" }
]
}
]
}

An array of device configurations. Each entry represents one SNMP manager device.

ParameterDefaultDescription
deviceNameSNMP routerDevice name in ThingsBoard
deviceTypesnmpDevice type in ThingsBoard
ipIP address or hostname of the SNMP manager
port161SNMP port
pollPeriod5000Polling interval in milliseconds
communitypublicDefault SNMP community string (public or private)
converter(Optional) Custom converter class name; omit to use the built-in converter
attributesArray of attribute mappings — see below
telemetryArray of telemetry mappings — see below
attributeUpdateRequests(Optional) Array of attribute-write configurations
serverSideRpcRequests(Optional) Array of RPC-triggered SNMP operation configurations

Sections “attributes” and “telemetry”

Section titled “Sections “attributes” and “telemetry””

Both sections share the same field structure. attributes entries are sent to ThingsBoard as device attributes; telemetry entries are sent as time-series telemetry.

ParameterDescription
keyThingsBoard attribute or telemetry key name
methodSNMP operation to use — see Supported methods
oidManager object identifier (string or array, depending on the method)

Method-specific parameters (e.g. timeout, community, scalarOid) are described in Supported methods.

Configurations in this section are optional. ThingsBoard allows the provision of device attributes and fetches some of them from the device application. You can treat this as a remote configuration for devices. Your devices are able to request shared attributes from ThingsBoard. See user guide for more details.

The “attributeUpdateRequests” configuration allows configuring the format of the corresponding attribute request and response messages.

ParameterDescription
attributeFilterShared attribute name to subscribe to
methodSNMP write method: set or multiset
oidObject identifier to write to (used with set)
mappingsOID-to-value map (used with multiset); values may reference ${attribute}
"attributeUpdateRequests": [
{
"attributeFilter": "dataToSet",
"method": "set",
"oid": "1.3.6.1.2.1.1.1.0"
},
{
"attributeFilter": "dataToMultiSet",
"method": "multiset",
"mappings": {
"1.2.3": "10",
"2.3.4": "${attribute}"
}
}
]

ThingsBoard allows sending RPC commands to the device connected to ThingsBoard directly or via Gateway.

Configuration, provided in this section is used for sending RPC requests from ThingsBoard to the device through the gateway.

ParameterDescription
requestFilterRPC method name to bind
methodSNMP operation to perform — see Supported methods
oidObject identifier (string or array, depending on the method)
"serverSideRpcRequests": [
{ "requestFilter": "setData", "method": "set", "oid": "1.3.6.1.2.1.1.1.0" },
{ "requestFilter": "multiSetData", "method": "multiset" },
{ "requestFilter": "getData", "method": "get", "oid": "1.3.6.1.2.1.1.1.0" },
{
"requestFilter": "runBulkWalk",
"method": "bulkwalk",
"oid": ["1.3.6.1.2.1.1.1.0","1.3.6.1.2.1.1.2.0"]
}
]
MethodOperationAccepts array OIDExtra parameters
getRead a single objectNotimeout
multigetRead multiple objects in one requestYestimeout
getnextRead the next object after the given OIDNotimeout
walkWalk the subtree rooted at OIDNocommunity
multiwalkWalk multiple subtreesYes
bulkwalkWalk multiple subtrees using BULK requestsYes
tableRead an SNMP tableNo
bulkgetRead scalars and repeating objects in one BULK requestscalarOid, repeatingOid, maxListSize
setWrite a value to a single objectNo
multisetWrite values to multiple objectsmappings

Reads a single SNMP object.

ParameterDescription
oidObject identifier to read
timeoutRequest timeout in seconds
{
"key": "ReceivedFromGet",
"method": "get",
"oid": "1.3.6.1.2.1.1.1.0",
"timeout": 6
}

Reads multiple SNMP objects in a single request.

ParameterDescription
oidArray of object identifiers to read
timeoutRequest timeout in seconds
{
"key": "ReceivedFromMultiGet",
"method": "multiget",
"oid": [
"1.3.6.1.2.1.1.1.0",
"1.3.6.1.2.1.1.2.0"
],
"timeout": 6
}

Reads the next object in the MIB tree after the given OID.

ParameterDescription
oidStarting OID
timeoutRequest timeout in seconds
{
"key": "ReceivedFromGetNext",
"method": "getnext",
"oid": "1.3.6.1.2.1.1.1.0",
"timeout": 6
}

Traverses the subtree rooted at the given OID. Accepts an optional community override.

ParameterDescription
oidRoot OID for the walk
community(Optional) Community string override for this operation
{
"key": "ReceivedFromWalk",
"community": "private",
"method": "walk",
"oid": "1.3.6.1.2.1.1.1.0"
}

Traverses multiple subtrees in a single operation.

ParameterDescription
oidArray of root OIDs to walk
{
"key": "ReceivedFromMultiWalk",
"method": "multiwalk",
"oid": [
"1.3.6.1.2.1.1.1.0",
"1.3.6.0.1.2.1"
]
}

Walks multiple subtrees using SNMP BULK requests (more efficient than multiwalk for large trees).

ParameterDescription
oidArray of root OIDs to walk
{
"key": "ReceivedFromBulkWalk",
"method": "bulkwalk",
"oid": [
"1.3.6.1.2.1.1.1.0",
"1.3.6.1.2.1.1.2.0"
]
}

Reads a full SNMP table.

ParameterDescription
oidOID of the table root
{
"key": "ReceivedFromTable",
"method": "table",
"oid": "1.3.6.1.2.1.1"
}

Reads scalar and repeating objects in a single SNMP BULK request.

ParameterDescription
scalarOidArray of non-repeating (scalar) OIDs
repeatingOidArray of repeating OIDs
maxListSizeMaximum number of repetitions to return
{
"key": "ReceivedFromBulkGet",
"method": "bulkget",
"scalarOid": [
"1.3.6.1.2.1.1.1.0",
"1.3.6.1.2.1.1.2.0"
],
"repeatingOid": [
"1.3.6.1.2.1.1.1.0",
"1.3.6.1.2.1.1.2.0"
],
"maxListSize": 10
}

Writes a value to a single SNMP object. Used in attributeUpdateRequests and serverSideRpcRequests.

ParameterDescription
oidObject identifier to write to
{
"attributeFilter": "dataToSet",
"method": "set",
"oid": "1.3.6.1.2.1.1.1.0"
}

Writes values to multiple SNMP objects in a single operation.

ParameterDescription
mappingsObject mapping OIDs to values; values may use ${attribute} to reference the incoming attribute value
{
"attributeFilter": "dataToMultiSet",
"method": "multiset",
"mappings": {
"1.2.3": "10",
"2.3.4": "${attribute}"
}
}