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

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