The first thing we’ll need to do is install the ZenPackLib ZenPack into our development system. This is done in the same way as it would be in any Zenoss system.
The ZenPackLib ZenPack provides the zenpacklib command line tool, which will allow us to create ZenPacks.
This tutorial assumes your system is already setup as described in Development Environment.
The latest version of ZenPackLib can be downloaded from its entry in the ZenPack Catalog. Note that you may already have the latest version installed on your system. The following commands show how you would download and install version 2.1.1.
From here on all commands should be run as the zenoss user on the host unless otherwise noted. If you don't login to the host as the zenoss user, use
su - zenoss to get a login shell.
Executing zenpacklib requires a live Zenoss environment. Always executing it as the zenoss user in your Zope container is a good way to have the right environment setup. The following commands demonstrate how to do this.
These five commands can be reduced to the following single command if you setup the helper aliases and functions your
.bashrc recommended in the Helper and Aliases and Functions section of the Development Environment page.
Creating a ZenPack
There are two ways to get started with zenpacklib. You can either use it to create a new ZenPack from the command line, or you can update an existing ZenPack to use it. We’ll start by creating a ZenPack from the command line.
Run the following commands to create a new ZenPack.
This will print several lines to let you know what has been created. Note that the ZenPack’s source directory has been created, but it has not yet been installed.
Now let’s take a look at zenpack.yaml. This is the file that will define a large part of what our ZenPack is.
Let’s add a device class and a monitoring template to our ZenPack. Change zenpack.yaml to contain the following:
Check for Correctness
Now that we have a more interesting zenpack.yaml, let’s have zenpacklib check that it’s correct. This can be done using the lint command.
Lint will print information about errors it finds in the YAML file. If nothing is printed, lint thinks the YAML is correct.
Installing a ZenPack
Now that we’ve created a ZenPack called ZenPacks.acme.Widgeter in /z, we can install it into our Zenoss system by running the following command.
Zenoss must be restarted anytime a new ZenPack is installed. A full restart of the entire system can be performed by running one of the following commands depending on what distribution of Zenoss you have installed.
Technically it isn’t necessary to restart everything. A lot of the infrastructure services don’t use ZenPack code. The following is a smaller list of services that you’re likely to need to restart after installing and modifying ZenPacks during development.
The following command will quickly restart just these services.