diff --git a/sos/report/plugins/pod_log.py b/sos/report/plugins/pod_log.py new file mode 100644 index 0000000000..9286bf23f6 --- /dev/null +++ b/sos/report/plugins/pod_log.py @@ -0,0 +1,38 @@ +# Copyright (C) 2024 Red Hat, Inc. +# +# 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.report.plugins import IndependentPlugin, Plugin, PluginOpt + + +class PodLog(Plugin, IndependentPlugin): + + short_desc = 'All logs under /var/log/pods' + long_desc = ('Get all the logs from /var/log/pods and also recreate the ' + '/var/log/containers symlinks to them. This will get rotated ' + 'logs in Kubernetes/OpenShift') + plugin_name = 'pod_log' + logdirs = ('/var/log/pods/', '/var/log/containers/') + files = (logdirs[0], ) + option_list = [ + PluginOpt('anysize', default=False, val_type=bool, + desc='gather all pod logs ignoring size limits'), + PluginOpt('maxage', default=None, val_type=int, + desc='gather only pod logs with `mtime` not older than this ' + 'many hours') + ] + + def setup(self): + self.add_copy_spec( + self.logdirs, + sizelimit=0 if self.get_option('anysize') else None, + maxage=self.get_option('maxage'), + ) + +# vim: set et ts=4 sw=4 :