Archived community.zenoss.org | full text search
Skip navigation
Currently Being Moderated

8.1 1 Adding Devices Programatically

VERSION 3  Click to view document history
Created on: Oct 26, 2009 4:01 PM by Zenoss API - Last Modified:  Feb 3, 2010 4:36 PM by Chet Luther

#8.1. Adding Devices Programatically

Devices can be added to Zenoss through the UI but also through a programmatic interface. This how to will describe adding a device using that interface.

#8.1.1. Using a REST call

Adding a device through a rest call can be done by a simple web get. In this example we will use wget to add a device. If you use wget don't forget to escape the "&" or wrap the URL in single quotes.

$ wget
      'http://admin:zenoss@MYHOST:8080/zport/dmd/DeviceLoader/loadDevice\
?deviceName=NEWDEVICE&devicePath=/Server/Linux'

The result of this command will be the log of auto-discovery and you can look for the string "NEWDEVICE loaded!" to see if it was successful. Possible failure messages are: "NEWDEVICE exists" and "no snmp found"

#8.1.2. Using an XML-RPC Call from Python

This is an example of how to add a device using Python. Because XML-RPC can be used from any language feel free to use your favorite. What is important here 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()

#8.1.3. XML-RPC Attributes

#

Table 8.1. XML-RPC Attributes and Descriptions

XML-RPC AttributesDescription
deviceNamethe name or IP of the device. If it's a name it must resolve in DNS
devicePaththe device class where the first "/" starts at "/Devices" like "/Server/Linux" the default is "/Discovered"
tagthe tag of the device
serialNumberthe serial number of the device
zSnmpCommunitySNMP community to use during auto-discovery if none is given the list zSnmpCommunities will be used
zSnmpPortSNMP port to use default is 161
zSnmpVerSNMP version to use default v1 other valid values are v2
rackSlotthe rack slot of the device.
productionStateproduction state of the device default is 1000 (Production)
commentsany comments about the device
hwManufacturerhardware manufacturer this must exist in the database before the device is added
hwProductNamehardware product this must exist in the manufacturer object specified
osManufacturerOS manufacturer this must exist in the database before the device is added
osProductNameOS product this must exist in the manufacturer object specified
locationPathpath to the location of this device like "/Building/Floor" must exist before device is added
groupPathslist of groups for this device multiple groups can be specified by repeating the attribute in the URL
systemPathslist of systems for this device multiple groups can be specified by repeating the attribute in the URL
statusMonitorslist of status monitors (zenping) for this device default is "localhost"
performanceMonitorperformance monitor to use default is "localhost"
discoverProtodiscovery protocol default is "snmp" other possible value is "none"

Comments (6)