Skip to content

Instantly share code, notes, and snippets.

View cluther's full-sized avatar

Chet Luther cluther

View GitHub Profile
@cluther
cluther / screenrc
Created June 18, 2013 19:35
screenrc
shell -${SHELL} # dash (-) is for login shells
shelltitle ''
vbell off
autodetach on
startup_message off
defscrollback 8192
hardstatus alwayslastline
hardstatus string "%{= ky}%-Lw%{=r}%20>%n %t%{= ky}%+Lw %{= ky}%-=| %{= kW}${USER}@%H "
@cluther
cluther / zenmodeler_pickle.diff
Created June 10, 2013 14:23
zenmodeler_pickle.diff
diff --git a/Products/DataCollector/zenmodeler.py b/Products/DataCollector/zenmodeler.py
index 2622fd6..df99e8b 100644
--- a/Products/DataCollector/zenmodeler.py
+++ b/Products/DataCollector/zenmodeler.py
@@ -644,6 +644,26 @@ class ZenModeler(PBDaemon):
try:
results = plugin.preprocess(results, self.log)
if results:
+###############################################################################
+ import os
@cluther
cluther / model-directory
Created June 10, 2013 14:22
model-directory
#!/usr/bin/env python
import logging
log = logging.getLogger(__name__)
import os
import pickle
import random
import sys
import Globals
@cluther
cluther / ZEN-6757.diff
Created June 4, 2013 22:10
Fix for ZEN-6757: usmStatsOid not being handled properly with SNMPv3
Index: /trunk/core/pynetsnmp/twistedsnmp.py
===================================================================
--- /trunk/core/pynetsnmp/twistedsnmp.py (revision 67812)
+++ /trunk/core/pynetsnmp/twistedsnmp.py (revision 73453)
@@ -228,48 +228,53 @@
log.debug("Received a usmStatsNotInTimeWindows error. Some devices use usmStatsNotInTimeWindows as a normal part of the SNMPv3 handshake.")
return
default_msg = "packet dropped (OID: {0})".format(usmStatsOidStr)
message = USM_STATS_OIDS.get(usmStatsOidStr, default_msg)
@cluther
cluther / __init__.py
Created June 4, 2013 19:41
Using datetime in ZPT
import datetime
from Products.ZenUtils.Utils import monkeypatch
@monkeypatch('Products.ZenModel.DataRoot.DataRoot')
def custom_datetime_utcnow(self):
'''
Return the string version of datetime.utcnow().
@cluther
cluther / status_interface_transform.py
Created March 7, 2013 19:01
/Status/Interface Transform for ValueChangeThreshold on adminStatus and OperStatus
if 'Value changed from' in evt.summary:
new_value = int(float(evt.current))
if evt.eventKey == 'oper_status':
if new_value == 1:
evt.summary = 'interface operationally up'
evt.severity = 0
else:
evt.summary = 'interface operationally down'
@cluther
cluther / snmpindex_dct.py
Created March 7, 2013 18:11
snmpindex_dct example usage
from Products.DataCollector.plugins.CollectorPlugin import SnmpPlugin
from Products.DataCollector.plugins.CollectorPlugin import GetTableMap
class MyPlugin(SnmpPlugin):
relname = 'myrelation'
modname = 'ZenPacks.example.MyStuff'
snmpGetTableMaps = (
GetTableMap('sometable',
@cluther
cluther / zenscriptbase_example.py
Created March 5, 2013 17:00
ZenScriptBase Example
#!/usr/bin/env python
import Globals
from Products.ZenUtils.ZenScriptBase import ZenScriptBase
class MyTool(ZenScriptBase):
def buildOptions(self):
super(MyTool, self).buildOptions()
self.parser.add_option(
@cluther
cluther / AIXAndWebsphereMQDevice.py
Created February 20, 2013 03:18
Combining two Device subclasses.
from ZenPacks.community.AIX.AIXBase import AIXBase
from ZenPacks.community.zenIbmMQ.MQDevice import MQDevice
class AIXAndWebsphereMQDevice(AIXBase, MQDevice):
"""
Example device subclass. In this case the reason for creating a subclass of
device is to add a new type of relation. We want many "ExampleComponent"
components to be associated with each of these devices.
#!/usr/bin/env python
##############################################################################
#
# Copyright (C) Zenoss, Inc. 2012, all rights reserved.
#
# This content is made available according to terms specified in
# License.zenoss under the directory where your Zenoss product is installed.
#
##############################################################################