Add a Device Class

To support adding our special WundergroundDevice devices that we defined in to Zenoss we must create a new device class. This will give us control of the zPythonClass configuration property that defines what type of devices will be created. It will also allow us to control what modeler plugins and monitoring templates will be used.

Use the following steps to add the device class.

  1. Add the following content to the end of $ZP_DIR/zenpack.yaml.
      zPingMonitorIgnore: true
      zSnmpMonitorIgnore: true
        - WeatherUnderground.Locations

Let’s take a look at what we’re doing here.

  1. First we’re saying the device class is going to be /WeatherUnderground. We add it at the top level because it doesn’t fall into one of the existing categories like /Server or /Network.
  2. Next we set zPythonClass to The zPythonClass property controls what type of device will be created in this device class. Note that the value for this is the name of the ZenPack followed by the name of the class we created in the above classes section.
  3. We then set both zPingMonitorIgnore and zSnmpMonitorIgnore to true to prevent any ping or SNMP monitoring Zenoss would perform on the device by default. Neither of these make sense since we’re dealing with an HTTP API, not a traditional device.
  4. Finally we set zCollectorPlugins to contain the name of the modeler plugin we created in the previous section. Note that zCollectorPlugins is a lines property, meaning it accepts multiple values in a list format.
  1. Reinstall the ZenPack to create the device class.
zenpack --link --install $ZP_TOP_DIR
  1. Restart Zenoss to make sure all of the changes in our ZenPack are picked up.
zenoss restart

Add a Device

Now would be a good time to add a device to the new device class. There are many ways to add a device to Zenoss. Either of the following approaches can be easily done from the command line.

Using zendisc

Using zendisc is the easiest way to add device from the command line. However, it only lets you specify the device class and the device’s address.

Run the following command to add

zendisc run --deviceclass=/WeatherUnderground

You should see output similar to the following.

INFO zen.ZenModeler: Collecting for device
INFO zen.ZenModeler: No WMI plugins found for
INFO zen.ZenModeler: Python collection device
INFO zen.ZenModeler: plugins: WeatherUnderground.Locations
INFO zen.PythonClient: collecting data
ERROR zen.PythonClient: zWundergroundAPIKey not set. Get one from
INFO zen.PythonClient: Python client finished collection for
WARNING zen.ZenModeler: The plugin WeatherUnderground.Locations returned no results.
INFO zen.ZenModeler: No change in configuration detected
INFO zen.ZenModeler: No command plugins found for
INFO zen.ZenModeler: SNMP monitoring off for
INFO zen.ZenModeler: No portscan plugins found for
INFO zen.ZenModeler: Scan time: 0.02 seconds
INFO zen.ZenModeler: Daemon ZenModeler shutting down


The error about zWundergroundAPIKey not being set is expected because we haven’t set it. The solution is to go to the device in the web interface and add your API key to the zWundergroundAPIKey configuration property. After adding the API key you should remodel the device.

Using zenbatchload

Another good way to add a device to Zenoss from the command line is zenbatchload. Using zenbatchload also allows us to set configuration properties such as zWundergroundAPIKey as the device is added.

Create a wunderground.zenbatchload file with the following contents.

/Devices/WeatherUnderground zWundergroundAPIKey='<your-api-key>', zWundergroundLocations=['Austin, TX', 'Des Moines, IA']

Now run the following command to load from that file.

zenbatchload wunderground.zenbatchload

You should now be able to see a list of locations on the device!