Follow me!

LinkedIn Twitter

Who's Online

We have 146 guests online

Python News



  

HowTo backup all of your Zenoss Templates the easy way.
Programming HowTo's - Python HowTo's
Written by Allen Sanabria   
Friday, 12 February 2010 15:19

Recently I had to prepare for a Zenoss upgrade. During my prep work I had to create a zenpack of all of our Templates. For those of you who use Zenoss, you know how many templates you can start to accumulate in a short amount of time. You can have Templates attached to single Devices, to SubClasses, and to Classes. Now if you have a few devices this is not a big deal. But if you have a couple hundred to a couple of thousand devices, this could be a real hassle.

Now you can take a ton of your time and review Class by Class and Device by Device until you finally finish. You will eventually get it all in a Zenpack....... Well lucky for you guys I created a Python Script that runs as the Zenoss user and create a Zenpack for you. All you have to do is pick a name for the ZenPack and optionally the Device Class you want to scan. The script will scan the Device Class that you specified ( or by default scan the entire /Device Class and its Sub Classes). It will then create the ZenPack with all the locally attached Device Templates. I am thinking of also adding the Events class as part of the next release of this script.

Update 1.0.1, I added the --unique option. If you decide to use this option, This Zenpack will only add, The Device Templates that are not already part of an existing ZenPack. I also added the --verbose option, so that you can see which Device Templates are being added or being dismissed.

You can download the script here

 Download Create ZenPack
File Title:Create ZenPack (Details)
File Type:py
File Version:1.0.1
File Size:6.44 Kb
License:
File Author:Allen Sanabria
File HomePage:
Downloads:97
Rating: ( Votes)
Your Vote:

Example.....

python createZenPack.py -p "ZenPacks.Allen.Test1" -a "Allen Sanabria" -v "0.9" -r "/Server/Linux/"

INFO:zen.HookReportLoader:loading reports from:/opt/zenoss/ZenPacks/ZenPacks.Allen.Test1/ZenPacks/Allen/Test1/reports
Created ZenPack ZenPacks.Allen.Test1
Scanning for locally attached Templates
Scanning for locally attached Templates
Objects Attached to Zenpack ZenPacks.Allen.Test1
/zport/dmd/Devices/Server/Linux/foo1.com/foo
/zport/dmd/Devices/Server/Linux/DNS/bind
/zport/dmd/Devices/Server/Linux/Apache/http

Another Example, with the unique option and verbose option.

python createZenPack.py -p "ZenPacks.Allen.Test1" -a "Allen Sanabria" -v "0.9" -u -V 

-INFO:zen.HookReportLoader:loading reports from:/opt/zenoss/ZenPacks/ZenPacks.Allen.Test1/ZenPacks/Allen/Test1/reports
Created ZenPack ZenPacks.Allen.Test1
Scanning for locally attached Templates
Scanning for locally attached Templates
Objects Attached to Zenpack ZenPacks.Allen.Test1
I'm not UNIQUE /zport/dmd/Devices/Server/rrdTemplates/LDAPServer
I'm in ZenPacks.zenoss.LDAPMonitor
I'm not UNIQUE /zport/dmd/Devices/Server/rrdTemplates/Apache
I'm in ZenPacks.zenoss.ApacheMonitor
I'm UNIQUE /zport/dmd/Devices/Server/Linux/foo1.com/foo

Another Example...

python createZenPack.py --list
HPTemperatureSensors
ZenPacks.Allen.Test1
ZenPacks.Allen.Full
ZenPacks.Allen.Tomcat

Help OutPut...

python createZenPack.py -h
usage: createZenPack.py --packname=ZenPackName --author=name --version=1.0

options:
-h, --help show this help message and exit
-p ZPACKNAME, --packname=ZPACKNAME
The name of the ZenPack that you want to create
-a AUTHOR, --author=AUTHOR
Who is creating The ZenPack?
-v VERSION, --version=VERSION
What Release is this?
-r ROOT, --root=ROOT
What Device Class You want the Search to begin at?
-l, --list
List all the ZenPacks

 



Add this page to your favorite Social Bookmarking websites
Reddit! Del.icio.us! Mixx! Free and Open Source Software News Google! Live! Facebook! StumbleUpon! Yahoo! Free Joomla PHP extensions, software, information and tutorials.
Comments
Search RSS
Only registered users can write comments!

3.22 Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved."

Last Updated on Monday, 01 March 2010 11:20