aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJake Hunsaker <jhunsake@redhat.com>2018-12-27 13:54:59 -0500
committerBryn M. Reeves <bmr@redhat.com>2019-03-21 16:23:26 +0000
commit68bf5239d2fc0d9555e884f463f8cd88d64dd31f (patch)
tree106e12d62b6fbcea06d4c0c762e32795b89bae4d
parent96573990f0c66064fdac905d69c469613b7aa2d9 (diff)
downloadsos-68bf5239d2fc0d9555e884f463f8cd88d64dd31f.tar.gz
[pulp] Add new plugin
Adds a new plugin for pulp as part of the effort to port the foreman-debug script to native sos plugins. Related: #1525 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com> Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r--sos/plugins/pulp.py72
1 files changed, 72 insertions, 0 deletions
diff --git a/sos/plugins/pulp.py b/sos/plugins/pulp.py
new file mode 100644
index 00000000..e947c174
--- /dev/null
+++ b/sos/plugins/pulp.py
@@ -0,0 +1,72 @@
+# Copyright (C) 2018 Red Hat, Inc., Jake Hunsaker <jhunsake@redhat.com>
+
+# This file is part of the sos project: https://github.com/sosreport/sos
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions of
+# version 2 of the GNU General Public License.
+#
+# See the LICENSE file in the source distribution for further information.
+
+from sos.plugins import Plugin, RedHatPlugin
+from pipes import quote
+
+
+class Pulp(Plugin, RedHatPlugin):
+ """Pulp platform"""
+
+ plugin_name = "pulp"
+ packages = ("pulp-server", "pulp-katello")
+ option_list = [
+ ('tasks', 'number of tasks to collect from DB queries', 'fast', 200)
+ ]
+
+ def setup(self):
+ self.add_copy_spec([
+ "/etc/pulp/*.conf",
+ "/etc/pulp/server/plugins.conf.d/",
+ "/etc/default/pulp*",
+ "/var/log/httpd/pulp-http.log*",
+ "/var/log/httpd/pulp-https.log*",
+ "/var/log/httpd/pulp-http_access_ssl.log*",
+ "/var/log/httpd/pulp-https_access_ssl.log*",
+ "/var/log/httpd/pulp-http_error_ssl.log*",
+ "/var/log/httpd/pulp-https_error_ssl.log*"
+ ])
+
+ num_tasks = self.get_option('tasks')
+
+ mtasks = self.build_mongo_cmd(
+ '\"DBQuery.shellBatchSize=%s;; '
+ 'db.task_status.find().sort({finish_time: -1})'
+ '.pretty().shellPrint()\"' % num_tasks
+ )
+
+ mres = self.build_mongo_cmd(
+ '\"DBQuery.shellBatchSize=%s;; '
+ 'db.reserved_resources.find().pretty().shellPrint()\"' % num_tasks
+ )
+
+ prun = self.build_mongo_cmd(
+ r'"DBQuery.shellBatchSize=%s;; '
+ r'db.task_status.find({state:{\$ne: \"finished\"}}).pretty()'
+ r'.shellPrint()"' % num_tasks
+ )
+
+ self.add_cmd_output(mtasks, suggest_filename="mongo-task_status")
+ self.add_cmd_output(mres, suggest_filename="mongo-reserved_resources")
+ self.add_cmd_output(prun, suggest_filename="pulp-running_tasks")
+
+ def build_mongo_cmd(self, query):
+ _cmd = "bash -c %s"
+ _moncmd = "mongo pulp_database --eval %s"
+ return _cmd % quote(_moncmd % query)
+
+ def postproc(self):
+ etcreg = r"(([a-z].*(passw|token|cred|secret).*)\:(\s))(.*)"
+ repl = r"\1 ********"
+ self.do_path_regex_sub("/etc/pulp/(.*).conf", etcreg, repl)
+ jreg = r"(\s*\".*(passw|cred|token|secret).*\:)(.*)"
+ self.do_path_regex_sub("/etc/pulp(.*)(.json$)", jreg, repl)
+
+# vim: set et ts=4 sw=4 :