Skip to content

Instantly share code, notes, and snippets.

@jstanley23
jstanley23 / gist:0e5f13bc2becdcf6d1de618b6ba51e99
Created July 10, 2018 13:37 — forked from dougsyer/gist:264cd27eddecda3de1b011cf34b3ad2d
creating a graph legend in zenoss 6 description field with html example
<style> h2 { color:blue; font-size:12pt; background-color:powderblue; } </style>
<h2>
1 -- Other<BR>
2 -- Ok<BR>
3 -- Degraded<BR>
4 -- Failed<BR>
</h2>
@jstanley23
jstanley23 / templateToYaml.py
Last active July 10, 2018 14:07
Export Zenoss template to ZPL yaml
import argparse
import yaml
import sys
import Globals
from Products.ZenUtils.ZenScriptBase import ZenScriptBase
# Because of circular dependencies, we must import Dumper first
from ZenPacks.zenoss.ZenPackLib.lib.helpers.Dumper import Dumper
@jstanley23
jstanley23 / zendmd_argument_example.py
Created June 29, 2018 12:22
zendmd script that accepts arguments (Run as a normal python script, not using zendmd)
import argparse
import Globals
from transaction import commit
from Products.ZenUtils.ZenScriptBase import ZenScriptBase
parser = argparse.ArgumentParser(description='Example zendmd script with arguments')
parser.add_argument(
'-d',
'--device',
@jstanley23
jstanley23 / __init__.py
Last active June 9, 2018 14:52
Breaking out zenpacklib yaml files
import os
from ZenPacks.zenoss.ZenPackLib import zenpacklib
# Break out the yaml files for easy reading/editing
dirname = os.path.dirname(__file__)
tpldir = os.path.join(dirname, "templates")
# These are the main yaml files
zenpack_files = (
@jstanley23
jstanley23 / serviced_snapshot_commit.sh
Created February 28, 2018 13:09
Zenoss 6 Snapshot Commit
serviced service shell -s CC_ZP_patch -i zope
serviced snapshot commit CC_ZP_patch
@jstanley23
jstanley23 / serviced_snapshot_commit.sh
Created January 5, 2018 18:54
serviced snapshot and commit commands
serviced service shell -s CC_ZP_Fix -i zope
serviced snapshot commit CC_ZP_Fix
@jstanley23
jstanley23 / movepool.sh
Last active March 30, 2018 12:33
Mass Change Zenoss Serviced Pool
#1. Get a list of the serviced ids you want to edit itno a temp file called "to_rename", one per line.
#2. Create a script to do the edit you want with sed e.g.
#4. Then edit the services using that script
#5. e.g.: for i in cat to_rename; do EDITOR=./movepool serviced service edit $i; done
# movepool.sh example
#!/bin/bash
sed -i -e 's/\"PoolID\": \"Prod_.*\",/\"PoolID\": \"resmgr\",/' "$1"
@jstanley23
jstanley23 / zenForceDelete.dmd
Last active December 10, 2022 10:28
Force delete a device in zendmd
#1) If a device won't delete normally the first method to try is this:
dmd.Devices.Example.Path.devices._delObject('DEVICE', suppress_events=True)
commit()
dmd.global_catalog.uncatalog_object('/zport/dmd/Devices/Example/Path/devices/DEVICE')
dmd.Devices.deviceSearch.uncatalog_object('/zport/dmd/Devices/Example/Path/devices/DEVICE')
commit()
------------------------
@jstanley23
jstanley23 / zenDelDevice.py
Created November 30, 2017 16:56
Zenoss Facade Delete
sync()
df = getFacade('devices')
df.deleteDevices(uids=[df.getDeviceByIpAddress('1.1.1.1').getPrimaryId()])
commit()
@jstanley23
jstanley23 / getCatalogNumbers.dmd
Created October 16, 2017 13:27
get Catalog lengths
def getCatalogNumbers():
catalogsToCheck = [
('CiscoUCS.ucsSearchCatalog', 'dmd.Devices.CiscoUCS.ucsSearchCatalog'),
('CloudStack.HostCatalog', 'dmd.Devices.CloudStack.HostCatalog'),
('CloudStack.RouterVMCatalog', 'dmd.Devices.CloudStack.RouterVMCatalog'),
('CloudStack.SystemVMCatalog', 'dmd.Devices.CloudStack.SystemVMCatalog'),
('CloudStack.VirtualMachineCatalog', 'dmd.Devices.CloudStack.VirtualMachineCatalog'),
('Devices.deviceSearch', 'dmd.Devices.deviceSearch'),
('Devices.searchRRDTemplates', 'dmd.Devices.searchRRDTemplates'),
('Events.eventClassSearch', 'dmd.Events.eventClassSearch'),