sos.report.plugins — Plugin Interface

This exports methods available for use by plugins for sos

class sos.report.plugins.CosPlugin[source]

Bases: object

Tagging class for Container-Optimized OS

class sos.report.plugins.DebianPlugin[source]

Bases: object

Tagging class for Debian Linux

class sos.report.plugins.ExperimentalPlugin[source]

Bases: object

Tagging class that indicates that this plugin is experimental

class sos.report.plugins.IndependentPlugin[source]

Bases: object

Tagging class for plugins that can run on any platform

class sos.report.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.

Parameters:commons (dict) – A set of information that is shared internally so that plugins may access the same dataset. This is provided automatically by sos

Each Plugin() subclass should also subclass at least one tagging class, e.g. RedHatPlugin, to support that distribution. If different distributions require different collections, each distribution should have its own subclass of the Plugin that also subclasses the tagging class for their respective distributions.

Variables:
  • plugin_name (str) – The name of the plugin, will be returned by name()
  • packages (tuple) – Package name(s) that, if installed, enable this plugin
  • files (tuple) – File path(s) that, if present, enable this plugin
  • commands (tuple) – Executables that, if present, enable this plugin
  • kernel_mods (tuple) – Kernel module(s) that, if loaded, enable this plugin
  • services (tuple) – Service name(s) that, if running, enable this plugin
  • architectures (tuple, or None) – Architecture(s) this plugin is enabled for. Defaults to ‘none’ to enable on all arches.
  • profiles (tuple) – Name(s) of profile(s) this plugin belongs to
  • plugin_timeout (int) – Timeout in seconds for this plugin as a whole
  • cmd_timeout (int) – Timeout in seconds for individual commands
add_alert(alertstring)[source]

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

Parameters:alertstring (str) – The text to add as an alert
add_blockdev_cmd(cmds, devices='block', timeout=None, sizelimit=None, chroot=True, runat=None, env=None, binary=False, prepend_path=None, whitelist=[], blacklist=[], tags=[], priority=10)[source]

Run a command or list of commands against storage-related devices.

Any commands specified by cmd will be iterated over the list of the specified devices. Commands passed to this should include a ‘%(dev)s’ variable for substitution.

Parameters:
  • cmds (str or a list of strings) – The command(s) to run against the list of devices
  • devices (str or a list of device paths) – The device paths to run cmd against. If set to block or fibre, the commands will be run against the matching list of discovered devices
  • timeout (int) – Timeout in seconds to allow each cmd to run
  • sizelimit (int) – Maximum amount of output to collect, in MB
  • chroot (bool) – Should sos chroot the command(s) being run
  • runat (str) – Set the filesystem location to execute the command from
  • env (dict) – Set environment variables for the command(s) being run
  • binary (bool) – Is the output collected going to be binary data
  • prepend_path (str or None) – The leading path for block device names
  • whitelist (list of str) – Limit the devices the cmds will be run against to devices matching these item(s)
  • blacklist (list of str) – Do not run cmds against devices matching these item(s)
add_cmd_output(cmds, suggest_filename=None, root_symlink=None, timeout=None, stderr=True, chroot=True, runat=None, env=None, binary=False, sizelimit=None, pred=None, subdir=None, changes=False, foreground=False, tags=[], priority=10, cmd_as_tag=False)[source]

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

Output will be limited to sizelimit, collecting the last X amount of command output matching sizelimit. Unless suggest_filename is set, the file that the output is saved to will match the command as it was executed, and will be saved under sos_commands/$plugin

Parameters:
  • cmds (str or a list of strings) – The command(s) to execute
  • suggest_filename (str) – Override the name of the file output is saved to within the archive
  • root_symlink (str) – If set, create a symlink with this name in the archive root
  • timeout (int) – Timeout in seconds to allow each cmd to run for
  • stderr (bool) – Should stderr output be collected
  • chroot (bool) – Should sos chroot the cmds being run
  • runat (str) – Run the cmds from this location in the filesystem
  • env (dict) – Set environment variables for the cmds being run
  • binary (bool) – Is the command expected to produce binary output
  • sizelimit (int) – Maximum amount of output in MB to save
  • pred (SoSPredicate) – A predicate to gate if cmds should be collected or not
  • subdir (str) – Save output to this subdirectory, within the plugin’s directory under sos_commands
  • changes (int) – Do cmds have the potential to change system state
  • foreground (bool) – Should the cmds be run in the foreground, with an attached TTY
  • tags (str or a list of strings) – A tag or set of tags to add to the metadata entries for the cmds being run
  • priority (int) – The priority with which this command should be run, lower values will run before higher values
  • cmd_as_tag (bool) – Should the command string be automatically formatted to a tag?
add_cmd_tags(tagdict)[source]

Retroactively add tags to any commands that have been run by this plugin that match a given regex

Parameters:tagdict (dict) – A dict containing the command regex and associated tags

tagdict takes the form of {cmd_regex: tags}, for example to tag all commands starting with foo with the tag bar, use {‘foo.*’: [‘bar’]}

add_copy_spec(copyspecs, sizelimit=None, maxage=None, tailit=True, pred=None, tags=[])[source]

Add a file, directory, or regex matching filepaths to the archive

Parameters:
  • copyspecs (str or a list of strings) – A file, directory, or regex matching filepaths
  • sizelimit (int) – Limit the total size of collections from copyspecs to this size in MB
  • maxage (int) – Collect files with mtime not older than this many hours
  • tailit (bool) – Should a file that exceeds sizelimit be tail’ed to fit the remaining space to meet sizelimit
  • pred (SoSPredicate) – A predicate to gate if copyspecs should be collected
  • tags (str or a list of strings) – A tag or set of tags to add to the metadata information for this collection

copyspecs will be expanded and/or globbed as appropriate. Specifying a directory here will cause the plugin to attempt to collect the entire directory, recursively.

Note that sizelimit is applied to each copyspec, not each file individually. For example, a copyspec of ['/etc/foo', '/etc/bar.conf'] and a sizelimit of 25 means that sos will collect up to 25MB worth of files within /etc/foo, and will collect the last 25MB of /etc/bar.conf.

add_custom_text(text)[source]

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

Parameters:text (str) – The text to include in the report
add_default_collections()[source]

Based on the class attrs defined for plugin enablement, add a standardized set of collections before we call the plugin’s own setup() method.

add_env_var(name)[source]

Add an environment variable to the list of to-be-collected env vars.

Collected environment variables will be saved to an environment file in the archive root, and any variable specified for collection will be collected in lowercase, uppercase, and the form provided

Parameters:name (str) – The name of the environment variable to collect
add_file_tags(tagdict)[source]

Apply a tag to a file matching a given regex, for use when a file is copied by a more generic copyspec.

Parameters:tagdict (dict) – A dict containing the filepatterns to match and the tag(s) to apply to those files

tagdict takes the form {file_pattern: tag}, E.G. to match all bond devices from /proc/net/bonding with the tag bond, use {‘/proc/net/bonding/bond.*’: [‘bond’]}

add_forbidden_path(forbidden, recursive=False)[source]

Specify a path, or list of paths, to not copy, even if it’s part of an add_copy_spec() call

Parameters:
  • forbidden (str or a list of strings) – A filepath to forbid collection from
  • recursive – Should forbidden glob be applied recursively
add_journal(units=None, boot=None, since=None, until=None, lines=None, allfields=False, output=None, timeout=None, identifier=None, catalog=None, sizelimit=None, pred=None, tags=None, priority=10)[source]

Collect journald logs from one of more units.

Parameters:
  • units (str or a list of strings) – Which journald units to collect
  • boot (str) – A boot index using the journalctl syntax. The special values ‘this’ and ‘last’ are also accepted.
  • since (str) – Start time for journal messages
  • until (str) – End time forjournal messages
  • lines (int) – The maximum number of lines to be collected
  • allfields (bool) – Include all journal fields regardless of size or non-printable characters
  • output (str) – Journalctl output control string, for example “verbose”
  • timeout (int) – An optional timeout in seconds
  • identifier (str) – An optional message identifier
  • catalog (bool) – Augment lines with descriptions from the system catalog
  • sizelimit (int) – Limit to the size of output returned in MB. Defaults to the value of –log-size.
add_service_status(services, **kwargs)[source]

Collect service status information based on the InitSystem used

Parameters:
  • services (str or a list of strings) – Service name(s) to collect statuses for
  • kwargs – Optional arguments to pass to _add_cmd_output (timeout, predicate, suggest_filename,..)
add_string_as_file(content, filename, pred=None)[source]

Add a string to the archive as a file

Parameters:
  • content (str) – The string to write to the archive
  • filename (str) – The name of the file to write content to
  • pred (SoSPredicate) – A predicate to gate if the string should be added to the archive or not
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 none of class.files, class.packages, nor class.commands is specified. If any of these is specified the plugin will check for the existence of any of the corresponding paths, packages or commands and return True if any are present.

For SCLPlugin subclasses, it will check whether the plugin can be run for any of installed SCLs. If so, it will store names of these SCLs on the plugin class in addition to returning True.

For plugins with more complex enablement checks this method may be overridden.

Returns:True if the plugin should be run for this system, else False
Return type:bool
check_is_architecture()[source]

Checks whether or not the system is running on an architecture that the plugin allows. If not architecture is set, assume plugin can run on all arches.

Returns:True if the host’s architecture allows the plugin to run, else False
Return type:bool
check_process_by_name(process)[source]

Checks if a named process is found in /proc/[0-9]*/cmdline.

Parameters:process (str) – The name of the process
Returns:True if the process exists, else False
Return type:bool
check_timeout()[source]

Checks to see if the plugin has hit its timeout.

This is set when the sos.collect_plugin() method hits a timeout and terminates the thread. From there, a Popen() call can still continue to run, and we need to manually terminate it. Thus, check_timeout() should only be called in sos_get_command_output().

Since sos_get_command_output() is not plugin aware, this method is handed to that call to use as a polling method, to avoid passing the entire plugin object.

Returns:True if timeout has been hit, else False
Return type:bool
cmdtimeout

Returns either the default command timeout value, the value as provided on the commandline via -k plugin.cmd-timeout=value, or the value of the global –cmd-timeout option.

collect()[source]

Collect the data for a plugin.

collect_cmd_output(cmd, suggest_filename=None, root_symlink=False, timeout=None, stderr=True, chroot=True, runat=None, env=None, binary=False, sizelimit=None, pred=None, subdir=None, tags=[])[source]

Execute a command and save the output to a file for inclusion in the report, then return the results for further use by the plugin

Parameters:
  • cmd (str) – The command to run
  • suggest_filename – Filename to use when writing to the archive
  • suggest_filenamestr
  • root_symlink (bool) – Create a symlink in the archive root
  • timeout (int) – Time in seconds to allow a cmd to run
  • stderr (bool) – Write stderr to stdout?
  • chroot (bool) – Perform chroot before running cmd?
  • runat (str) – Run the command from this location, overriding chroot
  • env (dict) – Environment vars to set for the cmd
  • binary (bool) – Is the output in binary?
  • sizelimit (int) – Maximum size in MB of output to save
  • subdir (str) – Subdir in plugin directory to save to
  • changes (bool) – Does this cmd potentially make a change on the system?
  • tags (str or a list of strings) – Add tags in the archive manifest
Returns:

cmd exit status, output, and the filepath within the archive output was saved to

Return type:

dict

container_exists(name)[source]

If a container runtime is present, check to see if a container with a given name is currently running

Parameters:name (str) – The name of the container to check presence of
Returns:True if name exists, else False
Return type:bool
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.

This is used to obfuscate sensitive information captured by command output collection via plugins.

Parameters:
  • cmd (str) – The command name/binary name for collected output that needs to be obfuscated. Internally globbed with a leading and trailing *
  • regexp (str or compile re object) – A regex to match the contents of the command output against
  • subst (str) – The substitution string used to replace matches from regexp
Returns:

Number of replacements made

Return type:

int

do_cmd_private_sub(cmd, desc='')[source]

Remove certificate and key output archived by sos report. Any matching instances are replaced with: ‘—–SCRUBBED’ and this function does not take a regexp or substituting string.

Parameters:
  • cmd (str) – The name of the binary to scrub certificate output from
  • desc (str) – An identifier to add to the SCRUBBED header line
Returns:

Number of replacements made

Return type:

int

do_file_private_sub(pathregex, desc='')[source]

Scrub certificate/key/etc information from files collected by sos.

Files matching the provided pathregex are searched for content that resembles certificate, ssh keys, or similar information. Any matches are replaced with “—–SCRUBBED $desc” where desc is a description of the specific type of content being replaced, e.g. “—–SCRUBBED RSA PRIVATE KEY” so that support representatives can at least be informed of what type of content it was originally.

Parameters:
  • pathregex (str) – A string or regex of a filename to match against
  • desc (str) – A description of the replaced content
do_file_sub(srcpath, regexp, subst)[source]

Apply a regexp substitution to a file archived by sosreport.

Parameters:
  • srcpath (str) – Path in the archive where the file can be found
  • regexp (str or compiled re object) – A regex to match the contents of the file
  • subst (str) – The substitution string to be used to replace matches within the file
Returns:

Number of replacements made

Return type:

int

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.

Parameters:
  • pathexp (str or compiled re object) – A regex to match filenames within the archive
  • regexp (str or compiled re object) – A regex to match against the contents of each file
  • subst (str) – The substituion string to be used to replace matches
exec_cmd(cmd, timeout=None, stderr=True, chroot=True, runat=None, env=None, binary=False, pred=None, foreground=False, container=False, quotecmd=False)[source]

Execute a command right now and return the output and status, but do not save the output within the archive.

Use this method in a plugin’s setup() if command output is needed to build subsequent commands added to a report via add_cmd_output().

Parameters:
  • cmd (str) – The command to run
  • timeout (int) – Time in seconds to allow a cmd to run
  • stderr (bool) – Write stderr to stdout?
  • chroot (bool) – Perform chroot before running cmd?
  • runat (str) – Run the command from this location, overriding chroot
  • env (dict) – Environment vars to set for the cmd
  • binary (bool) – Is the output in binary?
  • pred (SoSPredicate) – A predicate to gate execution of the cmd
  • foreground (bool) – Run the cmd in the foreground with a TTY
  • container (str) – Execute this command in a container with this name
  • quotecmd (bool) – Whether the cmd should be quoted.
Returns:

Command exit status and output

Return type:

dict

file_grep(regexp, *fnames)[source]

Grep through file(s) for a specific string or regex

Parameters:
  • regexp (str) – The string or regex to search for
  • fnames (str, list of string, or open file objects) – Paths to grep through
Returns:

Lines matching regexp

Return type:

str

filter_namespaces(ns_list, ns_pattern=None, ns_max=None)[source]

Filter a list of namespaces by regex pattern or max number of namespaces (options originally present in the networking plugin.)

fmt_container_cmd(container, cmd, quotecmd=False)[source]

Format a command to be executed by the loaded ContainerRuntime in a specified container

Parameters:
  • container (str) – The name of the container to execute the cmd in
  • cmd (str) – The command to run within the container
  • quotecmd (bool) – Whether the cmd should be quoted.
Returns:

The command to execute so that the specified cmd will run within the container and not on the host

Return type:

str

generate_copyspec_tags()[source]

After file collections have completed, retroactively generate manifest entries to apply tags to files copied by generic copyspecs

get_all_containers_by_regex(regex, get_all=False)[source]

Get a list of all container names and ID matching a regex

Parameters:
  • regex (str) – The regular expression to match
  • get_all (bool) – Return all containers found, even terminated ones
Returns:

All container IDs and names matching regex

Return type:

list of tuples as (id, name)

get_all_options()[source]

return a list of all options selected

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

Get the path where this plugin will save command output

Parameters:
  • name (str or None) – Optionally specify a filename to use as part of the command output path
  • make (bool) – Attempt to create the command output path
Returns:

The path where the plugin will write command output data within the archive

Return type:

str

get_container_by_name(name)[source]

Get the container ID for a specific container

Parameters:name (str) – The name of the container
Returns:The ID of the container if it exists
Return type:str or None
get_container_images(runtime=None)[source]

Return a list of all image names from the Policy’s ContainerRuntime

If runtime is not provided, use the Policy default. If the specified runtime is not loaded, return empty.

Parameters:runtime (str) – The container runtime to use, if not using the default runtime detected by the Policy
Returns:A list of container images known to the runtime
Return type:list
get_container_logs(container, **kwargs)[source]

Helper to get the logs output for a given container

Supports passthru of add_cmd_output() options

Parameters:
  • container (str) – The name of the container to retrieve logs from
  • kwargs – Any kwargs supported by add_cmd_output() are supported here
get_container_volumes(runtime=None)[source]

Return a list of all volume names from the Policy’s ContainerRuntime

If runtime is not provided, use the Policy default. If the specified runtime is not loaded, return empty.

Parameters:runtime (str) – The container runtime to use, if not using the default runtime detected by the Policy
Returns:A list of container volumes known to the runtime
Return type:list
get_containers(runtime=None, get_all=False)[source]

Return a list of all container IDs from the Policy ContainerRuntime

If runtime is not provided, use the Policy default

Parameters:
  • runtime (str) – The container runtime to use, if not the default runtime detected and loaded by the Policy
  • get_all (bool) – Return all containers known to the runtime, even those that have terminated
Returns:

All container IDs found by the ContainerRuntime

Return type:

list

get_description()[source]

This function will return the description for the plugin

get_option(optionname, default=0)[source]

Retrieve the value of the requested option, searching in order: parameters passed from the command line, set via set_option(), or the global_plugin_options dict.

optionname may be iterable, in which case this function will return the first match.

Parameters:
  • optionname (str) – The name of the option to retrieve the value of
  • default – Optionally provide a default value to return if no option matching optionname is found. Default 0
Returns:

The value of optionname if found, else default

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

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

get_predicate(cmd=False, pred=None)[source]

Get the current default Plugin or command predicate.

Parameters:
  • cmd (bool) – If a command predicate is set, should it be used.
  • pred (SoSPredicate) – An optional predicate to pass if no command or plugin predicate is set
Returns:

pred if neither a command predicate or plugin predicate is set. The command predicate if one is set and cmd is True, else the plugin default predicate (which may be None).

Return type:

SoSPredicate or None

get_process_pids(process)[source]

Get a list of all PIDs that match a specified name

Parameters:process (str) – The name of the process the get PIDs for
Returns:A list of PIDs
Return type:list
get_service_names(regex)[source]

Get all service names matching regex

Parameters:regex (str) – A regex to match service names against
Returns:All service name(s) matching the given regex
Return type:list
get_service_status(name)[source]

Return the reported status for service $name

Parameters:name (str) – The name of the service to check
Returns:The state of the service according to the init system
Return type:str
get_tags_for_cmd(cmd)[source]

Get the tag(s) that should be associated with the given command

Parameters:cmd (str) – The command that tags should be applied to
Returns:Any tags associated with the command
Return type:list
get_tags_for_file(fname)[source]

Get the tags that should be associated with a file matching a given regex

Parameters:fname (str) – A regex for filenames to be matched against
Returns:The tag(s) associated with fname
Return type:list of strings
is_installed(package_name)[source]

Is the package $package_name installed?

Parameters:package_name (str) – The name of the package to check
Returns:True id the package is installed, else False
Return type:bool
is_module_loaded(module_name)[source]

Determine whether specified module is loaded or not

Parameters:module_name (str) – Name of kernel module to check for presence
Returns:True if the module is loaded, else False
Return type:bool
is_service(name)[source]

Does the service $name exist on the system?

Parameters:name (str) – The name of the service to check
Returns:True if service is present on the system, else False
Return type:bool
is_service_disabled(name)[source]

Is the service $name disabled?

Parameters:name (str) – The name of the service to check
Returns:True if service is disabled on the system, else False
Return type:bool
is_service_enabled(name)[source]

Is the service $name enabled?

Parameters:name (str) – The name of the service to check
Returns:True if service is enabled on the system, else ``False
Return type:bool
is_service_running(name)[source]

Is the service $name currently running?

Parameters:name (str) – The name of the service to check
Returns:True if the service is running on the system, else False
Return type:bool
join_sysroot(path)[source]

Join a given path with the configured sysroot

Parameters:path (str) – The filesystem path that needs to be joined
Returns:The joined filesystem path
Return type:str
listdir(path)[source]

Helper to call the sos.utilities wrapper that allows the corresponding os call to account for sysroot

Parameters:path (str) – The canonical path for a specific file/directory
Returns:Contents of path, if it is a directory
Return type:list
log_skipped_cmd(pred, cmd, kmods=False, services=False, changes=False)[source]

Log that a command was skipped due to predicate evaluation.

Emit a warning message indicating that a command was skipped due to predicate evaluation. If kmods or services are True then the list of expected kernel modules or services will be included in the log message. If allow_changes is True a message indicating that the missing data can be collected by using the “–allow-system-changes” command line option will be included.

Parameters:
  • pred (SoSPredicate) – The predicate that caused the command to be skipped
  • cmd (str) – The command that was skipped
  • kmods (bool) – Did kernel modules cause the command to be skipped
  • services (bool) – Did services cause the command to be skipped
  • changes (bool) – Is the –allow-system-changes enabled
classmethod name()[source]

Get the name of the plugin

Returns:The name of the plugin, in lowercase
Return type:str
path_exists(path)[source]

Helper to call the sos.utilities wrapper that allows the corresponding os call to account for sysroot

Parameters:path (str) – The canonical path for a specific file/directory
Returns:True if the path exists in sysroot, else False
Return type:bool
path_isdir(path)[source]

Helper to call the sos.utilities wrapper that allows the corresponding os call to account for sysroot

Parameters:path (str) – The canonical path for a specific file/directory
Returns:True if the path is a dir, else False
Return type:bool
path_isfile(path)[source]

Helper to call the sos.utilities wrapper that allows the corresponding os call to account for sysroot

Parameters:path (str) – The canonical path for a specific file/directory
Returns:True if the path is a file, else False
Return type:bool
path_islink(path)[source]

Helper to call the sos.utilities wrapper that allows the corresponding os call to account for sysroot

Parameters:path (str) – The canonical path for a specific file/directory
Returns:True if the path is a link, else False
Return type:bool
postproc()[source]

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

set_cmd_predicate(pred)[source]

Set or clear the default predicate for command collection for this plugin. If set, this predecate takes precedence over the Plugin default predicate for command and journal data collection.

Parameters:pred (SoSPredicate) – The predicate to use as the default command predicate
set_option(optionname, value)[source]

Set the named option to value. Ensure the original type of the option value is preserved

Parameters:
  • optioname (str) – The name of the option to set
  • value – The value to set the option to
Returns:

True if the option is successfully set, else False

Return type:

bool

set_plugin_manifest(manifest)[source]

Pass in a manifest object to the plugin to write to

Parameters:manifest (SoSManifest) – The manifest that the plugin will add metadata to
set_predicate(pred)[source]

Set or clear the default predicate for this plugin.

Parameters:pred (SoSPredicate) – The predicate to use as the default for this plugin
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]

Remove the configured sysroot from a filesystem path

Parameters:path (str) – The filesystem path to strip sysroot from
Returns:The stripped filesystem path
Return type:str
test_predicate(cmd=False, pred=None)[source]

Test the current predicate and return its value.

Parameters:
  • cmdTrue if the predicate is gating a command or False otherwise.
  • pred – An optional predicate to override the current Plugin or command predicate.
Returns:

True or False based on predicate evaluation, or False if no predicate

Return type:

bool

timeout

Returns either the default plugin timeout value, the value as provided on the commandline via -k plugin.timeout=value, or the value of the global –plugin-timeout option.

timeout_from_options(optname, plugoptname, default_timeout)[source]

Returns either the default [plugin|cmd] timeout value, the value as provided on the commandline via -k plugin.[|cmd-]timeout=value, or the value of the global –[plugin|cmd]-timeout option.

tmp_in_sysroot()[source]

Check if sysroot is within the archive’s temp directory

Returns:True if sysroot is in the archive’s temp directory, else False
Return type:bool
use_sysroot()[source]

Determine if the configured sysroot needs to be used

Returns:True if sysroot is not /, else False
Return type:bool
class sos.report.plugins.RedHatPlugin[source]

Bases: object

Tagging class for Red Hat’s Linux distributions

class sos.report.plugins.SCLPlugin[source]

Bases: sos.report.plugins.RedHatPlugin

Superclass for plugins operating on Software Collections (SCLs).

Subclasses of this plugin class can specify class.files and class.packages using “%(scl_name)s” interpolation. The plugin invoking mechanism will try to match these against all found SCLs on the system. SCLs that do match class.files or class.packages are then accessible via self.scls_matched when the plugin is invoked.

Additionally, this plugin class provides “add_cmd_output_scl” (run a command in context of given SCL), and “add_copy_spec_scl” and “add_copy_spec_limit_scl” (copy package from file system of given SCL).

For example, you can implement a plugin that will list all global npm packages in every SCL that contains “npm” package:

class SCLNpmPlugin(Plugin, SCLPlugin):

packages = (“%(scl_name)s-npm”,)

def setup(self):
for scl in self.scls_matched:
self.add_cmd_output_scl(scl, “npm ls -g –json”)
add_cmd_output_scl(scl, cmds, **kwargs)[source]

Same as add_cmd_output, except that it wraps command in “scl enable” call and sets proper PATH.

add_copy_spec_scl(scl, copyspecs)[source]

Same as add_copy_spec, except that it prepends path to SCL root to “copyspecs”.

convert_cmd_scl(scl, cmd)[source]

wrapping command in “scl enable” call and adds proper PATH

class sos.report.plugins.SoSCommand(**kwargs)[source]

Bases: object

A class to represent a command to be collected.

A SoSCommand() object is instantiated for each command handed to an _add_cmd_output() call, so that we no longer need to pass around a very long tuple to handle the parameters.

Any option supported by _add_cmd_output() is passed to the SoSCommand object and converted to an attribute. SoSCommand.__dict__ is then passed to _get_command_output_now() for each command to be collected.

class sos.report.plugins.SoSPredicate(owner, dry_run=False, kmods=[], services=[], packages=[], cmd_outputs=[], arch=[], required={})[source]

Bases: object

A class to implement collection predicates.

A predicate gates the collection of data by an sos plugin. For any add_cmd_output(), add_copy_spec() or add_journal() call, the passed predicate will be evaulated and collection will proceed if the result is True, and not otherwise.

Predicates may be used to control conditional data collection without the need for explicit conditional blocks in plugins.

Parameters:
  • owner (Plugin) – The Plugin object creating the predicate
  • dry_run (bool) – Is sos running in dry_run mode?
  • kmods (list, or str of single name) – Kernel module name(s) to check presence of
  • services (list, or str of single name) – Service name(s) to check if running
  • packages (list, or str of single name) – Package name(s) to check presence of
  • cmd_outputs (list of dict``s, or single ``dict taking form {‘cmd’: <command to run>, ‘output’: <string that output should contain>}) – Command to run, with output string to check
  • arch (list, or str of single architecture) – Architecture(s) that the local system is matched against
  • required (dict, with keys matching parameter names and values being either ‘any’, ‘all’, or ‘none. Default ‘any’.) – For each parameter provided, should the checks require all items, no items, or any items provided
arch = []

Allowed architecture(s) of the system

dry_run = False

Skip all collection?

kmods = []

Kernel module enablement list

packages = []

Package presence list

report_failure()[source]

Used by Plugin() to obtain the error string based on if the reason was a failed check or a forbidden check

services = []

Services enablement list

class sos.report.plugins.SuSEPlugin[source]

Bases: object

Tagging class for SuSE Linux distributions

class sos.report.plugins.UbuntuPlugin[source]

Bases: object

Tagging class for Ubuntu Linux

sos.report.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.report.plugins.regex_findall(regex, fname)[source]

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