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

Check does not detect a date for the last update (check only for upgrades) - dont find updates when use spacewalk #52

Closed GasCan1234 closed 1 year ago

GasCan1234 commented 1 year ago

Hi,

we have a machine, there the check does not recognize the last date of the update run.

The check checks for "U" and "Upgrade" but from my point of view it should also check for "Update". Because if he makes only updates in the last runs, there is not U or Upgrade recorded, see the listing from the server.

[root@XXX ~]# /usr/bin/yum -C --quiet history | awk '{if(NR>2)print}'
   444 | XXX | 2022-09-29 07:01 | Erase          |    1
   443 | XXX | 2022-09-28 10:00 | Update         |    2 ##
   442 | XXX | 2022-09-27 10:44 | Update         |    1 ##
   441 | XXX | 2022-09-27 10:00 | Update         |    1 ##
   440 | XXX | 2022-09-26 10:00 | Update         |    1 ##
   439 | XXX | 2022-09-23 10:00 | Update         |    1 ##
   438 | XXX | 2022-09-22 10:00 | Update         |    1 ##
   437 | XXX | 2022-09-21 10:00 | Update         |   15 ##
   436 | XXX | 2022-09-20 10:00 | Update         |    1 ##
   435 | XXX | 2022-09-19 10:00 | Update         |    1 ##
   434 | XXX | 2022-09-16 10:00 | Update         |    1 ##
   433 | XXX | 2022-09-15 10:00 | Update         |    1 ##
   432 | XXX | 2022-09-14 10:00 | Update         |    1 ##
   431 | XXX | 2022-09-13 10:00 | Update         |    1 ##
   430 | XXX | 2022-09-12 10:00 | Update         |    1 ##
   429 | XXX | 2022-09-09 10:00 | Update         |    1 ##
   428 | XXX | 2022-09-08 10:00 | Update         |    1 ##
   427 | XXX | 2022-09-07 10:00 | Update         |    1 ##
   426 | XXX | 2022-09-06 10:00 | Update         |    1 ##
   425 | XXX | 2022-09-06 06:33 | Update         |    1
[root@XXX ~]# /usr/bin/yum -C --quiet history | awk '{if(NR>2)print}' | grep  ' U \|Upgrade' | cut -d '|' -f3  | head -n 1 | date -f - +"%s" || echo "-1"
[root@XXX ~]# /usr/bin/yum -C --quiet history | awk '{if(NR>2)print}' | grep  ' U \|Upgrade\|Update' | cut -d '|' -f3  | head -n 1 | date -f - +"%s" || echo "-1"
1664352000

https://github.com/HenriWahl/checkmk-agent-plugin-yum/blob/416c1243326b6758829fec0dcda4c228c0d465e6/agents/plugins/yum#L111

I have now changed the line to:

LAST_UPDATE_TIMESTAMP=$(/usr/bin/yum -C --quiet --noplugins history | awk '{if(NR>2)print}' | grep ' U \|Upgrade\|Update' | cut -d '|' -f3 | head -n 1 | date -f - +"%s" || echo "-1")

Maybe you would like to take over this as well.

Another problem we still had and I also overwrote with us is that the check is only executed with "--noplugins". If you use Spacewalk like we do and maintain your own repositories, the check doesn't find any packages or not all that should be updated. Is there a reason to check this way?

Thank you

HenriWahl commented 1 year ago

Thanks - could you please create a pull request to ease getting your fixes into upstream?

b-aktas commented 1 year ago

Instead of @GasCan1234 I created an pull request. It would be nice if you could fix it upstream and release an updated version on https://exchange.checkmk.com.

HenriWahl commented 1 year ago

Uploaded v2.4.1 to https://exchange.checkmk.com.