Feb 122010
 

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

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/reportsCreated ZenPack ZenPacks.Allen.Test1Scanning for locally attached TemplatesScanning for locally attached TemplatesObjects 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/reportsCreated ZenPack ZenPacks.Allen.Test1Scanning for locally attached TemplatesScanning for locally attached TemplatesObjects Attached to Zenpack ZenPacks.Allen.Test1I'm not UNIQUE /zport/dmd/Devices/Server/rrdTemplates/LDAPServerI'm in ZenPacks.zenoss.LDAPMonitorI'm not UNIQUE /zport/dmd/Devices/Server/rrdTemplates/ApacheI'm in ZenPacks.zenoss.ApacheMonitorI'm UNIQUE /zport/dmd/Devices/Server/Linux/foo1.com/foo

Another Example…

python createZenPack.py --listHPTemperatureSensorsZenPacks.Allen.Test1ZenPacks.Allen.FullZenPacks.Allen.Tomcat

Help OutPut…

python createZenPack.py -husage: 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

 

dynasty

  2 Responses to “HowTo backup all of your Zenoss Templates the easy way.”

  1. Downloads are not working. Trying to down load this script and all I see is: {quickdown:53}


Warning: fopen(/home/dynasty/linuxdynasty.org/wp-content/plugins/wp-google-plus-one/lib/standard.txt) [function.fopen]: failed to open stream: No such file or directory in /home/dynasty/linuxdynasty.org/wp-content/plugins/wp-google-plus-one/plusone.php on line 104

Warning: fread(): supplied argument is not a valid stream resource in /home/dynasty/linuxdynasty.org/wp-content/plugins/wp-google-plus-one/plusone.php on line 105

Warning: fclose(): supplied argument is not a valid stream resource in /home/dynasty/linuxdynasty.org/wp-content/plugins/wp-google-plus-one/plusone.php on line 106
.