Applies To
- Zenoss 4.x
Summary
When writing event transforms or researching how events are mapped to certain event classes, it is often useful to have a complete list of all event classes and their event class keys, and the Resource Manager UI doesn't provide this information in one place. The Python script included in this article lists the name of every event class and all of its associated event class keys (if any) in your Zenoss instance. Run the script from the command line on the Zenoss master server as the zenoss user. It does not require invoking zendmd.
Procedure
- Connect to the Zenoss master server as the zenoss user.
Note: when switching to the zenoss user using the su command, you must specify the “-” option in order to update your PATH to include the zenoss user's bin directory. For example: “su - zenoss”. Otherwise, the listEventClassKeys script (as installed below) might not be found without specifying its full path.
- Change to the zenoss user's home directory:
$ cd - Create the bin subdirectory to hold the script:
$ mkdir -p bin - Change to the bin subdirectory:
$ cd bin - Download the attached script listEventClassKeys.
- Display the contents of the listEventClassKeys file and verify that it matches the script listed below:
$ cat listEventClassKeys - Make the listEventClassKeys file executable:
$ chmod +x listEventClassKeys - Run the script and pipe the output through a pager; less, for example:
$ listEventClassKeys | less
Alternatively, you can redirect the output to a file; for example:
$ cd
$ listEventClassKeys > eventClassKeys
$ less eventClassKeys
Script
#! /usr/bin/env python import Globals from Products.ZenUtils.ZenScriptBase import ZenScriptBase dmd = ZenScriptBase(connect=True).dmd for eventClass in sorted([dmd.Events] + dmd.Events.getSubOrganizers(), key=lambda c: c.getOrganizerName().lower()): print eventClass.getOrganizerName() if hasattr(eventClass, 'instances') and len(eventClass.instances()) > 0: for eventClassKey in sorted(eventClass.instances(), key=lambda k: k.id.lower()): print '\t' + eventClassKey.id
Comments