This exports methods available for use by plugins for sos
Bases: object
Tagging class for Debian Linux
Bases: object
Tagging class that indicates that this plugin is experimental
Bases: object
Tagging class for plugins that can run on any platform
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 an alert to the collection of alerts for this plugin. These will be displayed in the report
Run a program or a list of programs and collect the output
Add a file or glob but limit it to sizelimit megabytes. Collect files with mtime not older than maxage hours. 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.
Append text to the custom text that is included in the report. This is freeform and can include html.
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 an environment variable to the list of to-be-collected env vars.
Accepts either a single variable name or a list of names. Any value given will be added as provided to the method, as well as an upper- and lower- cased version.
Specify a path, or list of paths, to not copy, even if it’s part of a copy_specs[] entry.
Collect journald logs from one of more units.
Parameters: |
|
---|
Collect service status information based on the InitSystem used.
Parameters: | services – A string, or list of strings, specifying the services to collect |
---|
Add a string to the archive as a file named filename
Collect udevadm info output for a given device
Parameters: |
|
---|
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.
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.
Checks if a named process is found in /proc/[0-9]*/cmdline. Returns either True or False.
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.
Collect the data for a plugin.
Execute a command and save the output to a file for inclusion in the report.
This decides whether a plugin should be automatically loaded or only if manually specified in the command line.
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.
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.
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.
param pathregex: | |
---|---|
A string or regex of a filename to match against | |
param desc: | A description of the replaced content |
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.
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.
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().
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.
return a list of all options selected
Return a path into which this module should store collected command output
This function will return the description for the plugin
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.
Will try to return the option as a list separated by the delimiter.
Get the current default Plugin or command predicate. If the cmd argument is True, the current command predicate is returned if set, otherwise the default Plugin predicate will be returned (which may be None).
If no default predicate is set and a pred value is passed it will be returned.
Returns PIDs of all processes with process name. If the process doesn’t exist, returns an empty list
Get all service names matching regex
Return the reported status for service $name
Is the package $package_name installed?
Return whether specified module as module_name is loaded or not
Does the service $name exist on the system?
Is the service $name disabled?
Is the service $name enabled?
Is the service $name currently running?
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.
Returns the plugin’s name as a string. This should return a lowercase string.
Perform any postprocessing. To be replaced by a plugin if required.
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.
Set the named option to value. Ensure the original type of the option value is preserved.
Set or clear the default predicate for this plugin.
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.
Test the current predicate and return its value.
Parameters: |
|
---|
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.
Bases: sos.plugins.RedHatPlugin
Tagging class for IBM PowerKVM Linux
Bases: object
Tagging class for Red Hat’s Linux distributions
Bases: sos.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:
packages = (“%(scl_name)s-npm”,)
Same as add_cmd_output, except that it wraps command in “scl enable” call and sets proper PATH.
Same as add_copy_spec_limit, except that it prepends path to SCL root to “copyspec”.
Same as add_copy_spec, except that it prepends path to SCL root to “copyspecs”.
wrapping command in “scl enable” call and adds proper PATH
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.
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.
Allowed architecture(s) of the system
Skip all collection?
Kernel module enablement list
Package presence list
Used by Plugin() to obtain the error string based on if the reason was a failed check or a forbidden check
Services enablement list
Bases: object
Tagging class for SuSE Linux distributions
Bases: object
Tagging class for Ubuntu Linux
Bases: sos.plugins.RedHatPlugin
Tagging class for IBM ZKVM Linux
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,).
Return a list of all non overlapping matches in the string(s)