Blame SOURCES/sos-bz2011507-foreman-puma-status.patch

92cd8f
From 5a9458d318302c1caef862a868745fc8bdf5c741 Mon Sep 17 00:00:00 2001
92cd8f
From: Pavel Moravec <pmoravec@redhat.com>
92cd8f
Date: Mon, 4 Oct 2021 15:52:36 +0200
92cd8f
Subject: [PATCH] [foreman] Collect puma status and stats
92cd8f
92cd8f
Collect foreman-puma-status and 'pumactl [gc-|]stats', optionally using
92cd8f
SCL (if detected).
92cd8f
92cd8f
Resolves: #2712
92cd8f
92cd8f
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
92cd8f
---
92cd8f
 sos/report/plugins/foreman.py | 21 ++++++++++++++++++++-
92cd8f
 1 file changed, 20 insertions(+), 1 deletion(-)
92cd8f
92cd8f
diff --git a/sos/report/plugins/foreman.py b/sos/report/plugins/foreman.py
92cd8f
index 4539f12b..351794f4 100644
92cd8f
--- a/sos/report/plugins/foreman.py
92cd8f
+++ b/sos/report/plugins/foreman.py
92cd8f
@@ -13,6 +13,7 @@ from sos.report.plugins import (Plugin,
92cd8f
                                 UbuntuPlugin)
92cd8f
 from pipes import quote
92cd8f
 from re import match
92cd8f
+from sos.utilities import is_executable
92cd8f
 
92cd8f
 
92cd8f
 class Foreman(Plugin):
92cd8f
@@ -26,7 +27,9 @@ class Foreman(Plugin):
92cd8f
     option_list = [
92cd8f
         ('months', 'number of months for dynflow output', 'fast', 1),
92cd8f
         ('proxyfeatures', 'collect features of smart proxies', 'slow', False),
92cd8f
+        ('puma-gc', 'collect Puma GC stats', 'fast', False),
92cd8f
     ]
92cd8f
+    pumactl = 'pumactl %s -S /usr/share/foreman/tmp/puma.state'
92cd8f
 
92cd8f
     def setup(self):
92cd8f
         # for external DB, search in /etc/foreman/database.yml for:
92cd8f
@@ -134,6 +138,17 @@ class Foreman(Plugin):
92cd8f
                                 suggest_filename='dynflow_sidekiq_status')
92cd8f
         self.add_journal(units="dynflow-sidekiq@*")
92cd8f
 
92cd8f
+        # Puma stats & status, i.e. foreman-puma-stats, then
92cd8f
+        # pumactl stats -S /usr/share/foreman/tmp/puma.state
92cd8f
+        # and optionally also gc-stats
92cd8f
+        # if on RHEL with Software Collections, wrap the commands accordingly
92cd8f
+        if self.get_option('puma-gc'):
92cd8f
+            self.add_cmd_output(self.pumactl % 'gc-stats',
92cd8f
+                                suggest_filename='pumactl_gc-stats')
92cd8f
+        self.add_cmd_output(self.pumactl % 'stats',
92cd8f
+                            suggest_filename='pumactl_stats')
92cd8f
+        self.add_cmd_output('/usr/sbin/foreman-puma-status')
92cd8f
+
92cd8f
         # collect tables sizes, ordered
92cd8f
         _cmd = self.build_query_cmd(
92cd8f
             "SELECT table_name, pg_size_pretty(total_bytes) AS total, "
92cd8f
@@ -297,6 +312,10 @@ class RedHatForeman(Foreman, RedHatPlugin):
92cd8f
         self.add_file_tags({
92cd8f
             '/usr/share/foreman/.ssh/ssh_config': 'ssh_foreman_config',
92cd8f
         })
92cd8f
+        # if we are on RHEL7 with scl, wrap some Puma commands by
92cd8f
+        # scl enable tfm 'command'
92cd8f
+        if self.policy.dist_version() == 7 and is_executable('scl'):
92cd8f
+            self.pumactl = "scl enable tfm '%s'" % self.pumactl
92cd8f
 
92cd8f
         super(RedHatForeman, self).setup()
92cd8f
 
92cd8f
-- 
92cd8f
2.31.1
92cd8f