Skip to content

Commit

Permalink
Only generate RabbitMQ failures against nodes.
Browse files Browse the repository at this point in the history
Refs ZEN-5533.
  • Loading branch information
cluther committed Feb 21, 2013
1 parent 8951030 commit 6d3d420
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 30 deletions.
10 changes: 8 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,14 @@ Screenshots
Changes
===============================================================================


1.0.6
-------------------------------------------------------------------------------

* (ZEN-5533) /Status/RabbitMQ for queues don't auto-clear when resolved


1.0.5
-------------------------------------------------------------------------------

* Fixed "No data returned for command" event when no queues, connections or
channels exist.
* (ZEN-3526) RabbitMQ: No data returned for command
54 changes: 27 additions & 27 deletions ZenPacks/zenoss/RabbitMQ/parsers/RabbitMQCTL.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ def loadData(keys, expiration=1800):


class RabbitMQCTL(CommandParser):
createDefaultEventUsingExitCode = False

eventKey = eventClassKey = 'rabbitmq_node_status'

event = None
Expand All @@ -65,23 +67,17 @@ def processResults(self, cmd, result):
return

# Get as much error handling out of the way right away.
if self.isError(cmd, result):
if not self.verifyResult(cmd, result):
return

# Route to the right parser based on the command.
if 'status' in cmd.command:
self.processStatusResults(cmd, result)
elif 'list_connections' in cmd.command:
if 'list_connections' in cmd.command:
self.processListConnectionsResults(cmd, result)
elif 'list_channels' in cmd.command:
self.processListChannelsResults(cmd, result)
elif 'list_queues' in cmd.command:
self.processListQueuesResults(cmd, result)

def processStatusResults(self, cmd, result):
result.events.append(self.getEvent(
cmd, "node status is OK", clear=True))

def processListConnectionsResults(self, cmd, result):
connections = {}

Expand Down Expand Up @@ -236,31 +232,35 @@ def processListQueuesResults(self, cmd, result):
result.values.append((
point, queues[point.component][point.id]))

def isError(self, cmd, result):
match = re.search(r'^Error: (.+)$', cmd.result.output, re.MULTILINE)
if match:
result.events.append(self.getEvent(
cmd, match.group(1),
message=cmd.result.output))
def verifyResult(self, cmd, result):
clear = True
summary = 'status is OK'

if clear:
match = re.search(
r'^Error: (.+)$', cmd.result.output, re.MULTILINE)

return True
if match:
summary = match.group(1)
clear = False

match = re.search(r'command not found', cmd.result.output, re.MULTILINE)
if match:
result.events.append(self.getEvent(
cmd, "command not found: rabbitmqctl",
message=cmd.result.output))
if clear:
match = re.search(
r'command not found', cmd.result.output, re.MULTILINE)

return True
if match:
summary = 'command not found: rabbitmqctl'
clear = False

if cmd.result.exitCode != 0:
result.events.append(self.getEvent(
cmd, "rabbitmqctl error - see event message",
message=cmd.result.output))
if clear:
if cmd.result.exitCode != 0:
summary = 'rabbitmqctl error - see event message'
clear = False

return True
if 'status' in cmd.command:
result.events.append(self.getEvent(cmd, summary, clear=clear))

return False
return clear

def getEvent(self, cmd, summary, message=None, clear=False):
event = dict(
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# or saved. Do not modify them directly here.
# NB: PACKAGES is deprecated
NAME = "ZenPacks.zenoss.RabbitMQ"
VERSION = "1.0.5"
VERSION = "1.0.6"
AUTHOR = "Zenoss Labs"
LICENSE = "GPLv2"
NAMESPACE_PACKAGES = ['ZenPacks', 'ZenPacks.zenoss']
Expand Down

0 comments on commit 6d3d420

Please sign in to comment.