HenriWahl / checkmk-agent-plugin-yum

Checks for updates on RPM-based distributions via yum.
GNU General Public License v2.0
23 stars 22 forks source link

Multiple issues on RHEL 8 #50

Closed sven-borkert closed 1 year ago

sven-borkert commented 1 year ago

Hi,

I tried to get this plugin working on RHEL 8.6 but encountered multiple little problems in the agent plugin. I was able to fix the issues and would like to create a patch later, putting my findings here first:

I'm working on RHEL 8.6 x86_64, tested with the agent plugin from yum-2.3.2.mkp.

  1. Searching for a process containing "python /usr/bin/yum" is not safe to determine if yum/dnf is running.

Depening on whether I call "yum update", "/usr/bin/yum update", "dnf update" or "/usr/bin/dnf update" I can see the following processes:

It should be more reliable to check like this:

while [ -n "$(pgrep -f "python (/usr|)/bin/(yum|dnf)")" ]; do

  1. Checking for an uptime < 120s to determine if a reboot has occurred is unreliable in case you execute the check less than every minute, or the CheckMK server has an unexpected downtime. It is safer to remember the last seen uptime and check if the current uptime is lower.

  2. Running "list updates" with all plugins disabled is not working for me:

    [root@xxx ~]# /usr/bin/yum -C --noplugins --quiet list updates
    Error: Cache-only enabled but no cache for 'rhel-8-appstream-rhui-rpms'

There is cached data in /var/cache/dnf/, but with --noplugins it says it cannot find any. Running "dnf makecache" does not change this. Keeping the plugins enabled it works like expected:

[root@xxx ~]# /usr/bin/yum -C --quiet list updates
Available Upgrades
NetworkManager.x86_64                                      1:1.36.0-7.el8_6                                                      rhel-8-baseos-rhui-rpms
...

I'm not fully sure why it needs the plugins enabled to find the cached data. Maybe someone else knows. What was the reason to disable all plugins?

I removed the --noplugins in my version of the agent plugin.

  1. I found multiple RHEL 8 servers here that have both directories: /var/cache/yum and /var/cache/dnf, even on recently installed systems (When I install RHEL 8.6 myself in a VM it only has the dnf directory). I'm not sure why we have the /var/cache/yum directory, as it's always empty, but this disturbs the listing of cache contents the agent plugin performs, as it lists only the empty yum directory when it's there. So I did the following modification to list them always both:
-YUM_CURRENT="$(ls -lR /var/cache/yum/ || ls -lR /var/cache/dnf/)"
+YUM_CURRENT="$(ls -lR /var/cache/{yum,dnf}/)"

Regards, Sven

HenriWahl commented 1 year ago

Fixed with https://github.com/HenriWahl/checkmk-agent-plugin-yum/pull/51