sos.plugins — Plugin Interface

This exports methods available for use by plugins for sos

class sos.plugins.DebianPlugin[source]

Bases: object

Tagging class for Debian Linux

class sos.plugins.ExperimentalPlugin[source]

Bases: object

Tagging class that indicates that this plugin is experimental

class sos.plugins.IndependentPlugin[source]

Bases: object

Tagging class for plugins that can run on any platform

class sos.plugins.Plugin(commons)[source]

Bases: object

This is the base class for sosreport plugins. Plugins should subclass this and set the class variables where applicable.

plugin_name is a string returned by plugin.name(). If this is set to None (the default) class_.__name__.tolower() will be returned. Be sure to set this if you are defining multiple plugins that do the same thing on different platforms.

requires_root is a boolean that specifies whether or not sosreport should execute this plugin as a super user.

version is a string representing the version of the plugin. This can be useful for post-collection tooling.

packages (files) is an iterable of the names of packages (the paths of files) to check for before running this plugin. If any of these packages or files is found on the system, the default implementation of check_enabled will return True.

profiles is an iterable of profile names that this plugin belongs to. Whenever any of the profiles is selected on the command line the plugin will be enabled (subject to normal check_enabled tests).

add_alert(alertstring)[source]

Add an alert to the collection of alerts for this plugin. These will be displayed in the report

add_cmd_output(cmds, suggest_filename=None, root_symlink=None, timeout=300, stderr=True, chroot=True, runat=None)[source]

Run a program or a list of programs and collect the output

add_copy_spec(copyspecs)[source]

Add a file specification (can be file, dir,or shell glob) to be copied into the sosreport by this module.

add_copy_spec_limit(copyspec, sizelimit=None, tailit=True)[source]

Add a file or glob but limit it to sizelimit megabytes. If fname is a single file the file will be tailed to meet sizelimit. If the first file in a glob is too large it will be tailed to meet the sizelimit.

add_custom_text(text)[source]

Append text to the custom text that is included in the report. This is freeform and can include html.

add_forbidden_path(forbidden)[source]

Specify a path to not copy, even if it’s part of a copy_specs[] entry.

add_journal(units=None, boot=None, since=None, until=None, lines=None, allfields=False, output=None, timeout=None)[source]

Collect journald logs from one of more units.

Keyword arguments: units – A string, or list of strings specifying the systemd

units for which journal entries will be collected.
boot – A string selecting a boot index using the journalctl
syntax. The special values ‘this’ and ‘last’ are also accepted.
since – A string representation of the start time for journal
messages.
until – A string representation of the end time for journal
messages.

lines – The maximum number of lines to be collected. allfields – Include all journal fields regardless of size or

non-printable characters.
output – A journalctl output control string, for example
“verbose”.

timeout – An optional timeout in seconds.

add_string_as_file(content, filename)[source]

Add a string to the archive as a file named filename

archive = None
call_ext_prog(prog, timeout=300, stderr=True, chroot=True, runat=None)[source]

Execute a command independantly of the output gathering part of sosreport.

check_enabled()[source]

This method will be used to verify that a plugin should execute given the condition of the underlying environment. The default implementation will return True if neither class.files or class.packages is specified. If either are specified the plugin will check for the existence of any of the supplied files or packages and return True if any exist. It is encouraged to override this method if this behavior isn’t applicable.

check_ext_prog(prog)[source]

Execute a command independently of the output gathering part of sosreport and check the return code. Return True for a return code of 0 and False otherwise.

collect()[source]

Collect the data for a plugin.

default_enabled()[source]

This decides whether a plugin should be automatically loaded or only if manually specified in the command line.

do_cmd_output_sub(cmd, regexp, subst)[source]

Apply a regexp substitution to command output archived by sosreport. cmd is the command name from which output is collected (i.e. excluding parameters). The regexp can be a string or a compiled re object. The substitution string, subst, is a string that replaces each occurrence of regexp in each file collected from cmd. Internally ‘cmd’ is treated as a glob with a leading and trailing ‘*’ and each matching file from the current module’s command list is subjected to the replacement.

This function returns the number of replacements made.

do_cmd_private_sub(cmd)[source]

Remove certificate and key output archived by sosreport. cmd is the command name from which output is collected (i.e. exlcuding parameters). Any matching instances are replaced with: ‘—–SCRUBBED’ and this function does not take a regexp or substituting string.

This function returns the number of replacements made.

do_file_sub(srcpath, regexp, subst)[source]

Apply a regexp substitution to a file archived by sosreport. srcpath is the path in the archive where the file can be found. regexp can be a regexp string or a compiled re object. subst is a string to replace each occurance of regexp in the content of srcpath.

This function returns the number of replacements made.

do_path_regex_sub(pathexp, regexp, subst)[source]

Apply a regexp substituation to a set of files archived by sos. The set of files to be substituted is generated by matching collected file pathnames against pathexp which may be a regular expression string or compiled re object. The portion of the file to be replaced is specified via regexp and the replacement string is passed in subst.

do_regex_find_all(regex, fname)[source]
file_grep(regexp, *fnames)[source]

Returns lines matched in fnames, where fnames can either be pathnames to files to grep through or open file objects to grep through line by line.

files = ()
get_all_options()[source]

return a list of all options selected

get_cmd_output_now(exe, suggest_filename=None, root_symlink=False, timeout=300, stderr=True, chroot=True, runat=None)[source]

Execute a command and save the output to a file for inclusion in the report.

get_cmd_output_path(name=None, make=True)[source]

Return a path into which this module should store collected command output

get_command_output(prog, timeout=300, stderr=True, chroot=True, runat=None)[source]
get_description()[source]

This function will return the description for the plugin

get_option(optionname, default=0)[source]

Returns the first value that matches ‘optionname’ in parameters passed in via the command line or set via set_option or via the global_plugin_options dictionary, in that order.

optionaname may be iterable, in which case the first option that matches any of the option names is returned.

get_option_as_list(optionname, delimiter=', ', default=None)[source]

Will try to return the option as a list separated by the delimiter.

is_installed(package_name)[source]

Is the package $package_name installed?

is_module_loaded(module_name)[source]

Return whether specified moudle as module_name is loaded or not

join_sysroot(path)[source]
classmethod name(class_)[source]

Returns the plugin’s name as a string. This should return a lowercase string.

packages = ()
plugin_name = None
policy()[source]
postproc()[source]

Perform any postprocessing. To be replaced by a plugin if required.

profiles = ()
report()[source]

Present all information that was gathered in an html file that allows browsing the results.

requires_root = True
set_option(optionname, value)[source]

set the named option to value.

setup()[source]

Collect the list of files declared by the plugin. This method may be overridden to add further copy_specs, forbidden_paths, and external programs if required.

strip_sysroot(path)[source]
sysroot = '/'
tmp_in_sysroot()[source]
use_sysroot()[source]
version = 'unversioned'
class sos.plugins.PowerKVMPlugin[source]

Bases: sos.plugins.RedHatPlugin

Tagging class for IBM PowerKVM Linux

class sos.plugins.RedHatPlugin[source]

Bases: object

Tagging class for Red Hat’s Linux distributions

class sos.plugins.SuSEPlugin[source]

Bases: object

Tagging class for SuSE Linux distributions

class sos.plugins.UbuntuPlugin[source]

Bases: object

Tagging class for Ubuntu Linux

class sos.plugins.ZKVMPlugin[source]

Bases: sos.plugins.RedHatPlugin

Tagging class for IBM ZKVM Linux

sos.plugins.import_plugin(name, superclasses=None)[source]

Import name as a module and return a list of all classes defined in that module. superclasses should be a tuple of valid superclasses to import, this defaults to (Plugin,).

sos.plugins.regex_findall(regex, fname)[source]

Return a list of all non overlapping matches in the string(s)