Sandro Bonazzola has uploaded a new change for review.

Change subject: sos: engine: add jboss stack trace
......................................................................

sos: engine: add jboss stack trace

added jbosstrace option, enabled by default, to engine
sos plugin.
The new option send a SIGQUIT signal to the JBoss
process launched by ovirt-engine, causing a dump of
the stack trace to /var/log/ovirt-engine/console.log.

Other JBoss instances will not receive that signal.

Change-Id: Id049f1cc7f322995a8692562a3f7aebddc7cc04d
Bug-Url: https://bugzilla.redhat.com/989484
Signed-off-by: Sandro Bonazzola <sbona...@redhat.com>
---
M src/sos/plugins/engine.py
1 file changed, 57 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-log-collector 
refs/changes/65/19365/1

diff --git a/src/sos/plugins/engine.py b/src/sos/plugins/engine.py
index 8692328..8e206c7 100644
--- a/src/sos/plugins/engine.py
+++ b/src/sos/plugins/engine.py
@@ -1,3 +1,8 @@
+import os
+import signal
+import subprocess
+
+
 import sos.plugintools
 
 
@@ -5,7 +10,59 @@
 class engine(sos.plugintools.PluginBase):
     """oVirt related information"""
 
+    optionList = [
+        (
+            'jbosstrace',
+            'Enable oVirt Engine JBoss stack trace generation',
+            '',
+            True
+        ),
+    ]
+
+    def __init__(self, pluginname, commons):
+        sos.plugintools.PluginBase.__init__(self, pluginname, commons)
+
     def setup(self):
+        if self.getOption('jbosstrace'):
+            proc = subprocess.Popen(
+                args=[
+                    '/usr/bin/pgrep',
+                    '-f',
+                    'jboss',
+                ],
+                stdout=subprocess.PIPE,
+            )
+            output, err = proc.communicate()
+            returncode = proc.returncode
+            jboss_pids = set()
+            if returncode == 0:
+                jboss_pids = set([int(x) for x in output.splitlines()])
+                proc = subprocess.Popen(
+                    args=[
+                        '/usr/bin/pgrep',
+                        '-f',
+                        'ovirt-engine',
+                    ],
+                    stdout=subprocess.PIPE,
+                )
+                engine_output, err = proc.communicate()
+                if returncode == 0:
+                    engine_pids = set(
+                        [int(x) for x in engine_output.splitlines()]
+                    )
+                    jboss_pids.intersection_update(engine_pids)
+                else:
+                    self.soslog.error('Unable to get engine pids: %s' % err)
+                    self.addAlert('Unable to get engine pids')
+            else:
+                self.soslog.error('Unable to get jboss pid: %s' % err)
+                self.addAlert('Unable to get jboss pid')
+            for pid in jboss_pids:
+                try:
+                    os.kill(pid, signal.SIGQUIT)
+                except OSError as e:
+                    self.soslog.error('Unable to send signal to %d' % pid, e)
+
         # Copy engine config files.
         self.addCopySpec("/etc/ovirt-engine")
         self.addCopySpec("/etc/rhevm")


-- 
To view, visit http://gerrit.ovirt.org/19365
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id049f1cc7f322995a8692562a3f7aebddc7cc04d
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-log-collector
Gerrit-Branch: master
Gerrit-Owner: Sandro Bonazzola <sbona...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to