Skip to content

Instantly share code, notes, and snippets.

View daniel-garcia's full-sized avatar

Daniel García daniel-garcia

View GitHub Profile
#!/usr/bin/env zendmd
import uuid
import time
from MySQLdb import cursors
MAX_CHANGES = 10000
total_changes = 0
start_changes = time.time()
for d in dmd.Devices.getSubDevicesGen():
[random]
rw=randread
size=1g
directory=/tmp
iodepth=23
direct=1
blocksize=8k
numjobs=2
nrfiles=1
group_reporting
@daniel-garcia
daniel-garcia / db.fio
Created June 8, 2012 01:37
fio profile for DB workloads
[seq-read]
# Sequential reads
rw=read
# Size if the the I/O
size=8g
# Directory where the test file will be created
directory=/utest
# Diables posix_fadvise - predeclare an access pattern for file data
fadvise_hint=0
# Block size
@daniel-garcia
daniel-garcia / four-threads-randio.fio
Created June 8, 2012 02:17
four-threads-randio.fio
# Four threads, two query, two writers.
[global]
rw=randread
size=256m
directory=/tmp/fio-testing/data
ioengine=libaio
iodepth=4
invalidate=1
direct=1
2012-06-08 15:20:32,215 INFO zen.ZenModeler: Connecting to zen-hub-005-p:8794
2012-06-08 15:20:32,224 INFO zen.ZenModeler: Connected to ZenHub
2012-06-08 15:20:32,784 INFO zen.ZenModeler: Collecting for device rmake-dev-02
2012-06-08 15:20:33,252 INFO zen.ZenModeler: No WMI plugins found for rmake-dev-02
2012-06-08 15:20:33,255 INFO zen.ZenModeler: No Python plugins found for rmake-dev-02
2012-06-08 15:20:33,257 INFO zen.ZenModeler: No command plugins found for rmake-dev-02
2012-06-08 15:20:33,259 INFO zen.ZenModeler: SNMP collection device rmake-dev-02
2012-06-08 15:20:33,259 INFO zen.ZenModeler: plugins: zenoss.snmp.NewDeviceMap, zenoss.snmp.DeviceMap, HPDeviceMap, DellDeviceMap, zenoss.snmp.InterfaceMap, zenoss.snmp.RouteMap, zenoss.snmp.IpServiceMap, zenoss.snmp.HRFileSystemMap, zenoss.snmp.HRSWRunMap, zenoss.snmp.CpuMap, HPCPUMap, DellCPUMap, DellPCIMap
2012-06-08 15:20:33,289 INFO zen.ZenModeler: No portscan plugins found for rmake-dev-02
2012-06-08 15:20:33,407 INFO zen.SnmpClient: snmp client finished
Index: Products/ZenUtils/zencatalog.py
===================================================================
--- Products/ZenUtils/zencatalog.py (revision 59432)
+++ Products/ZenUtils/zencatalog.py (working copy)
@@ -212,8 +212,11 @@
def catalog_object(ob):
if hasattr(ob, 'index_object'):
ob.index_object()
- catalog.catalog_object(ob)
- log.debug('Catalogued object %s' % ob.absolute_url_path())
@daniel-garcia
daniel-garcia / gist:2974468
Created June 22, 2012 18:44
example export device list
import transaction
with open('/tmp/somefile.txt', 'w') as f:
for device in dmd.Devices.getSubDevicesGen():
print >> f , "%s:%s" % (device.id, device.getDeviceClassName())
device._p_invalidate()
transaction.abort()
@daniel-garcia
daniel-garcia / rawevents_2hour_lifetime.diff
Created August 3, 2012 03:11
message lifetime on raw event queue
Index: zenhome/lib/python/zenoss/protocols/data/queueschema.py
===================================================================
--- zenhome.orig/lib/python/zenoss/protocols/data/queueschema.py 2012-08-02 22:01:45.869403130 -0500
+++ zenhome/lib/python/zenoss/protocols/data/queueschema.py 2012-08-02 22:03:21.997400830 -0500
@@ -74,6 +74,9 @@
u'description': u'New zenevents will go into this exchange for ZEP to process them.',
u'durable': True,
u'name': u'zenoss.zenevents.raw',
+ u'arguments': {
+ u'x-message-ttl': { 'value': 7200000 }
@daniel-garcia
daniel-garcia / gist:3626063
Created September 4, 2012 20:26
rate limiting events with memcached, modifying a customer transform
if not device:
evt.dedupid=evt.device
evt.severity = 3 if evt.severity > 0 else 0
# we can rate limit events for devices that we don't monitor
if evt.severity > 0:
try:
client = dmd._p_jar.db().storage._cache.clients_global_first[0]
key = "rl_%s_%s" % (evt.dedupid, evt.severity)
timeout = 60
@daniel-garcia
daniel-garcia / simple_ssh_server.go
Created September 14, 2012 04:28
simple ssh server
package main
import (
"fmt"
"io/ioutil"
"code.google.com/p/go.crypto/ssh"
"code.google.com/p/go.crypto/ssh/terminal"
)