1. Introduction to Zenpacks

A ZenPack is a package that adds new functionality to the Zenoss Core. A ZenPack may add Action Rules, Event Classes, Event Commands, User Commands, Service Classes, Data Sources, Graphs, Performance Templates, Reports, Model Extensions or Product Definitions. A ZenPack may also add new daemons and new UI features such as menus.

ZenPacks are a mechanism for extending and modifying Zenoss. This can be as simple as adding new Device Classes or Performance Templates or as complex as extending the data model and providing new collection daemons. ZenPacks can be distributed (as .zip files) for installation on other Zenoss systems. Simple ZenPacks can be created completely within the Zenoss user interface while more complex ZenPacks require development of scripts or daemons in Python or another programming language.

For example, say you have developed a Performance Template for a new piece of hardware. You've created Data Sources for the OID's you think are worth monitoring, Thresholds to make sure some of these values stay within reasonable limits and several Graph Definitions to show this data graphically. Perhaps you've also created a new Device Class for this hardware. You can create a ZenPack to easily distribute your Performance Template and Device Class to other Zenoss administrators. This ZenPack can be entirely created from within the Zenoss user interface.

For another example, say you want to monitor a new piece of software running on one of your servers. You would like to monitor several performance metrics of this software, but they are available only via a programmatic API provided with the software. You could develop a new collector daemon to gather data via this API and provide it back to Zenoss. You might also create a new type of Data Source to provide configuration data for the new collector. Obviously this effort would require development skills and intimate knowledge of Zenoss not necessary for the previous example, but this functionality can still be distributed as a ZenPack.

1.1. Installing ZenPacks

ZenPacks can be installed either from the command line on the Zenoss server or via the Zenoss user interface.

1.1.1. Installing via the Command Line

The following ZenPack command can be used from the command line to install .zip ZenPack files:

zenpack run --install filename

This unzips the specified file into $ZENHOME/Products/<ZenPackId> and installs the ZenPack into Zenoss. If you are authorizing a ZenPack you may sometimes want to install from a directory rather than a .zip file. The zenpack command can also take a directory as an option:

zenpack --install directoryname

This copies the contents of the given directory into $ZENHOME/Products/<ZenPackId> and installs it. It is important to note that all files in the original directory have been copied, so further changes to those files will not take effect until you again install from that directory. You can avoid this if you wish by specifying --link to the zenpack command. This directs zenpack to create a symlink in $ZENHOME/Products rather than a copy of the directory you specify. This is often the most convenient way to install a ZenPack when the ZenPack is maintained in version control system.

zenpack --link --install directoryname

1.1.2. Installing via the User Interface

You can upload and install a ZenPack .zip file via the user interface. From the Settings->ZenPacks page choose the Install Zenpack... menu item. In the dialog that follows use the Browse button to select the .zip file from your local computer. When you click the OK button the file is uploaded to the Zenoss server and installed.

1.1.3. Installing All Core ZenPacks via RPM

Zenoss also provides an RPM to the Zenoss Core ZenPacks. To install the ZenPacks from the ZenPack RPMs:

  1. Make sure zeo is running.

  2. As root user, run the following command:

rpm -ihv <rpm name>

1.2. Creating a ZenPack

While logged into Zenoss as an Administrator click on Settings then on the ZenPacks tab. Use the "Create a ZenPack..." menu item from the page menu to create a new ZenPack. A dialog asks for the name of the new ZenPack as well as some other basic information. When you click the Save button the new ZenPack object is created in the database and a corresponding directory is created in $ZENHOME/Products/<NewZenPackId>.

Many types of objects can be added to a ZenPack via the user interface. Some examples are:

  • Device Classes

  • Event Classes

  • Event Mappings

  • User Commands

  • Event Commands

  • Service Classes

  • Device Organizers

  • Performance Templates

Devices are the conspicuous omission from this list. Any individual Device is usually specific to a particular site and therefore not likely to be useful to other Zenoss users.

To add one of these database objects to a ZenPack navigate to that object and use the "Add to ZenPack..." menu item. Zenoss will present a dialog which lists all installed ZenPacks. Select the ZenPack to which you want to add this object and click the Add button. To view the objects that are part of a ZenPack navigate to the Settings page then the ZenPacks tab. Click on the name of the ZenPack and you will see a page that lists both the files and the objects that are part of this ZenPack. You can remove objects from the ZenPack by selecting the checkboxes next to them and using the "Delete from ZenPack..." menu item.

ZenPack items which are not database objects are added to a ZenPack by placing them in the correct location within $ZENHOME/Products/<YourZenPackId>. This is how you would add daemons, reports, skins, etc. See Section 22.5 An Example ZenPack and Section 22.6 ZenPack Structure for more details on how to include these types of items within a ZenPack.

Discussion regarding development of ZenPacks takes place on the zenoss-dev mailing list and forumns: http://community.zenoss.com/forums/viewforum.php?f=3

1.2.1. Packaging and Distributing Your ZenPack

ZenPacks are usually distributed as .zip files. To create the installable .zip file for a ZenPack use the "Export ZenPack..." menu item in the page menu when viewing a ZenPack. The dialog that follows has two options. The first option simply exports the ZenPack to a file named <ZenPackId>.zip in the $ZENHOME/exports directory on the Zenoss server. The second option does the same but then downloads the exported file to your browser. Other Zenoss administrators can install this exported .zip file as described in Section 22.1 Installing ZenPacks.

For information on how to make your ZenPack available on the zenoss.com site see http://www.zenoss.com/community/projects/zenpacks/how-to-contribute-a-zenpack

1.3. Example ZenPack

HelloWorldZenPack is an example ZenPack and a good starting point for creating your own ZenPacks. The code and comments in its files provide more detail as to the workings of the install process and other aspects of ZenPacks. HelloWorldZenPack and other Community ZenPacks are available at http://www.zenoss.com/community/projects/zenpacks

1.4. ZenPack Structure

Using HelloWorldZenPack as a model, this section describes the structure and features of a ZenPack.

1.4.1. HelloWorldZenPack/

In the top level directory of our ZenPack contains our Model Extensions, this would be the Python code that may extend the existing object model in any way. In this example, we have two files, init.py and HelloWorld.py. You are not required to have an init.py file or any other files at this level. You are also not restricted to any particular number of files.

1.4.2. HelloWorldZenPack/init.py

Just like in a Python module, init.py contains any initialization code for your ZenPack.

1.4.3. HelloWorldZenPack/HelloWorld.py

Includes some example Model Extensions, which illustrates the implementation of new objects with attributes and relationships. In the file, Device, Group, Location, Admin classes are defined. Each class has an attribute and some sort of relationship with one another.

1.4.4. HelloWorldZenPack/daemons

This directory should exist in the ZenPack however this directory may be left empty. This directory contains binaries which represent additional daemons for Zenoss.

Once the ZenPack is installed the daemon will be started during a zenoss start.

1.4.5. HelloWorldZenPack/datasources

Classes in this directory are subclasses of ZenModel.RRDDataSource.RRDDataSource and provide new types of data sources which are made available within the Zenoss UI.

1.4.6. HelloWorldZenPack/modeler

This directory should exist in the ZenPack however this directory may be left empty.

1.4.7. HelloWorldZenPack/objects

This directory should exist in the ZenPack however this directory may be left empty. This directory contains xml files to be imported into the ZeoDB. When imported a object will be instantiated based on the data in the xml files. Each xml may contain one or many object definitions.

In the directory, we have example for an EventClass, EventClassInst, EventCommand, ServiceClass, RRDTemplate, and UserCommand. These objects may be any object you wish to export from an existing Zenoss core. (see How do I export objects to xml?)

1.4.8. HelloWorldZenPack/skins

This directory should exist in the ZenPack however this directory may be left empty. This directory contains page templates that add new UI to Zenoss.

The "skins" directory will be registered as a Directory View and acts like other "skins" directories within $ZENHOME/Products directory.

1.5. Removing a ZenPack

Warning: Removing a ZenPack can have unexpected consequences. For example, removing a ZenPack that installed a Device Class will remove both the Device Class and all Devices within that class. Also, before removing a ZenPack you should delete any Data Source of a type provided by the ZenPack. You should always perform a backup of your Zenoss data before removing a ZenPack. See Section 21.1 Backup and Restore for information on how to backup your Zenoss data.