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

Flapping UNKN - Item not found in agent output #40

Closed m3rlinux closed 3 years ago

m3rlinux commented 3 years ago

Hi, I am experimenting a strange behaviour: the output of the plugin is often empty image

I'm on version 1.6.0p24 of cmk server and 1.6.0p17 of agent. The agent is installed in CentOs 7.8

Could you put me in a right way for debugging this issue? Thanks

HenriWahl commented 3 years ago

Maybe it takes some time for the local yum to retrieve all repository information? Does it happen on different hosts? What happens if you run yum locally on that host?

m3rlinux commented 3 years ago

Hi! I found some problems with the script:

  1. https://github.com/HenriWahl/checkmk-agent-plugin-yum/blob/2ee2eb6660970a36141b01be1f788d5175427dae/agents/plugins/yum#L60-L65 you compare two different variables: $YUM_CURRENT which contains a list of cache yum files with $YUM_CACHED which contains a previous plugin run result This test is always True so the if statement is always being executed
  2. https://github.com/HenriWahl/checkmk-agent-plugin-yum/blob/2ee2eb6660970a36141b01be1f788d5175427dae/agents/plugins/yum#L25-L34 you are searching for a wrong cached file name (see line 25 in which you grep for a yum.cache (file name) and line 34 in which you create yum_check.cache (file name)
  3. https://github.com/HenriWahl/checkmk-agent-plugin-yum/blob/2ee2eb6660970a36141b01be1f788d5175427dae/agents/plugins/yum#L62 you search for new updates only if no others yum instances is running. Maybe it would be better to wait some time and/or manage this exception.
  4. https://github.com/HenriWahl/checkmk-agent-plugin-yum/blob/2ee2eb6660970a36141b01be1f788d5175427dae/agents/plugins/yum#L27 there isn't nothing in your code which could create a file with ".new" suffix; so this line is quite useless
  5. https://github.com/HenriWahl/checkmk-agent-plugin-yum/blob/2ee2eb6660970a36141b01be1f788d5175427dae/agents/plugins/yum#L91-L94 Maybe in these lines you should use yum_check.cache file name instead of yum_state.cache to store cached yum files

Last but not least probably defining these two variable at the beginning of the script could be usefull: YUM_CHECK_CACHE=$MK_VARDIR/cache/yum_check.cache YUM_STATE_CACHE=$MK_VARDIR/cache/yum_state.cache

I have done a global revision of the script which you can find in a PULL REQUEST that I will send you after this comment

I hope you appreciate my contribution ;)