Legrand / Raritan Xerus™ JSON-RPC API for Remote Access Devices like KX4-101, KX3G2

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 xeruskvm.rpc.devsettings
snmp_proxy = xeruskvm.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 of 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 Event Rules and Actions 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 xeruskvm.rpc.event
event_engine = xeruskvm.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 = [
xeruskvm.rpc.event.KeyValue("SnmpNotfType", "v2Inform"),
xeruskvm.rpc.event.KeyValue("SnmpTrapDest1", "192.168.0.42:162:private"),
xeruskvm.rpc.event.KeyValue("SnmpNotfTimeout", "3"),
xeruskvm.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 xeruskvm.rpc.datetime
datetime_proxy = xeruskvm.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 = xeruskvm.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 xeruskvm.rpc.devsettings
cfg = xeruskvm.rpc.devsettings.Smtp.Configuration(
host = "mail.company.example",
port = 25,
useTls = False,
allowOffTimeRangeCerts = False,
caCertChain = "",
sender = "notification@company.example",
useAuth = False,
username = "",
password = "",
retryCount = 5,
retryInterval = 3
)
smtp_proxy = xeruskvm.rpc.devsettings.Smtp("/smtp", agent)
smtp_proxy.setConfiguration(cfg)