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

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