PS
This combiner provides information about running processes based on the ps command.
More specifically this consolidates data from
insights.parsers.ps.PsAuxcww,
insights.parsers.ps.PsEoCmd,
insights.parsers.ps.PsEf,
insights.parsers.ps.PsAux,
insights.parsers.ps.PsAuxww and
insights.parsers.ps.PsAlxwww parsers (in that specific order).
Note
The final dataset can vary depending on availability of the parsers for a given
ExecutionContext and added filters. The underlying filterable datasources
for this combiner can be filtered by passing insights.combiners.ps.Ps
to insights.core.filters.add_filter() function along with a filter pattern.
Please see insights.core.filters for more information on filtering.
Examples
>>> sorted(ps_combiner.pids)
[1, 2, 3, 8, 9, 10, 11, 12, 13]
>>> '[kthreadd]' in ps_combiner.commands
True
>>> '[kthreadd]' in ps_combiner
True
>>> ps_combiner[2] == {
... 'PID': 2,
... 'USER': 'root',
... 'UID': 0,
... 'PPID': 0,
... '%CPU': 0.0,
... '%MEM': 0.0,
... 'VSZ': 0.0,
... 'RSS': 0.0,
... 'TTY': '?',
... 'STAT': 'S',
... 'START': '2019',
... 'TIME': '1:04',
... 'COMMAND': '[kthreadd]',
... 'COMMAND_NAME': '[kthreadd]',
... 'ARGS': '',
... 'F': '1',
... 'PRI': 20,
... 'NI': '0',
... 'WCHAN': 'kthrea',
... 'NLWP': '1'
... }
True
- class insights.combiners.ps.Ps(ps_alxwww, ps_auxww, ps_aux, ps_ef, ps_auxcww, ps_eo_cmd)[source]
Bases:
objectPscombiner consolidates data from the parsers ininsights.parsers.psmodule.- property commands
Returns the set of full command strings for each command including optional path and arguments, unless underlying parser contains command names only.
- Returns:
the set with command strings.
- Return type:
set
- property pids
Returns the list of running process IDs (integers).
- Returns:
the PIDs from the PID column.
- Return type:
list
- property processes
Returns the list of dictionaries, where each item in the list represents a process and the keys in each dictionary are the column headers.
- Returns:
the list of running processes.
- Return type:
list
- search(**kwargs)[source]
Search the process list for matching rows based on key-value pairs.
This uses the
insights.parsers.keyword_search()function for searching; see its documentation for usage details. If no search parameters are given, no rows are returned.- Returns:
A list of dictionaries of processes that match the given search criteria.
- Return type:
list
Examples
>>> ps_combiner.search(COMMAND__contains='[rcu_bh]') == [ ... {'PID': 9, 'USER': 'root', 'UID': 0, 'PPID': 2, '%CPU': 0.1, '%MEM': 0.0, ... 'VSZ': 0.0, 'RSS': 0.0, 'TTY': '?', 'STAT': 'S', 'START': '2019', 'TIME': '0:00', ... 'COMMAND': '[rcu_bh]', 'COMMAND_NAME': '[rcu_bh]', 'ARGS': '', 'F': '1', 'PRI': 20, ... 'NI': '0', 'WCHAN': 'rcu_gp', 'NLWP': '1'} ... ] True >>> ps_combiner.search(USER='root', COMMAND='[kthreadd]') == [ ... {'PID': 2, 'USER': 'root', 'UID': 0, 'PPID': 0, '%CPU': 0.0, '%MEM': 0.0, ... 'VSZ': 0.0, 'RSS': 0.0, 'TTY': '?', 'STAT': 'S', 'START': '2019', 'TIME': '1:04', ... 'COMMAND': '[kthreadd]', 'COMMAND_NAME': '[kthreadd]', 'ARGS': '', 'F': '1', 'PRI': 20, ... 'NI': '0', 'WCHAN': 'kthrea', 'NLWP': '1'} ... ] True