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", "type": "INTEGER" },
{ "attributeFilter": "dataToMultiSet", "method": "multiset", "mappings": { "1.2.3": "10", "2.3.4": "${attribute}" }, "type": "OCTETSTRING" }

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}
typeSNMP data type for value encoding (see Supported data types) — required only for set and multiset methods
"attributeUpdateRequests": [
{
"attributeFilter": "dataToSet",
"method": "set",
"oid": "1.3.6.1.2.1.1.1.0",
"type": "INTEGER"
},
{
"attributeFilter": "dataToMultiSet",
"method": "multiset",
"mappings": {
"1.2.3": "10",
"2.3.4": "${attribute}"
},
"type": "OCTETSTRING"
}
]

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",
"type": "IPADDRESS"
},
{
"requestFilter": "dataToMultiSet",
"method": "multiset",
"mappings": [
{
"oid": "1.3.6.1.2.1.1.9.0",
"value": "44"
},
{
"oid": "1.3.6.1.2.1.1.10.0",
"type": "INTEGER",
"value": "${params.temperature}"
},
{
"oid": "1.3.6.1.2.1.1.11.0",
"type": "GAUGE",
"value": "${params.pressure}"
}
],
"type": "INTEGER"
},
{
"requestFilter": "dataToMultiSetBroadcast",
"method": "multiset",
"mappings": [
{
"oid": "1.3.6.1.2.1.1.12.0",
"value": "${params}"
},
{
"oid": "1.3.6.1.2.1.1.13.0",
"value": "${params}"
}
],
"type": "INTEGER"
},
{
"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 objectNotype
multisetWrite values to multiple objectsmappings, type

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
typeSNMP data type for value encoding — see Supported data types
{
"attributeFilter": "dataToSet",
"method": "set",
"oid": "1.3.6.1.2.1.1.1.0",
"type": "GAUGE"
}

Writes values to multiple SNMP objects in a single operation. The shape of mappings depends on where the method is used.

In attributeUpdateRequestsmappings is an object mapping OIDs directly to values:

ParameterDescription
mappingsObject mapping OIDs to values; values may use ${attribute} to reference the incoming attribute value
typeSNMP data type for value encoding — see Supported data types
{
"attributeFilter": "dataToMultiSet",
"method": "multiset",
"mappings": {
"1.2.3": "10",
"2.3.4": "${attribute}"
},
"type": "COUNTER"
}

In serverSideRpcRequestsmappings is an array of objects, each with its own oid and value, and an optional per-mapping type override:

ParameterDescription
mappingsArray of { oid, value, type } objects
mappings[].oidObject identifier to write to
mappings[].valueValue to write to the OID; use a JSON-path expression to extract data packed in the RPC call’s params object, or just a constant value
mappings[].type(Optional) Per-mapping SNMP data type override — see Supported data types
typeDefault SNMP data type applied to mappings that don’t specify their own type — see Supported data types; (Optional) if type is set on every mapping
{
"requestFilter": "dataToMultiSet",
"method": "multiset",
"mappings": [
{
"oid": "1.3.6.1.2.1.1.9.0",
"value": "62"
},
{
"oid": "1.3.6.1.2.1.1.10.0",
"type": "INTEGER",
"value": "${params.temperature}"
},
{
"oid": "1.3.6.1.2.1.1.11.0",
"type": "GAUGE",
"value": "${params.pressure}"
}
],
"type": "INTEGER"
}
TypeDescriptionExample
INTEGERWhole number (positive or negative)42, -100
COUNTERNon-negative integer that monotonically increases until reaching 4,294,967,295, then wraps to zero1500
COUNTER6464-bit non-negative integer that monotonically increases until reaching 18,446,744,073,709,551,615, then wraps to zero9223372036854775807
GAUGENon-negative integer for gauges and measurements that can increase or decrease75
TIMETICKSTime value in units of 0.01 seconds (hundredths of a second)12345678
OCTETSTRINGString of bytes (octets)"hello"
IPADDRESSIPv4 address in dotted-decimal notation"192.168.1.1"