https://github.com/sosreport/sos/wiki/
/usr/lib/python2.7/site-packages/sos/plugins
yum.py
from sos.plugins import Plugin, RedHatPlugin
class Yum(Plugin, RedHatPlugin):
"""yum information
"""
plugin_name = 'yum'
profiles = ('system', 'packagemanager', 'sysmgmt')
files = ('/etc/yum.conf',)
packages = ('yum',)
option_list = [
("yumlist", "list repositories and packages", "slow", False),
("yumdebug", "gather yum debugging data", "slow", False)
]
def setup(self):
# Pull all yum related information
self.add_copy_spec([
"/etc/yum",
"/etc/yum.repos.d",
"/etc/yum.conf",
"/var/log/yum.log"
])
# Get a list of channels the machine is subscribed to.
self.add_cmd_output("yum -C repolist")
# candlepin info
self.add_forbidden_path("/etc/pki/entitlement/key.pem")
self.add_forbidden_path("/etc/pki/entitlement/*-key.pem")
self.add_copy_spec([
"/etc/pki/product/*.pem",
"/etc/pki/consumer/cert.pem",
"/etc/pki/entitlement/*.pem"
])
self.add_cmd_output("yum history")
if self.get_option("yumlist"):
# List various information about available packages
self.add_cmd_output("yum list")
if self.get_option("yumdebug") and self.is_installed('yum-utils'):
# RHEL6+ alternative for this whole function:
# self.add_cmd_output("yum-debug-dump '%s'"
# % os.path.join(self.commons['dstroot'],"yum-debug-dump"))
r = self.call_ext_prog("yum-debug-dump")
try:
self.add_cmd_output("zcat %s" % (r['output'].split()[-1],))
except IndexError:
pass
plugin_name Plugin name
profiles -p (--profile) If you run sosreport with NAME and the value specified for NAME is specified in profiles, the plugin will be executed. You can check which plugin has what profiles with sosreport --list-profiles.
files, packages If the files specified in files exist or the packages specified in packages are installed, the plugin is enabled by default. The plugin can be enabled / disabled as an option.
option_list Options that can be specified for plugins From left: option name, option description (check with sosreport -l), fast or slow (no path is currently used as long as you grep the source, it is suggested to remove this item itself), default Valid / invalid.
setup method Mandatory sosreport loops the setup method of each plugin (around line 1247 of sosreport.py).
sosreport.py
1240 def setup(self):
1241 msg = "[%s:%s] executing 'sosreport %s'"
1242 self.soslog.info(msg % (__name__, "setup", " ".join(self._args)))
1243 self.ui_log.info(_(" Setting up plugins ..."))
1244 for plugname, plug in self.loaded_plugins:
1245 try:
1246 plug.archive = self.archive
1247 plug.setup()
1248 except KeyboardInterrupt:
1249 raise
1250 except (OSError, IOError) as e:
1251 if e.errno in fatal_fs_errors:
1252 self.ui_log.error("")
1253 self.ui_log.error(" %s while setting up plugins"
1254 % e.strerror)
1255 self.ui_log.error("")
1256 self._exit(1)
1257 if self.raise_plugins:
1258 raise
1259 self._log_plugin_exception(plugname, "setup")
1260 except:
1261 if self.raise_plugins:
1262 raise
1263 self._log_plugin_exception(plugname, "setup")
add_copy_spec method Copy and get the file.
add_cmd_output method Get the command execution result.
add_forbidden_path method Excludes the specified file from the acquisition target.
get_option method Returns True if the plugin option set in option_list is specified.
is_installed method Returns True if the specified package is installed.
call_ext_prog method Returns the command execution result in a process separate from sosreport.
Summarizing the above, the implementation of the yum plugin is as follows.
item | Contents |
---|---|
profiles | system packagemanager sysmgmt |
Valid conditions | /etc/yum.conf exists or when yum package is installed |
yumlist option | Get the execution result of the yum list command. Default disabled |
yumdebug option | yum-debug-Get the result of referencing the archive generated by the dump command with the zcat command. Default is disabled |
Acquisition file | /etc/yum /etc/yum.repos.d /etc/yum.conf /var/log/yum.log /etc/pki/product/*.pem(*1) /etc/pki/consumer/cert.pem /etc/pki/entitlement/*.pem /etc/pki/entitlement/key.pem /etc/pki/entitlement/*-key.pem yum-debug-Reference result by zcat command of archive generated by dump command(*2) |
Get command | yum -C repolist yum history yum list(*3) |
/etc/pki/entitlement/key.pem /etc/pki/entitlement/\*-key.pem
Recommended Posts