CmdLine - file /proc/cmdline
This parser reads the /proc/cmdline
file, which contains the arguments
given to the currently running kernel on boot.
- class insights.parsers.cmdline.CmdLine(context)[source]
Bases:
LegacyItemAccess
,Parser
A parser class for parsing the Linux kernel command line as given in
/proc/cmdline
.Parsing Logic:
Parses all elements in command line to a dict where the key is the element itself and the value is a list stores its corresponding values. If an element doesn't contain "=", set the corresponding value to `True`. If an element contains "=", set the corresponding value to the whole right value of the "=".
Note
For special command line elements that include two “=”, e.g.
root=LABEL=/1
, “root” will be the key and “LABEL=/1” will be the value in the returned list.Some parameters (the returned keys) might be still effective even if there is ‘#’ before it, e.g.:
#rhgb
. This should be checked by the rule.Sample input:
BOOT_IMAGE=/vmlinuz-3.10.0-327.36.3.el7.x86_64 root=/dev/system_vg/Root ro rd.lvm.lv=system_vg/Root crashkernel=auto rd.lvm.lv=system_vg/Swap rhgb quiet LANG=en_GB.utf8
Examples
>>> cmd['BOOT_IMAGE'] ['/vmlinuz-3.10.0-327.36.3.el7.x86_64'] >>> cmd['rd.lvm.lv'] ['system_vg/Root', 'system_vg/Swap'] >>> 'autofs' in cmd False >>> cmd.get('autofs') is None True >>> 'quiet' in cmd True >>> cmd.get('quiet') [True] >>> cmd['crashkernel'] ['auto']
- data
Parsed booting arguments are stored in this dictionary
- Type:
dict
- cmdline
The RAW line of the
/proc/cmdline
- Type:
str