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:
tuplenamedtuple: 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:
Parser,listClass for parsing file
/var/log/yum.loginto 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
listofEntryobjects, 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
- packages_of(state)[source]
- Parameters:
state -- one state or list of states of Installed, Updated, and Erased.
- Returns:
list of latest
Entryinstances 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
Entryinstances:month
day
time
state
package
The month, day, and time form the
Entry.timestamp.Entry.statecontains the state of the package, one ofErased,Installed, orUpdated.Entry.pkgcontains theinsights.parsers.installed_rpms.InstalledRpminstance corresponding to the parse package.Entry.idxis the zero-based line number (but not the RAW line number) of theEntryin the file. It can ONLY be used to tell ordering of events.- Parameters:
content (list) -- Lines of
/var/log/yum.logto be parsed.- Raises:
ParseException -- if a line can’t be parsed for any reason.
SkipComponent -- if nothing is parsed.
- property present_packages
list of latest
Entryinstances for installed packages.