Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
import sys
import os
from optparse import OptionParser
zenhome = os.environ['ZENHOME']
oldpath = os.environ.get('LD_LIBRARY_PATH', None)
libpath = os.path.join(zenhome, 'ZenPacks',
'ZenPacks.zenoss.ZenSQLTx-2.0.0-py2.4-linux-i686.egg',
'ZenPacks', 'zenoss', 'ZenSQLTx', 'lib')
from xmlrpclib import ServerProxy
baseUrl = 'http://admin:zenoss@localhost:8080'
p = ServerProxy(baseUrl + '/zport/dmd/Devices')
deviceNames = eval(p.jsonGetDeviceNames())
for deviceName in deviceNames:
path = p.findDevicePath(deviceName)
dp = ServerProxy(baseUrl + path)
print "%s = %s" % (deviceName, dp.getProperty('snmpSysName'))
From 64492bf0117eb1649aad1f6b1cec1b281ea88938 Mon Sep 17 00:00:00 2001
From: Chet Luther <cluther@zenoss.com>
Date: Mon, 5 Oct 2009 14:30:25 -0400
Subject: [PATCH] Various ZenAWS fixes.
Fixes #5597, Fixes #5601. Reviewed by ian.
---
.../ZenPacks/zenoss/ZenAWS/EC2Manager.py | 5 +-
.../zenoss/ZenAWS/libexec/zenec2modeler.py | 29 ++++--
.../modeler/plugins/zenoss/aws/EC2InstanceMap.py | 5 +-
def getComponentQuickly(device_name, component_type, component_name):
cs = dmd.Devices.componentSearch
for brain in cs(getParentDeviceName=device_name, meta_type=component_type):
component = brain.getObject()
if component.name() == component_name:
return component
grail = getComponentQuickly('mydevice', 'IpInterface', 'eth0')
from Products.ZenModel.ZenModelRM import ZenModelRM
pathlist = self.REQUEST['PATH_INFO'].split('/')
obj = self.getObjByPath('/'.join(pathlist))
while not isinstance(obj, ZenModelRM):
pathlist = pathlist[:-1]
obj = self.getObjByPath('/'.join(pathlist))
# Now obj is what you want.
oldPlugin="zenoss.snmp.RouteMap"
newPlugin="IpRouteCSOB"
def replacePlugin(objs):
for obj in objs:
if not obj.hasProperty('zCollectorPlugins'): continue
if oldPlugin not in obj.zCollectorPlugins: continue
print "Replacing plugin for %s." % obj.id
obj.zCollectorPlugins = [
p for p in obj.zCollectorPlugins if p != oldPlugin ]
# This script looks for, and fixes problems where zDeviceTemplates was
# set as a regular object attribute instead of through the acquisition
# mechanism.
from Acquisition import aq_base
for d in dmd.Devices.getSubDevices():
if hasattr(aq_base(d), 'zCollectorPlugins') and not d.hasProperty('zCollectorPlugins'):
print "%s has the problem." % d.id
templates = d.zCollectorPlugins
del(d.zCollectorPlugins)
d._setProperty('zCollectorPlugins', templates)
@cluther
cluther / __init__.py
Created July 6, 2011 16:51
Changing Zenoss Permissions
import logging
log = logging.getLogger('zen.ZenPack')
import Globals
from AccessControl import ClassSecurityInfo
from Products.ZenModel.Location import Location
from Products.ZenModel.ZenPack import ZenPack as ZenPackBase
from Products.ZenModel.ZenossSecurity import ZEN_COMMON, ZEN_VIEW
from Products.ZenWidgets.ZenossPortlets import ZenossPortlets
@cluther
cluther / gist:1073311
Created July 9, 2011 04:29
Rebuild all Graph Definitions' Relationships
for t in dmd.Devices.getAllRRDTemplates():
for g in t.graphDefs():
g.buildRelations()
commit()
@cluther
cluther / gist:1076520
Created July 11, 2011 18:55
Fix Collector Associations
# Remove non-existent devices from performance monitors
from Products.ZenModel.PerformanceConf import PerformanceConf
for pmon in dmd.Monitors.Performance.objectValues():
if not isinstance(pmon, PerformanceConf): continue
for device in pmon.devices():
try:
bah = device.primaryAq()
except Exception:
print "Removing %s from %s" % (device.id, pmon.id)
pmon.devices._remove(device)