Legrand / Raritan / Server Technology Xerus™ JSON-RPC API

Loading...
Searching...
No Matches
Device Settings

# SNMP Agent

The SNMP agent is configured using the devsettings.Snmp interface that can be found at the well-known URI `/snmp`. The configuration is retrieved with getSettings and written with setSettings.

Note
  The SNMPv3 agent uses a user-based security model. User passphrases and privilege levels are configured with the user management interface.

# Python example: Set SNMPv2 write community and sysName
import raritan.rpc.devsettings
snmp_proxy = raritan.rpc.devsettings.Snmp("/snmp", agent)
cfg = snmp_proxy.getConfiguration()
cfg.v2enable = True
cfg.writeComm = "private"
cfg.sysName = "Rack 17A"
snmp_proxy.setConfiguration(cfg)

# SNMP Notifications

Configuration SNMP traps and informs is not straight-forward because there is no dedicated interface for it. It is done by modifying pre-defined rules and actions of the event rules engine. See eventengine for more details.

Notifications are enabled or disabled by setting the isEnabled flag in the rule with id `SystemSnmpTrapRule`. Notification types and destinations are configured with the arguments vector of the `SystemSnmpTrapAction` action. Action arguments are key-value pairs, with the following keys being supported:

- SnmpNotfType: Notification type. One of "v2Trap", "v2Inform", "v3Trap", "v3Inform"
- SnmpTrapDest1: Primary trap destination, format: "<host>:<port>:<community>"
- SnmpTrapDest2: Optional second destination (SNMPv2 only)
- SnmpTrapDest3: Optional third destination (SNMPv2 only)
- SnmpNotfTimeout: Timeout in seconds for SNMPv2/SNMPv3 informs
- SnmpNotfRetries: Number of retries for SNMPv2/SNMPv3 informs
- SnmpNotfV3SecName: SNMPv3 security/user name
- SnmpNotfV3SecLevel: SNMPv3 security level. One of: "noAuthNoPriv", "authNoPriv", "authPriv"
- SnmpNotfV3AuthProto: SNMPv3 authentication protocol. One of: "md5", "sha"
- SnmpNotfV3AuthKey: SNMPv3 authentication passphrase
- SnmpNotfV3PrivProto: SNMPv3 privacy protocol. One of: "des", "aes"
- SnmpNotfV3PrivKey: SNMPv3 privacy passphrase

# Python example: Enable SNMPv2 informs for all events
import raritan.rpc.event
event_engine = raritan.rpc.event.Engine("/event_engine", agent)
# Enable rule with ID 'SystemSnmpTrapRule'
event_engine.enableRule("SystemSnmpTrapRule")
# Configure notification type and destination in 'SystemSnmpTrapAction'
for action in event_engine.listActions():
if action.id == 'SystemSnmpTrapAction':
action.arguments = [
raritan.rpc.event.KeyValue("SnmpNotfType", "v2Inform"),
raritan.rpc.event.KeyValue("SnmpTrapDest1", "192.168.0.42:162:private"),
raritan.rpc.event.KeyValue("SnmpNotfTimeout", "3"),
raritan.rpc.event.KeyValue("SnmpNotfRetries", "5")
]
event_engine.modifyAction(action)

# Date and Time

System time is configured with the datetime.DateTime interface at `/datetime`. The following settings can be configured:

- Set a device-local time or synchronize with NTP server
- For NTP: Use servers from DHCP (if enabled) or configure them manually
- Device time zone

# Python example: Set time zone and NTP servers
import raritan.rpc.datetime
datetime_proxy = raritan.rpc.datetime.DateTime("/datetime", agent)
cfg = datetime_proxy.getCfg()
# find time zone by name
for zone in datetime_proxy.getZoneInfos(False):
if zone.name.find("Taipei") >= 0:
cfg.zoneCfg.id = zone.id
cfg.zoneCfg.enableAutoDST = zone.hasDSTInfo
cfg.protocol = raritan.rpc.datetime.DateTime.Protocol.NTP
cfg.ntpCfg.forceStatic = True
cfg.ntpCfg.server1 = "0.pool.ntp.org"
datetime_proxy.setCfg(cfg)

# SMTP Server

The SMTP server for mail notifications is configured using the devsettings.Smtp interface at `/smtp`.

# Python example: Configure SMTP server
import raritan.rpc.devsettings
cfg = raritan.rpc.devsettings.Smtp.Configuration(
host = "mail.company.example",
port = 25,
useTls = False,
allowOffTimeRangeCerts = False,
caCertChain = "",
sender = "pdu-notification@company.example",
useAuth = False,
username = "",
password = "",
retryCount = 5,
retryInterval = 3
)
smtp_proxy = raritan.rpc.devsettings.Smtp("/smtp", agent)
smtp_proxy.setConfiguration(cfg)