Skip to content

Commit

Permalink
Finished hotfix 1.0.10.
Browse files Browse the repository at this point in the history
  • Loading branch information
otrach committed Sep 9, 2021
2 parents 6b29134 + 87bd6ce commit 13b3767
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 19 deletions.
9 changes: 7 additions & 2 deletions README.mediawiki
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,19 @@ Rabbitmqadmin uses a user to authenticate with Rabbit for performing operations.
; 4. Download the rabbitmqadmin script
1. Download the rabbitmqadmin script to /usr/local/bin/:
* cd /usr/local/bin
* RabbitMQ 2.x: wget http://{your-rabbitmq-server}:55672/cli/rabbitmqadmin -u {your-rabbitmq-user} -p {your-rabbitmq-user-password}
* RabbitMQ 3.x: wget http://{your-rabbitmq-server}:15672/cli/rabbitmqadmin -u {your-rabbitmq-user} -p {your-rabbitmq-user-password}
* RabbitMQ 2.x: wget http://{your-rabbitmq-server}:55672/cli/rabbitmqadmin --user {your-rabbitmq-user} --password {your-rabbitmq-user-password}
* RabbitMQ 3.x: wget http://{your-rabbitmq-server}:15672/cli/rabbitmqadmin --user {your-rabbitmq-user} --password {your-rabbitmq-user-password}
2. Make the rabbitmqadmin file executable and update ownership:
* chmod +x /usr/local/bin/rabbitmqadmin
* If you are running the SSH commands as a non-root user, chown (your user):(your group) /usr/local/bin/rabbitmqadmin

== Change Log ==

;1.0.10
* (ZPS-6912) Fix Traceback generated when no queries are being returned for the vhost name
* (ZPS-6937) Fix RabbitMQ 3.8.x targets break parsing
* Tested with Zenoss Cloud, Zenoss 6.6.0, Zenoss 6.5.0 and Service Impact 5.5.3
;1.0.9
* (ZPS-2772) Fix modeler omission of RabbitMQ nodes from rabbitmqctl status
Expand Down
17 changes: 17 additions & 0 deletions ZenPacks/zenoss/RabbitMQ/RabbitMQComponent.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from Products.ZenModel.DeviceComponent import DeviceComponent
from Products.ZenModel.ManagedEntity import ManagedEntity
from Products.ZenModel.ZenossSecurity import ZEN_CHANGE_DEVICE
from Products.ZenUtils.Version import getVersionTupleFromString


class RabbitMQComponent(DeviceComponent, ManagedEntity):
Expand All @@ -22,10 +23,17 @@ class RabbitMQComponent(DeviceComponent, ManagedEntity):
DeviceComponent subclasses in this ZenPack.
"""

rabbit_version = None

# Disambiguate multi-inheritence.
_properties = ManagedEntity._properties
_relations = ManagedEntity._relations

_properties = _properties + (
{
'id': 'rabbit_version', 'type': 'int', 'mode': 'w'
},
)
# This makes the "Templates" component display available.
factory_type_information = ({
'actions': ({
Expand All @@ -41,3 +49,12 @@ class RabbitMQComponent(DeviceComponent, ManagedEntity):

# Commands are run via SSH and should not be specified absolutely.
zCommandPath = ''

@property
def rabbitmq_version_flag(self):
flag = ''
if self.rabbit_version:
if getVersionTupleFromString(self.rabbit_version) >= \
getVersionTupleFromString("3.8.0"):
flag = '-s'
return flag
58 changes: 45 additions & 13 deletions ZenPacks/zenoss/RabbitMQ/modeler/plugins/zenoss/ssh/RabbitMQ.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,21 @@

class RabbitMQ(CommandPlugin):
command = (
'rabbitmqctl -s status 2>&1 && ('
'BASE_VERSION="3.8.0" &&'
'VV=$(rabbitmqctl status 2>&1|grep rabbit, || rabbitmqctl version) &&'
'PAT="([0-9]+\.[0-9]+\.[0-9]+)" &&'
'[[ $VV =~ $PAT ]] &&'
'function ComparingRabbit { [[ "$1" = "`echo -e "$1\n$2" | sort -V | head -n1`" ]];} &&'
'$(ComparingRabbit $BASE_VERSION ${BASH_REMATCH[0]} ) && FLAG="-s" || FLAG="" &&'
'rabbitmqctl $FLAG status 2>&1 && ('
'echo __COMMAND__ ; '
'for vhost in $(rabbitmqctl -s -q list_vhosts) ; do '
'for vhost in $(rabbitmqctl $FLAG -q list_vhosts) ; do '
'echo "VHOST: $vhost" ; '
'echo "__SPLIT__" ; '
'rabbitmqctl -s -q list_exchanges -p $vhost '
'rabbitmqctl $FLAG -q list_exchanges -p $vhost '
'name type durable auto_delete arguments ; '
'echo "__SPLIT__" ; '
'rabbitmqctl -s -q list_queues -p $vhost '
'rabbitmqctl $FLAG -q list_queues -p $vhost '
'name durable auto_delete arguments ; '
'echo "__VHOST__" ; '
'done'
Expand All @@ -50,17 +56,40 @@ def process(self, device, results, unused):
node_title = None
node_id = None
nodes = []
rabbit_version = None

rabbit_regex = re.search(r'rabbit,"RabbitMQ","[0-9]+\.[0-9]+\.[0-9]+"',
command_strings[0])
rabbit_regex_newer_version = re.search(r'RabbitMQ version: [0-9]+\.[0-9]+\.[0-9]+',
command_strings[0])

if rabbit_regex:
rabbit_match = rabbit_regex.group(0)
rabbit_version = re.search('([0-9]+\.[0-9]+\.[0-9]+)', rabbit_match).group(1)
if rabbit_regex_newer_version:
rabbit_match = rabbit_regex_newer_version.group(0)
rabbit_version = re.search('([0-9]+\.[0-9]+\.[0-9]+)', rabbit_match).group(1)

for line in command_strings[0].split('\n'):
match = re.search(r'Status of node (\S+).*$', line)
match_newer_version = re.search(r'Node name: (\S+).*$', line)
if match:
node_title = match.group(1).strip("'")
node_id = prepId(node_title)
nodes.append(ObjectMap(data={
'id': node_id,
'title': node_title,
}))

'rabbit_version': rabbit_version,
}))
continue
elif match_newer_version:
node_title = match_newer_version.group(1).strip("'")
node_id = prepId(node_title)
nodes.append(ObjectMap(data={
'id': node_id,
'title': node_title,
'rabbit_version': rabbit_version,
}))
continue

match = re.search(r'^(Error: .+)$', line)
Expand All @@ -85,10 +114,11 @@ def process(self, device, results, unused):

# vhosts
maps.extend(self.getVHostRelMap(
device, command_strings[1], 'rabbitmq_nodes/%s' % node_id))
device, command_strings[1], 'rabbitmq_nodes/%s' % node_id,
rabbit_version))
return maps

def getVHostRelMap(self, device, vhosts_string, compname):
def getVHostRelMap(self, device, vhosts_string, compname, rabbit_version=None):
rel_maps = []
object_maps = []

Expand All @@ -110,13 +140,14 @@ def getVHostRelMap(self, device, vhosts_string, compname):
object_maps.append(ObjectMap(data={
'id': vhost_id,
'title': vhost_title,
'rabbit_version': rabbit_version,
}))

exchanges = self.getExchangeRelMap(exchanges_string,
'%s/rabbitmq_vhosts/%s' % (compname, vhost_id))
'%s/rabbitmq_vhosts/%s' % (compname, vhost_id), rabbit_version)

queues = self.getQueueRelMap(queues_string,
'%s/rabbitmq_vhosts/%s' % (compname, vhost_id))
'%s/rabbitmq_vhosts/%s' % (compname, vhost_id), rabbit_version)

LOG.info(
'Found vhost %s with %d exchanges and %d queues on %s',
Expand All @@ -132,7 +163,7 @@ def getVHostRelMap(self, device, vhosts_string, compname):
modname='ZenPacks.zenoss.RabbitMQ.RabbitMQVHost',
objmaps=object_maps)] + rel_maps

def getExchangeRelMap(self, exchanges_string, compname):
def getExchangeRelMap(self, exchanges_string, compname, rabbit_version=None):
object_maps = []
for exchange_string in exchanges_string.split('\n'):
if not exchange_string.strip():
Expand Down Expand Up @@ -180,15 +211,15 @@ def getExchangeRelMap(self, exchanges_string, compname):
'auto_delete': auto_delete,
'federated': federated,
'arguments': arguments,
'rabbit_version': rabbit_version,
}))

return RelationshipMap(
compname=compname,
relname='rabbitmq_exchanges',
modname='ZenPacks.zenoss.RabbitMQ.RabbitMQExchange',
objmaps=object_maps)

def getQueueRelMap(self, queues_string, compname):
def getQueueRelMap(self, queues_string, compname, rabbit_version=None):
object_maps = []
for queue_string in queues_string.split('\n'):
if not queue_string.strip():
Expand Down Expand Up @@ -236,6 +267,7 @@ def getQueueRelMap(self, queues_string, compname):
'auto_delete': auto_delete,
'federated': federated,
'arguments': arguments,
'rabbit_version': rabbit_version,
}))

return RelationshipMap(
Expand Down
8 changes: 4 additions & 4 deletions ZenPacks/zenoss/RabbitMQ/objects/objects.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ rabbitmq_node_status
4
</property>
<property type="string" id="commandTemplate" mode="w" >
rabbitmqctl -s -n ${here/title} list_channels pid consumer_count messages_unacknowledged acks_uncommitted 2&gt;&amp;1
rabbitmqctl ${here/rabbitmq_version_flag} -n ${here/title} list_channels pid consumer_count messages_unacknowledged acks_uncommitted 2&gt;&amp;1
</property>
<property type="int" id="cycletime" mode="w" >
300
Expand Down Expand Up @@ -117,7 +117,7 @@ rabbitmq_node_status
4
</property>
<property type="string" id="commandTemplate" mode="w" >
rabbitmqctl -s -n ${here/title} list_connections pid channels recv_oct recv_cnt send_oct send_cnt send_pend 2&gt;&amp;1
rabbitmqctl ${here/rabbitmq_version_flag} -n ${here/title} list_connections pid channels recv_oct recv_cnt send_oct send_cnt send_pend 2&gt;&amp;1
</property>
<property type="int" id="cycletime" mode="w" >
300
Expand Down Expand Up @@ -270,7 +270,7 @@ rabbitmq_node_status
4
</property>
<property type="string" id="commandTemplate" mode="w" >
rabbitmqctl -s -q -n ${here/title} status 2&gt;&amp;1
rabbitmqctl ${here/rabbitmq_version_flag} -q -n ${here/title} status 2&gt;&amp;1
</property>
<property type="int" id="cycletime" mode="w" >
60
Expand Down Expand Up @@ -831,7 +831,7 @@ rabbitmq_node_status
4
</property>
<property type="string" id="commandTemplate" mode="w" >
rabbitmqctl -s -n ${here/rabbitmq_node_name} list_queues -p ${here/rabbitmq_vhost_name} name messages_ready messages_unacknowledged messages consumers memory 2&gt;&amp;1
rabbitmqctl ${here/rabbitmq_version_flag} -n ${here/rabbitmq_node_name} list_queues -p ${here/rabbitmq_vhost_name} name messages_ready messages_unacknowledged messages consumers memory 2&gt;&amp;1
</property>
<property type="int" id="cycletime" mode="w" >
300
Expand Down

0 comments on commit 13b3767

Please sign in to comment.