Skip to content

Instantly share code, notes, and snippets.

View daniel-garcia's full-sized avatar

Daniel García daniel-garcia

View GitHub Profile
Index: Products/ZenUtils/zencatalog.py
===================================================================
--- Products/ZenUtils/zencatalog.py (revision 74143)
+++ Products/ZenUtils/zencatalog.py (working copy)
@@ -115,6 +115,10 @@
action="store_true",
default=False,
help="Create global catalog and populate it")
+ self.parser.add_option("--continueindex",
+ action="store_true",
@daniel-garcia
daniel-garcia / zencatalog_continue.diff
Created June 14, 2013 05:04
attempt to coninue a zencatalog --createcatalog --forceindex, with a new --continueindex option
Index: Products/ZenUtils/zencatalog.py
===================================================================
--- Products/ZenUtils/zencatalog.py (revision 73688)
+++ Products/ZenUtils/zencatalog.py (working copy)
@@ -115,6 +115,10 @@
action="store_true",
default=False,
help="Create global catalog and populate it")
+ self.parser.add_option("--continueindex",
+ action="store_true",
@daniel-garcia
daniel-garcia / getcount.py
Created June 13, 2013 16:36
get number of objects in dmd
#!/usr/bin/env python
import time
import transaction
import Globals
from Products.ZenUtils.ZenScriptBase import ZenScriptBase
from OFS.ObjectManager import ObjectManager
from Products.ZenRelations.ToManyContRelationship import ToManyContRelationship
from Products.ZenModel.ZenModelRM import ZenModelRM
@daniel-garcia
daniel-garcia / getcount.zendmd
Created June 13, 2013 15:38
get count of all objects in a zenoss system
from OFS.ObjectManager import ObjectManager
import time
import transaction
from Products.ZenModel.ZenModelRM import ZenModelRM
from Products.ZenRelations.ToManyContRelationship import ToManyContRelationship
def recurse(obj):
if isinstance(obj, ObjectManager):
# Bottom up, for multiple-path efficiency
for ob in obj.objectValues():
@daniel-garcia
daniel-garcia / gist:5768361
Created June 12, 2013 19:31
configure rabbitmq
RABBITMQ_HOST=localhost
RABBITMQ_PASS=zenoss
RABBITMQ_PORT=5672
RABBITMQ_SSL=0
rabbitmqctl add_user ${RABBITMQ_USER} ${RABBITMQ_PASS}
rabbitmqctl add_vhost ${RABBITMQ_VHOST}
rabbitmqctl set_permissions -p ${RABBITMQ_VHOST} ${RABBITMQ_USER} '.*' '.*' '.*'
@daniel-garcia
daniel-garcia / disable_browser_messages.diff
Created May 24, 2013 16:14
disable all browser messages in Zenoss
Index: Products/ZenWidgets/messaging.py
===================================================================
--- Products/ZenWidgets/messaging.py.orig
+++ Products/ZenWidgets/messaging.py
@@ -182,6 +182,7 @@ class MessageSender(object):
@param image: Optional URL of an image to be displayed in the message
@type image: str
"""
+ pass
context = self.context.REQUEST.SESSION.get('messages')
@daniel-garcia
daniel-garcia / zstack.sh
Created May 15, 2013 15:39
a script to print the state of python programs
#!/bin/bash
#
# Get a stack trace of the tasks matching the supplied regex
#
# This script was inspired by:
# http://old.zope.org/Members/4am/debugspinningzope
###############################################################################
#==============================================================================
function Usage
@daniel-garcia
daniel-garcia / optimize_table_eventsummary.sql
Created April 29, 2013 19:54
Optimize the event_summary table in Zenoss by first dropping all secondary indexes.
LOCK TABLES event_summary WRITE;
ALTER TABLE event_summary
DROP KEY `fingerprint_hash`,
DROP KEY `element_uuid`,
DROP KEY `element_sub_uuid`,
DROP KEY `event_summary_clear_idx`,
DROP KEY `event_summary_age_idx`,
DROP KEY `event_summary_archive_idx`;
@daniel-garcia
daniel-garcia / save_datamaps.diff
Created April 29, 2013 16:08
Enable saving datamap serialization in zenhub for later playback. Add "savedatamaptodir /path/to/dir" in $ZENHOME/global.conf to save datamaps.
Index: Products/DataCollector/ApplyDataMap.py
===================================================================
--- Products/DataCollector/ApplyDataMap.py.orig
+++ Products/DataCollector/ApplyDataMap.py
@@ -178,6 +178,23 @@ class ApplyDataMap(object):
if not hasattr(device.dmd, 'zport'):
transaction.abort()
+ # save apply datamaps
+ try:
@daniel-garcia
daniel-garcia / relstorageKeepAlive.diff
Created April 18, 2013 22:59
call mysql connection's ping() method
Index: lib/python/relstorage/adapters/mysql.py
===================================================================
--- lib/python/relstorage/adapters/mysql.py.orig
+++ lib/python/relstorage/adapters/mysql.py
@@ -91,6 +91,26 @@ disconnected_exceptions = (
# when the adapter attempts to close a database connection.
close_exceptions = disconnected_exceptions + (MySQLdb.ProgrammingError,)
+# attempt to ping MySQL connections
+OPEN_CONNECTIONS = []