Zenoss Developer's Guide Copyright © 2010 Zenoss, Inc., 275 West St
Total Page:16
File Type:pdf, Size:1020Kb
Zenoss Developer's Guide Copyright © 2010 Zenoss, Inc., 275 West St. Suite 204, Annapolis, MD 21401, U.S.A. All rights reserved. This work is licensed under a Creative Commons Attribution Share Alike 3.0 License. To view a copy of this license, visit http:// creativecommons.org/licenses/by-sa/3.0/; or send a letter to Creative Commons, 171 2nd Street, Suite 300, San Francisco, California, 94105, USA. The Zenoss logo is a registered trademark of Zenoss, Inc. Zenoss and Open Enterprise Management are trademarks of Zenoss, Inc. in the U.S. and other countries. Flash is a registered trademark of Adobe Systems Incorporated. Java is a registered trademark of Oracle and/or its affiliates. Other names may be trademarks of their respective owners. Linux is a registered trademark of Linus Torvalds. Oracle and the Oracle logo are registered trademarks of the Oracle Corporation. SNMP Informant is a trademark of Garth K. Williams (Informant Systems, Inc.). Sybase is a registered trademark of Sybase, Inc. Tomcat is a trademark of the Apache Software Foundation. Windows is a registered trademark of Microsoft Corporation in the United States and other countries. All other companies and products mentioned are trademarks and property of their respective owners. Part Number: 08-102010-3.0-v01 1. Introduction ............................................................................................................................................. 1 1.1. Overview ...................................................................................................................................... 1 1.1.1. Key Tenets ........................................................................................................................ 1 1.2. Architecture and Technologies ....................................................................................................... 2 1.2.1. User Layer ......................................................................................................................... 3 1.2.2. Data Layer ......................................................................................................................... 3 1.2.3. Process Layer .................................................................................................................... 4 1.2.4. Collection Layer ................................................................................................................. 4 2. Getting Started ........................................................................................................................................ 5 2.1. Working with the Source Code ...................................................................................................... 5 2.1.1. Getting the Source Code .................................................................................................... 5 2.1.1.1. Getting Subversion for the Appliance ........................................................................ 5 2.1.2. Keeping Code Updated ...................................................................................................... 6 2.1.3. Getting Patches ................................................................................................................. 6 2.1.4. Style Guidelines ................................................................................................................. 6 2.1.4.1. Docstrings ............................................................................................................... 6 2.1.5. Generating Diffs for new Fixes ............................................................................................ 8 2.1.6. Submitting a Fix ................................................................................................................. 8 2.2. Development Toolchain Requirements ........................................................................................... 8 2.2.1. Appliance ........................................................................................................................... 8 2.3. Programming Techniques ............................................................................................................ 10 2.3.1. Calling Methods Using REST ............................................................................................ 10 2.3.1.1. How to Call Methods Using REST .......................................................................... 10 2.3.1.2. Sending an Event .................................................................................................. 11 2.3.2. Miscellaneous Notes ......................................................................................................... 13 2.3.2.1. pkg_resources ....................................................................................................... 13 2.3.2.2. urllib2 Workarounds ............................................................................................ 13 2.4. zendmd: Command-line Access to the Device Management Database (DMD) ................................. 14 2.5. Programming Documentation ....................................................................................................... 16 2.5.1. Python ............................................................................................................................. 16 2.5.2. Zenoss API ...................................................................................................................... 16 2.5.3. Other Resources .............................................................................................................. 16 2.5.4. Contributing to the Documentation .................................................................................... 16 3. ZenPacks .............................................................................................................................................. 17 3.1. Overview .................................................................................................................................... 17 3.2. Creating a ZenPack .................................................................................................................... 17 3.2.1. ZenPack Names ............................................................................................................... 17 3.2.2. Specifying Dependencies .................................................................................................. 18 3.2.3. Locating ZenPack Source Outside of Zenoss ..................................................................... 18 3.2.4. Community ZenPack Subversion Access ........................................................................... 18 3.3. ZenPack Structure and Contents ................................................................................................. 18 3.4. Developing the ZenPack ............................................................................................................. 21 3.4.1. Base ZenPack Class ........................................................................................................ 21 3.4.2. Storing Objects in the ZODB ............................................................................................. 21 3.4.3. Providing DataSource classes ........................................................................................... 21 3.4.4. Monitoring Template Checklist .......................................................................................... 22 3.4.4.1. Data Sources ........................................................................................................ 22 3.4.4.2. Data Points ........................................................................................................... 22 3.4.4.3. Thresholds ............................................................................................................ 23 3.4.4.4. Graph Definitions ................................................................................................... 23 3.4.4.5. Graph Points ......................................................................................................... 23 3.4.5. Providing Performance Collector Plugins ........................................................................... 23 3.4.6. Referencing Collector Plugins in ZenPacks ........................................................................ 23 3.4.7. Providing Daemons .......................................................................................................... 24 iii Zenoss Developer's Guide 3.4.8. setuptools and the zenpacksupport ................................................................................... 24 3.5. Building and Distributing ZenPacks .............................................................................................. 24 3.5.1. Migrating between versions ............................................................................................... 25 3.5.2. Converting older ZenPacks to ZenPack eggs ..................................................................... 25 3.6. Development Mode ..................................................................................................................... 25 3.6.1. Source ZenPacks ............................................................................................................. 25 3.6.2. Converting .egg Files to Development Mode ...................................................................... 25 3.7. Where to Get More Information