|
|
7b9b39 |
From 2780f6d6ec3a4db72ed5a00aea15ac750394314c Mon Sep 17 00:00:00 2001
|
|
|
7b9b39 |
From: Michele Baldessari <michele@acksyn.org>
|
|
|
7b9b39 |
Date: Wed, 17 Jan 2018 15:07:53 +0100
|
|
|
7b9b39 |
Subject: [PATCH] [rabbitmq] Log collection fixes when rabbitmq runs in a
|
|
|
7b9b39 |
container
|
|
|
7b9b39 |
|
|
|
7b9b39 |
When rabbitmq is running inside a container all the rabbitmqctl
|
|
|
7b9b39 |
commands will fail with some obscure (welsh?) error messages like:
|
|
|
7b9b39 |
|
|
|
7b9b39 |
$ rabbitmqctl cluster_status
|
|
|
7b9b39 |
erno" ienrirto rt elromgigneart ipnrge sienn td)o _booetr"r,o{r: b<a0d.ar2g.,0[>{
|
|
|
7b9b39 |
l_prim_loader,check_file_result,3,[]},{init,get_boot,1,[]},{init,get_boot,2,[]},{init,do_boot,3,[]}]}}
|
|
|
7b9b39 |
init terminating in do_boot ()
|
|
|
7b9b39 |
|
|
|
7b9b39 |
When run inside containers we need to run any rabbitmqctl command inside
|
|
|
7b9b39 |
the container, so that output is properly collected:
|
|
|
7b9b39 |
$ docker exec -t rabbitmq-bundle-docker-0 rabbitmqctl cluster_status
|
|
|
7b9b39 |
Cluster status of node 'rabbit@controller-0' ...
|
|
|
7b9b39 |
[{nodes,[{disc,['rabbit@controller-0','rabbit@controller-1',
|
|
|
7b9b39 |
'rabbit@controller-2']}]},
|
|
|
7b9b39 |
{running_nodes,['rabbit@controller-2','rabbit@controller-1',
|
|
|
7b9b39 |
'rabbit@controller-0']},
|
|
|
7b9b39 |
{cluster_name,<<"rabbit@controller-0.localdomain">>},
|
|
|
7b9b39 |
{partitions,[]},
|
|
|
7b9b39 |
{alarms,[{'rabbit@controller-2',[]},
|
|
|
7b9b39 |
{'rabbit@controller-1',[]},
|
|
|
7b9b39 |
{'rabbit@controller-0',[]}]}]
|
|
|
7b9b39 |
|
|
|
7b9b39 |
While we're at it we also collect the logs of any rabbitmq container.
|
|
|
7b9b39 |
This is particularly useful in containerized openstack deployments
|
|
|
7b9b39 |
where short-lived containers are used to set up the cloud.
|
|
|
7b9b39 |
|
|
|
7b9b39 |
Since the info output by 'rabbitmqctl cluster_status' and 'rabbitmqctl
|
|
|
7b9b39 |
list_policies' is already contained in 'rabbitmqctl report', we just
|
|
|
7b9b39 |
remove the former two commands.
|
|
|
7b9b39 |
|
|
|
7b9b39 |
First reported via RHBZ#1525620
|
|
|
7b9b39 |
|
|
|
7b9b39 |
Signed-off-by: Michele Baldessari <michele@acksyn.org>
|
|
|
7b9b39 |
Signed-off-by: John Eckersberg <jeckersb@redhat.com>
|
|
|
7b9b39 |
---
|
|
|
7b9b39 |
sos/plugins/rabbitmq.py | 23 ++++++++++++++++++++---
|
|
|
7b9b39 |
1 file changed, 20 insertions(+), 3 deletions(-)
|
|
|
7b9b39 |
|
|
|
7b9b39 |
diff --git a/sos/plugins/rabbitmq.py b/sos/plugins/rabbitmq.py
|
|
|
7b9b39 |
index 2c7e428a..8057dd90 100644
|
|
|
7b9b39 |
--- a/sos/plugins/rabbitmq.py
|
|
|
7b9b39 |
+++ b/sos/plugins/rabbitmq.py
|
|
|
7b9b39 |
@@ -28,9 +28,26 @@ class RabbitMQ(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin):
|
|
|
7b9b39 |
packages = ('rabbitmq-server',)
|
|
|
7b9b39 |
|
|
|
7b9b39 |
def setup(self):
|
|
|
7b9b39 |
- self.add_cmd_output("rabbitmqctl report")
|
|
|
7b9b39 |
- self.add_cmd_output("rabbitmqctl cluster_status")
|
|
|
7b9b39 |
- self.add_cmd_output("rabbitmqctl list_policies")
|
|
|
7b9b39 |
+ container_status = self.get_command_output(
|
|
|
7b9b39 |
+ "docker ps -a --format='{{ .Names }}'")
|
|
|
7b9b39 |
+
|
|
|
7b9b39 |
+ in_container = False
|
|
|
7b9b39 |
+ container_names = []
|
|
|
7b9b39 |
+ if container_status['status'] == 0:
|
|
|
7b9b39 |
+ for line in container_status['output'].splitlines():
|
|
|
7b9b39 |
+ if line.startswith("rabbitmq"):
|
|
|
7b9b39 |
+ in_container = True
|
|
|
7b9b39 |
+ container_names.append(line)
|
|
|
7b9b39 |
+
|
|
|
7b9b39 |
+ if in_container:
|
|
|
7b9b39 |
+ for container in container_names:
|
|
|
7b9b39 |
+ self.add_cmd_output('docker logs {0}'.format(container))
|
|
|
7b9b39 |
+ self.add_cmd_output(
|
|
|
7b9b39 |
+ 'docker exec -t {0} rabbitmqctl report'
|
|
|
7b9b39 |
+ .format(container)
|
|
|
7b9b39 |
+ )
|
|
|
7b9b39 |
+ else:
|
|
|
7b9b39 |
+ self.add_cmd_output("rabbitmqctl report")
|
|
|
7b9b39 |
|
|
|
7b9b39 |
self.add_copy_spec([
|
|
|
7b9b39 |
"/etc/rabbitmq/*",
|
|
|
7b9b39 |
--
|
|
|
7b9b39 |
2.13.6
|
|
|
7b9b39 |
|