SNMP Write
x/snmpWrite component: v0.37 .0+ Writes (Set) OID values to network/facility devices (switches/routers/UPS/sensors, etc.) over the SNMP protocol (v1/v2c/v3).
Additional extension library required: rulego-components-iot (opens new window)
# Configuration
The connection configuration is identical to x/snmpRead; all fields are listed below:
| Field | Type | Description | Default |
|---|---|---|---|
| server | string | Device address (host or host:port, default port 161) | 127.0.0.1:161 |
| version | string | SNMP version, options: v1/v2c/v3 | v2c |
| community | string | Community string (used by v1/v2c) | public |
| timeout | int | Request timeout in seconds | 5 |
| v3 Security | The following fields are used only when version=v3 (SNMPv3 USM security model) | ||
| securityLevel | string | Security level, options: noAuthNoPriv/authNoPriv/authPriv | noAuthNoPriv |
| username | string | v3 user name | None |
| authProtocol | string | Authentication protocol, options: None/MD5/SHA/SHA224/SHA256/SHA384/SHA512 | None |
| authPassword | string | Authentication password | None |
| privProtocol | string | Privacy (encryption) protocol, options: None/DES/AES/AES192/AES256 | None |
| privPassword | string | Privacy password | None |
| points | Default point table | ||
| points | []Point | Default point list to write; when msg.Data carries valid points, msg.Data takes precedence | None |
# Point Fields
Fields of each Point (the write node uses name/addr/type/value):
| Field | Type | Description | Default |
|---|---|---|---|
| name | string | Point name (optional) | None |
| addr | string | SNMP OID to write, e.g. 1.3.6.1.2.1.1.5.0 | None |
| type | string | Value type, required, see the table below | None |
| value | string | Value in string form, supports ${msg.xx} placeholders | None |
| scale | float | Optional scale multiplier; conversion formula eng = raw*scale + offset | 1 |
| offset | float | Optional offset | 0 |
type options (write value types):
| type | Description | Aliases |
|---|---|---|
Integer | Integer | integer, int |
OctetString | Byte string / string | octetstring, string |
ObjectIdentifier | OID | objectidentifier, oid |
IPAddress | IP address | ipaddress, ip |
Counter32 | 32-bit counter | - |
Gauge32 | 32-bit gauge | gauge32, uint32 |
TimeTicks | Time ticks | timeticks |
Counter64 | 64-bit counter | counter64 |
# Input
Write points are read from msg.Data (a JSON array). If msg.Data is empty, the configured points are used. Format:
[
{ "addr": "1.3.6.1.2.1.1.5.0", "type": "OctetString", "value": "router-01" },
{ "addr": "1.3.6.1.2.1.1.6.0", "type": "OctetString", "value": "${msg.location}" }
]
1
2
3
4
2
3
4
valuesupports${msg.xx}/${metadata.xx}template variables. If any point fails to write, the node returns an error immediately and does not process subsequent points.
# Features
- Template variables: the
addr/type/valuefields support${msg.xx}/${metadata.xx}placeholders. - Dynamic points: when
msg.Datacarries a valid point list (JSON array), it takes precedence — handy when points must be decided at runtime. - Same-chain connection pool: enables
ref://in-chain connection reuse; other nodes in the chain can borrow the connection by node ID to avoid reconnecting. See Component Connection Reuse. - Auto reconnect & retry: on write failure the node reconnects and retries up to 3 times (
maxRetries=3). - SNMPv3 USM: fully supports the v3 User Security Model (authentication + encryption).
# Relation Type
- Success: On success, the message is sent to the
Successchain (the message payload is unchanged). - Failure: On failure, the message is sent to the
Failurechain.
# Example
{
"ruleChain": {
"name": "snmp write demo",
"root": true
},
"metadata": {
"nodes": [
{
"type": "x/snmpWrite",
"name": "write device config",
"configuration": {
"server": "192.168.1.1:161",
"version": "v2c",
"community": "private",
"timeout": 5,
"points": [
{ "name": "sysName", "addr": "1.3.6.1.2.1.1.5.0", "type": "OctetString", "value": "core-switch-01" },
{ "name": "sysLocation", "addr": "1.3.6.1.2.1.1.6.0", "type": "OctetString", "value": "${msg.location}" }
]
}
}
]
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Edit this page on GitHub (opens new window)
Last Updated: 2026/07/29, 07:07:39