ChkConfig - command chkconfig
¶
- class insights.parsers.chkconfig.ChkConfig(*args, **kwargs)[source]¶
Bases:
CommandParser
A parser for working with data gathered from chkconfig utility.
Sample input data is shown as content in the examples below.
- Raises:
SkipComponent -- When nothing is parsed.
Examples
>>> content = ''' ... auditd 0:off 1:off 2:on 3:on 4:on 5:on 6:off ... crond 0:off 1:off 2:on 3:on 4:on 5:on 6:off ... iptables 0:off 1:off 2:on 3:on 4:on 5:on 6:off ... kdump 0:off 1:off 2:off 3:on 4:on 5:on 6:off ... restorecond 0:off 1:off 2:off 3:off 4:off 5:off 6:off ... xinetd: 0:off 1:off 2:on 3:on 4:on 5:on 6:off ... rexec: off ... rlogin: off ... rsh: off ... telnet: on ... ''' >>> shared[ChkConfig].is_on('crond') True >>> shared[ChkConfig].is_on('httpd') False >>> shared[ChkConfig].is_on('rexec') False >>> shared[ChkConfig].is_on('telnet') True >>> shared[ChkConfig].parsed_lines['crond'] 'crond 0:off 1:off 2:on 3:on 4:on 5:on 6:off' >>> shared[ChkConfig].parsed_lines['telnet'] ' telnet: on' >>> shared[ChkConfig].levels_on('crond') set(['3', '2', '5', '4']) >>> shared[ChkConfig].levels_off('crond') set(['1', '0', '6']) >>> shared[ChkConfig].levels_on('telnet') set([]) >>> shared[ChkConfig].levels_off('telnet') set([])
- class LevelState(level, state)¶
Bases:
tuple
namedtuple: Represents the state of a particular service level.
- property level¶
- property state¶
- is_on(service_name)[source]¶
Checks if the service is enabled in chkconfig.
- Parameters:
service_name (str) -- service name
- Returns:
True if service is enabled, False otherwise
- Return type:
bool
- level_states¶
Dictionary of set of level numbers access by service name.
- Type:
dict
- levels_off(service_name)[source]¶
set (str): Returns set of levels where service_name is off.
- Raises:
KeyError -- Raises exception if service_name is not in Chkconfig.
- levels_on(service_name)[source]¶
set (str): Returns set of level numbers where service_name is on.
- Raises:
KeyError -- Raises exception if service_name is not in Chkconfig.
- parse_content(content)[source]¶
Main parsing class method which stores all interesting data from the content.
- Parameters:
content (context.content) -- Parser context content
- parsed_lines¶
Dictionary of content lines access by service name.
- Type:
dict
- service_list¶
List of service names in order of appearance.
- Type:
list
- services¶
Dictionary of bool indicating if service is enabled, access by service name .
- Type:
dict