Skip to content

Commit

Permalink
change kill_proc method in functional_test and add event to dsplugins
Browse files Browse the repository at this point in the history
  • Loading branch information
ssOleg committed Oct 15, 2013
1 parent 01ed8b8 commit c3fba76
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
6 changes: 5 additions & 1 deletion ZenPacks/zenoss/MySqlMonitor/dsplugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ def onSuccess(self, result, config):
print '*********'*10

return {
'events': [],
'events': [{
'summary': 'error: %s' % result,
'eventKey': 'myPlugin_result',
'severity': 0,
}],
'values': {
'root_3306': {
'random': (2, time.time()),
Expand Down
15 changes: 6 additions & 9 deletions functional_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,12 @@ def dump_zodb():

def kill_proc():
bprint('''Kill all mysql processes!''')
o = subprocess.check_output(['mysql', '--batch', '-u', 'root', '-e', 'show processlist'])
pl = [x.split('\t') for x in o.splitlines()]
cols = dict((c, i) for i, c in enumerate(pl[0]))
print ' '.join(['%15s' % p for p in pl[0]])
for process in pl[1:]:
if (process[cols['Command']] == 'Sleep') and (process[cols['db']] in ('zodb', 'zodb_session')):
print ' '.join(['%15s' % p for p in process])
cmd = 'mysqladmin -u root KILL %s' % process[cols['Id']]
os.system(cmd)
o = subprocess.check_output(['mysql', '--batch', '-u', 'root', '-e',
'SELECT id FROM information_schema.processlist\
WHERE Command = "Sleep"'])
for process_id in o.split()[1:]:
cmd = 'mysqladmin -u root KILL %s' % process_id
os.system(cmd)


def restore_zodb():
Expand Down

0 comments on commit c3fba76

Please sign in to comment.