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

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