This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# | |
# This script allows a single datasource's cycletime (interval) to be | |
# changed. | |
# | |
# Example usage: | |
# change-cpu-interval --device=web-server-a --template=Device --datasource=cpu --interval=10 | |
import sys |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gc, sys | |
objs = [] | |
for obj in gc.get_objects(): | |
size = sys.getsizeof(obj, 0) | |
if size > 1024: | |
objs.append((obj, size)) | |
objs.sort(key=lambda x: x[1], reverse=True) | |
from pprint import pprint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# It is expected that the following code would be placed in the | |
# __init__.py of your ZenPack. | |
# lxml provides an API for building XML documents. | |
# http://lxml.de/tutorial.html#the-e-factory | |
from lxml import etree | |
from lxml.builder import E | |
# monkeypatch allows us to add a new method (myXML) to an existing | |
# object (ZentinelPortal a.k.a. /zport). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This code goes into the __init__.py of a ZenPack. It patches the | |
# Products.ZenRRD.RRDUtil.RRDUtil.put() method. This allows for | |
# executing custom code for every RRD update that's made. | |
from Products.ZenUtils.Utils import monkeypatch | |
@monkeypatch('Products.ZenRRD.RRDUtil.RRDUtil') | |
def put(self, *args, **kwargs): | |
value = original(self, *args, **kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def jmx_datasources(thing): | |
for template in thing.getRRDTemplates(): | |
for ds in template.datasources(): | |
if ds.enabled and ds.sourcetype == 'JMX': | |
return True | |
return False | |
for device in dmd.Devices.getSubDevicesGen(): | |
if any(map(jmx_datasources, [device] + device.getMonitoredComponents())): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
INFO:root:progress: 8 of 1000, elapsed=0:00:01, remaining=0:02:09 | |
INFO:root:progress: 16 of 1000, elapsed=0:00:02, remaining=0:02:08 | |
INFO:root:progress: 24 of 1000, elapsed=0:00:03, remaining=0:02:07 | |
INFO:root:progress: 32 of 1000, elapsed=0:00:04, remaining=0:02:06 | |
INFO:root:progress: 40 of 1000, elapsed=0:00:05, remaining=0:02:05 | |
INFO:root:progress: 48 of 1000, elapsed=0:00:06, remaining=0:02:04 | |
INFO:root:progress: 56 of 1000, elapsed=0:00:07, remaining=0:02:03 | |
INFO:root:progress: 64 of 1000, elapsed=0:00:08, remaining=0:02:02 | |
INFO:root:progress: 72 of 1000, elapsed=0:00:09, remaining=0:02:01 | |
INFO:root:progress: 80 of 1000, elapsed=0:00:10, remaining=0:02:00 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env zendmd | |
output = open('transforms.txt', 'w') | |
for ec in [dmd.Events] + dmd.Events.getSubOrganizers(): | |
if ec.transform: | |
print >> output, "%s" % ec.getOrganizerName() | |
print >> output, "-"*len(ec.getOrganizerName()) | |
print >> output, ec.transform | |
print >> output | |
for mapping in ec.instances(): | |
if not mapping.transform: continue |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
############################################################################## | |
# | |
# Copyright (C) Zenoss, Inc. 2013, all rights reserved. | |
# | |
# This content is made available according to terms specified in | |
# License.zenoss under the directory where your Zenoss product is installed. | |
# | |
############################################################################## |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from Products.ZenUtils.Utils import monkeypatch | |
from ZODB.transact import transact | |
def get_datapoint_count(device): | |
''' | |
Return the total number of monitored datapoints on device. | |
''' | |
if not device.monitorDevice(): | |
return 0 |