Raritan PX2/PX3 JSON-RPC API
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.
1 # Python example: Set SNMPv2 write community and sysName
2 
3 import raritan.rpc.devsettings
4 
5 snmp_proxy = raritan.rpc.devsettings.Snmp("/snmp", agent)
6 
7 cfg = snmp_proxy.getConfiguration()
8 cfg.v2enable = True
9 cfg.writeComm = "private"
10 cfg.sysName = "Rack 17A"
11 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 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:

1 # Python example: Enable SNMPv2 informs for all events
2 
3 import raritan.rpc.event
4 
5 event_engine = raritan.rpc.event.Engine("/event_engine", agent)
6 
7 # Enable rule with ID 'SystemSnmpTrapRule'
8 event_engine.enableRule("SystemSnmpTrapRule")
9 
10 # Configure notification type and destination in 'SystemSnmpTrapAction'
11 for action in event_engine.listActions():
12  if action.id == 'SystemSnmpTrapAction':
13  action.arguments = [
14  raritan.rpc.event.KeyValue("SnmpNotfType", "v2Inform"),
15  raritan.rpc.event.KeyValue("SnmpTrapDest1", "192.168.0.42:162:private"),
16  raritan.rpc.event.KeyValue("SnmpNotfTimeout", "3"),
17  raritan.rpc.event.KeyValue("SnmpNotfRetries", "5")
18  ]
19  event_engine.modifyAction(action)

Date and Time

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

1 # Python example: Set time zone and NTP servers
2 
3 import raritan.rpc.datetime
4 
5 datetime_proxy = raritan.rpc.datetime.DateTime("/datetime", agent)
6 
7 cfg = datetime_proxy.getCfg()
8 
9 # find time zone by name
10 for zone in datetime_proxy.getZoneInfos(False):
11  if zone.name.find("Taipei") >= 0:
12  cfg.zoneCfg.id = zone.id
13  cfg.zoneCfg.enableAutoDST = zone.hasDSTInfo
14 
15 cfg.protocol = raritan.rpc.datetime.DateTime.Protocol.NTP
16 cfg.ntpCfg.forceStatic = True
17 cfg.ntpCfg.server1 = "0.pool.ntp.org"
18 
19 datetime_proxy.setCfg(cfg)

SMTP Server

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

1 # Python example: Configure SMTP server
2 
3 import raritan.rpc.devsettings
4 
5 cfg = raritan.rpc.devsettings.Smtp.Configuration(
6  host = "mail.company.example",
7  port = 25,
8  useTls = False,
9  allowOffTimeRangeCerts = False,
10  caCertChain = "",
11  sender = "pdu-notification@company.example",
12  useAuth = False,
13  username = "",
14  password = "",
15  retryCount = 5,
16  retryInterval = 3
17 )
18 
19 smtp_proxy = raritan.rpc.devsettings.Smtp("/smtp", agent)
20 smtp_proxy.setConfiguration(cfg)