YumLog - file /var/log/yum.log
¶
This module provides parsing for the /var/log/yum.log
file.
-
class
insights.parsers.yumlog.
Entry
(idx, timestamp, state, pkg)¶ Bases:
tuple
namedtuple: Represents a package line in
/var/log/yum.log
.-
idx
¶
-
pkg
¶
-
state
¶
-
timestamp
¶
-
-
insights.parsers.yumlog.
VALID_STATES
= ['Erased:', 'Installed:', 'Updated:']¶ Package states in this file
-
class
insights.parsers.yumlog.
YumLog
(context)[source]¶ Bases:
insights.core.Parser
,list
Class for parsing file
/var/log/yum.log
into a list of .The file looks like:
May 13 15:54:49 Installed: libevent-2.0.21-4.el7.x86_64 May 13 15:54:49 Installed: tmux-1.8-4.el7.x86_64 May 23 18:06:24 Installed: wget-1.14-10.el7_0.1.x86_64 May 23 18:10:05 Updated: 1:openssl-libs-1.0.1e-51.el7_2.5.x86_64 May 23 18:10:05 Installed: 1:perl-parent-0.225-244.el7.noarch May 23 18:10:05 Installed: perl-HTTP-Tiny-0.033-3.el7.noarch May 23 16:09:09 Erased: redhat-access-insights-batch May 23 18:10:05 Installed: perl-podlators-2.5.1-3.el7.noarch May 23 18:10:05 Installed: perl-Pod-Perldoc-3.20-4.el7.noarch May 23 18:10:05 Installed: 1:perl-Pod-Escapes-1.04-286.el7.noarch May 23 18:10:06 Installed: perl-Text-ParseWords-3.29-4.el7.noarch
The information is stored as a
list
ofEntry
objects, each of which contains attributes for the position in the log, timestamp of the action, the package’s state in the system, and the affected package as aninsights.parsers.installed_rpms.InstalledRpm
.Note
The file will be filtered at least with the keywords defined in the
STATES
, that means only the lines that contain one of these keywords will be collected.Examples
>>> type(yl) <class 'insights.parsers.yumlog.YumLog'> >>> e = yl.present_packages.get('nss-softokn') >>> e.pkg.release == '19.el6_6' True >>> e = yl.present_packages.get('openssl-libs') >>> e.pkg.name == 'openssl-libs' True >>> e.pkg.version == '1.0.1e' True >>> len(yl) 8 >>> sorted(e.idx for e in yl) == sorted(range(len(yl))) True
-
ERASED
= 'Erased'¶ Deprecated since version 3.2.0.
Will be removed from 3.4.0. Use string “Erased” instead.
-
INSTALLED
= 'Installed'¶ Deprecated since version 3.2.0.
Will be removed from 3.4.0. Use string “Installed” instead.
-
UPDATED
= 'Updated'¶ Deprecated since version 3.2.0.
Will be removed from 3.4.0. Use string “Updated” instead.
-
data
¶ Deprecated since version 3.2.0.
Will be removed from 3.4.0.
-
packages_of
(state)[source]¶ Parameters: state -- one state or list of states of Installed, Updated, and Erased. Returns: list of latest Entry
instances for packages in state.Raises: KeyError
-- when getting invalid state.
-
parse_content
(content)[source]¶ Parses contents of each line in
/var/log/yum.log
.Each line in the file contains 5 fields that are parsed into the attributes of
Entry
instances:- month
- day
- time
- state
- package
The month, day, and time form the
Entry.timestamp
.Entry.state
contains the state of the package, one ofErased
,Installed
, orUpdated
.Entry.pkg
contains theinsights.parsers.installed_rpms.InstalledRpm
instance corresponding to the parse package.Entry.idx
is the zero-based line number (but not the RAW line number) of theEntry
in the file. It can ONLY be used to tell ordering of events.Parameters: content (list) -- Lines of
/var/log/yum.log
to be parsed.Raises: ParseException
-- if a line can’t be parsed for any reason.SkipComponent
-- if nothing is parsed.
-
pkgs
¶ Deprecated since version 3.2.0.
Will be removed from 3.4.0.
-
present_packages
¶ list of latest
Entry
instances for installed packages.
-