diff options
author | Jake Hunsaker <jhunsake@redhat.com> | 2021-04-22 11:42:26 -0400 |
---|---|---|
committer | Jake Hunsaker <jhunsake@redhat.com> | 2021-04-26 11:01:48 -0400 |
commit | f3f70abd4c95cd69ff019821d1cee5ddaab6cbb6 (patch) | |
tree | 475e1401daa240d1e9ad44dfeba346e1683cf4a5 | |
parent | 9ee8f4d0dc1d21ee30ebc25a54e473fd1eb2a227 (diff) | |
download | sos-f3f70abd4c95cd69ff019821d1cee5ddaab6cbb6.tar.gz |
[apache] Refactor duplicate code for Jboss file collections
Refactor the collections for the different httpd versions collected by
the RedHatApache instance of this plugin, to remove the repetition of
similar collection points.
Moving forward, collection of newer httpd versions will only need to
specify the version number, rather than explicitly repeat the same file
collection paths.
Closes: #704
Resolves: #2505
Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
-rw-r--r-- | sos/report/plugins/apache.py | 72 |
1 files changed, 34 insertions, 38 deletions
diff --git a/sos/report/plugins/apache.py b/sos/report/plugins/apache.py index 38635a7f..838c393b 100644 --- a/sos/report/plugins/apache.py +++ b/sos/report/plugins/apache.py @@ -48,48 +48,44 @@ class RedHatApache(Apache, RedHatPlugin): def setup(self): super(RedHatApache, self).setup() - self.add_copy_spec([ - "/etc/httpd/conf/httpd.conf", - "/etc/httpd/conf.d/*.conf", - "/etc/httpd/conf.modules.d/*.conf", - # JBoss Enterprise Web Server 2.x - "/etc/httpd22/conf/httpd.conf", - "/etc/httpd22/conf.d/*.conf", - # Red Hat JBoss Web Server 3.x - "/etc/httpd24/conf/httpd.conf", - "/etc/httpd24/conf.d/*.conf", - "/etc/httpd24/conf.modules.d/*.conf", - ]) + # httpd versions, including those used for JBoss Web Server + vers = ['', '22', '24'] + + # Extrapolate all top-level config directories for each version, and + # relevant config files within each + etcdirs = ["/etc/httpd%s" % ver for ver in vers] + confs = [ + "conf/httpd.conf", + "conf.d/*.conf", + "conf.modules.d/*.conf" + ] + + # Extrapolate top-level logging directories for each version, and the + # relevant log files within each + logdirs = ["/var/log/httpd%s" % ver for ver in vers] + logs = [ + "access_log", + "error_log", + "ssl_access_log", + "ssl_error_log" + ] - self.add_forbidden_path("/etc/httpd/conf/password.conf") + self.add_forbidden_path([ + "%s/conf/password.conf" % etc for etc in etcdirs + ]) - self.add_service_status('httpd') + for edir in etcdirs: + for conf in confs: + self.add_copy_spec("%s/%s" % (edir, conf)) - # collect only the current log set by default - self.add_copy_spec([ - "/var/log/httpd/access_log", - "/var/log/httpd/error_log", - "/var/log/httpd/ssl_access_log", - "/var/log/httpd/ssl_error_log", - # JBoss Enterprise Web Server 2.x - "/var/log/httpd22/access_log", - "/var/log/httpd22/error_log", - "/var/log/httpd22/ssl_access_log", - "/var/log/httpd22/ssl_error_log", - # Red Hat JBoss Web Server 3.x - "/var/log/httpd24/access_log", - "/var/log/httpd24/error_log", - "/var/log/httpd24/ssl_access_log", - "/var/log/httpd24/ssl_error_log", - ]) if self.get_option("log") or self.get_option("all_logs"): - self.add_copy_spec([ - "/var/log/httpd/*", - # JBoss Enterprise Web Server 2.x - "/var/log/httpd22/*", - # Red Hat JBoss Web Server 3.x - "/var/log/httpd24/*" - ]) + self.add_copy_spec(logdirs) + else: + for ldir in logdirs: + for log in logs: + self.add_copy_spec("%s/%s" % (ldir, log)) + + self.add_service_status('httpd') class DebianApache(Apache, DebianPlugin, UbuntuPlugin): |