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

Improvements #42

Closed m3rlinux closed 3 years ago

m3rlinux commented 3 years ago

Resolve #40

HenriWahl commented 3 years ago

Hi, thanks for contributing.

I tested but i am not sure if it works as expected. I just replaced the agent yum file on a CentOS7 host which instead of the former

<<<yum>>>
no
0

gives this output, which leads to UNKNOWN:

<<<yum>>>
/var/cache/yum/:
total 0
drwxr-xr-x. 3 root root 14 Nov  4  2015 x86_64

/var/cache/yum/x86_64:
total 4
drwxr-xr-x. 14 root root 4096 Jul  6 03:45 7

/var/cache/yum/x86_64/7:
total 36
drwxr-xr-x. 4 root root   31 May 18  2016 base

....
m3rlinux commented 3 years ago

Could you try to remove cache files and run the script again?

rm -f /var/lib/check_mkagent/cache/yum*

EDIT: The problem is due the fact that you store yum information instead of check results in yum_state.cache file Unfortunately if there isn't updates the script don't update this file so you have to delete it manually.

HenriWahl commented 3 years ago

Could you try to remove cache files and run the script again?

rm -f /var/lib/check_mkagent/cache/yum*

This works, yes.

EDIT: The problem is due the fact that you store yum information instead of check results in yum_state.cache file Unfortunately if there isn't updates the script don't update this file so you have to delete it manually.

Well, this information was used as a kind of hash to find if there was anything new available. So if there where new updates there was no need to do anything.

HenriWahl commented 3 years ago

The resulting state is UNKNOWN anyway - do I need to update the server side too?

Edit: I see there is no server side change.

Edit 2: The agent output contains the file listing again:

<<<yum>>>
/var/cache/yum/:
total 0
drwxr-xr-x. 3 root root 14 Nov  4  2015 x86_64

/var/cache/yum/x86_64:
total 4
drwxr-xr-x. 14 root root 4096 Jul  6 03:45 7

/var/cache/yum/x86_64/7:
total 36
drwxr-xr-x. 4 root root   31 May 18  2016 base
drwxr-xr-x. 4 root root 4096 Jul  6 03:45 epel

...
HenriWahl commented 3 years ago

The first attempt works, but the second gives the file listing again.

HenriWahl commented 3 years ago

Maybe it is a good idea to store the results of your improved version in some other files to avoid this mess when upgrading from the old to the new version?

m3rlinux commented 3 years ago

Maybe it is a good idea to store the results of your improved version in some other files to avoid this mess when upgrading from the old to the new version?

Maybe yes! I pushed a new commit with a refactoring of variable and file

HenriWahl commented 3 years ago

Way better:

<<<yum>>>
no
0
0
<<<yum:cached(1625580465,600)>>>
no
0
invalid check cache file
HenriWahl commented 3 years ago

Looks very good at all, no more UNKNOWN states! :+1: