Adding a device through a rest call can be done by a simple Web get. For example:
$ wget --auth-no-challenge 'http://admin:zenoss@MYHOST:8080/zport/dmd/DeviceLoader/loadDevice\ ?deviceName=NEWDEVICE&devicePath=/Server/Linux'
When using wget, you must escape ampersands (&) and wrap the URL in single quotes.
The result of this command will be the log of auto-discovery. Look in this log for the string "NEWDEVICE loaded!" to see if the add was successful. Possible failure messages are: "NEWDEVICE exists" and "no snmp found."
This example shows how to add a device by using Python. Because XML-RPC can be used from any language, your use may differ. The important information is the base URL in
ServerProxy, passing positional parameters, and calling
loadDevice on your proxy object.
>>> from xmlrpclib import ServerProxy >>> url = 'http://admin:zenoss@MYHOST:8080/zport/dmd/DeviceLoader' >>> serv = ServerProxy(url) >>> serv.loadDevice('NEWDEVICE', '/Server/Linux')
You can check on the device with another XML-RPC call:
>>> from xmlrpclib import ServerProxy >>> cp = 'Devices/Server/Linux/devices' >>> url = 'http://admin:zenoss@MYHOST:8080/zport/dmd/%s/NEWDEVICE' % cp >>> serv = ServerProxy(url) >>> print serv.getManageIp()
Table 8.1. XML-RPC Attributes and Descriptions
|deviceName||the name or IP of the device. If it's a name it must resolve in DNS|
|devicePath||the device class where the first "/" starts at "/Devices" like "/Server/Linux" the default is "/Discovered"|
|tag||the tag of the device|
|serialNumber||the serial number of the device|
|zSnmpCommunity||SNMP community to use during auto-discovery if none is given the list zSnmpCommunities will be used|
|zSnmpPort||SNMP port to use default is 161|
|zSnmpVer||SNMP version to use default v1 other valid values are v2|
|rackSlot||the rack slot of the device.|
|productionState||production state of the device default is 1000 (Production)|
|comments||any comments about the device|
|hwManufacturer||hardware manufacturer this must exist in the database before the device is added|
|hwProductName||hardware product this must exist in the manufacturer object specified|
|osManufacturer||OS manufacturer this must exist in the database before the device is added|
|osProductName||OS product this must exist in the manufacturer object specified|
|locationPath||path to the location of this device like "/Building/Floor" must exist before device is added|
|groupPaths||list of groups for this device multiple groups can be specified by repeating the attribute in the URL|
|systemPaths||list of systems for this device multiple groups can be specified by repeating the attribute in the URL|
|statusMonitors||list of status monitors (zenping) for this device default is "localhost"|
|performanceMonitor||performance monitor to use default is "localhost"|
|discoverProto||discovery protocol default is "snmp" other possible value is "none"|