Insights Shell

The insights shell is an ipython-based interactive environment for exploring insights components. You can run it against your local system or different kinds of packaged data like insights archives, sosreports, JBoss Diagnostic Reports, must-gather archives, and more. See insights shell -h for details.

class insights.shell.Holder[source]

Bases: dict

This is a dictionary that holds models for multiple archives. Access each model set using the path to the archive as the key. See models.keys().

class insights.shell.Models(broker, models, cwd, tmp, cov)[source]

Bases: dict

Represents all components that may be available given the data being analyzed. Use models.find() to see them. Tab complete attributes to access them. Use help(models) for more info.

Start the shell with the environment variable INSIGHTS_FILTERS_ENABLED=False to disable filtering that may cause unexpected missing data.

Examples

>>> models.find("rpm")
InstalledRpms (insights.parsers.installed_rpms.InstalledRpms)
>>> rpms = models.InstalledRpms
>>> rpms.newest("bash")
0:bash-4.1.2-48.el6
>>> models.find("(?i)yum")  # Prefix "(?i)" ignores case.
YumConf (insights.parsers.yum_conf.YumConf, parser)
YumLog (insights.parsers.yumlog.YumLog, parser)
YumRepoList (insights.parsers.yum.YumRepoList, parser)
└╌╌Incorrect line: 'repolist: 33296'
YumReposD (insights.parsers.yum_repos_d.YumReposD, parser)
>>> models.show_trees("rpm")
insights.parsers.installed_rpms.InstalledRpms (parser)
┊   insights.specs.Specs.installed_rpms (unfiltered / lines)
┊   ┊╌╌╌╌╌TextFileProvider("'/home/csams/Downloads/archives/sosreport-example-20191225000000/sos_commands/rpm/package-data'")
┊   ┊   insights.specs.insights_archive.InsightsArchiveSpecs.installed_rpms (unfiltered / lines)
┊   ┊   ┊   insights.specs.insights_archive.InsightsArchiveSpecs.all_installed_rpms (unfiltered / lines)
┊   ┊   ┊   ┊   insights.core.context.HostArchiveContext ()
┊   ┊   insights.specs.sos_archive.SosSpecs.installed_rpms (unfiltered / lines)
┊   ┊   ┊╌╌╌╌╌TextFileProvider("'/home/csams/Downloads/archives/sosreport-example-20191225000000/sos_commands/rpm/package-data'")
┊   ┊   ┊   insights.core.context.SosArchiveContext ()
┊   ┊   insights.specs.default.DefaultSpecs.installed_rpms (unfiltered / lines)
┊   ┊   ┊   insights.specs.default.DefaultSpecs.docker_installed_rpms (unfiltered / lines)
┊   ┊   ┊   ┊   insights.core.context.DockerImageContext ()
┊   ┊   ┊   insights.specs.default.DefaultSpecs.host_installed_rpms (unfiltered / lines)
┊   ┊   ┊   ┊   insights.core.context.HostContext ()
evaluate(name)[source]

Evaluate a component and return its result. Prints diagnostic information in the case of failure. This function is useful when a component’s name contains characters that aren’t valid for python identifiers so you can’t access it with models.<name>.

Parameters

name (str) -- the name of the component as shown by Models.find().

evaluate_all(match=None, ignore='spec')[source]

Evaluate all components that match.

Parameters
  • match (str, optional) -- regular expression for matching against the fully qualified name of components to keep.

  • ignore (str, optional) -- regular expression for searching against the fully qualified name of components to ignore.

find(match=None, ignore=None)[source]

Find components that might be available based on the data being analyzed.

Parameters
  • match (str, optional) -- regular expression for matching against the fully qualified name of components to keep.

  • ignore (str, optional) -- regular expression for searching against the fully qualified name of components to ignore.

make_rule(path=None, overwrite=False, pick=None)[source]

Attempt to generate a rule based on models used so far.

Parameters
  • path (str) -- path to store the rule.

  • overwrite (bool) -- whether to overwrite an existing file.

  • pick (str) -- Optionally specify which lines or line ranges to use for the rule body. “1 2 3” gets lines 1,2 and 3. “1 3-5 7” gets line 1, lines 3 through 5, and line 7.

reset_requested()[source]

Reset requested state so you can work on a new rule.

show_exceptions(match=None, ignore='spec')[source]

Show exceptions that occurred during evaluation. Ignores “spec” by default.

Parameters
  • match (str, optional) -- regular expression for matching against the fully qualified name of components to keep.

  • ignore (str, optional) -- regular expression for searching against the fully qualified name of components to ignore.

show_failed(match=None, ignore='spec')[source]

Show names of any components that failed during evaluation. Ignores “spec” by default.

Parameters
  • match (str, optional) -- regular expression for matching against the fully qualified name of components to keep.

  • ignore (str, optional) -- regular expression for searching against the fully qualified name of components to ignore.

show_requested()[source]

Show the components you’ve worked with so far.

show_rule_report(match=None, ignore=None)[source]

Print a rule report for the matching rules.

show_source(comp)[source]

Show source for the given module, class, or function. Also accepts the string names, with the side effect that the component will be imported.

show_timings(match=None, ignore='spec', group=0)[source]

Show timings for components that have successfully evaluated.

Parameters
  • match (str, optional) -- regular expression for matching against the fully qualified name of components to keep.

  • ignore (str, optional) -- regular expression for searching against the fully qualified name of components to ignore.

show_trees(match=None, ignore='spec', depth=None, toward_dependents=False)[source]

Show dependency trees of any components whether they’re available or not.

Parameters
  • match (str, optional) -- regular expression for matching against the fully qualified name of components to keep.

  • ignore (str, optional) -- regular expression for searching against the fully qualified name of components to ignore.

  • depth (int, optional) -- how deep into the tree to explore.

  • toward_dependents (bool, optional) -- whether to walk the tree toward dependents. Default is to walk toward dependencies.