This file contains hidden or 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 smart_truncate(text, max_length=128, suffix='...'): | |
| """Returns a string of at most `max_length` characters, cutting | |
| only at word-boundaries. If the string was truncated, `suffix` | |
| will be appended. | |
| """ | |
| if len(text) > max_length: | |
| pattern = r'^(.{0,%d}\S)\s.*' % (max_length-len(suffix)-1) | |
| return re.sub(pattern, r'\1' + suffix, text) | |
| else: |
This file contains hidden or 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
| 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 file contains hidden or 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 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) |
This file contains hidden or 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 | |
| import sys | |
| import Globals | |
| from Products.ZenUtils.ZenScriptBase import ZenScriptBase | |
| # Check command line options. | |
| if len(sys.argv) < 2: | |
| print >> sys.stderr, "Usage: %s <device>" % sys.argv[0] | |
| sys.exit(1) |
NewerOlder