HeinleinSupport / check_mk_extensions

check_mk Plugins
https://www.heinlein-consulting.de/
GNU General Public License v2.0
235 stars 108 forks source link

Error when updating CRE version with apcaccess plugin #83

Closed dnlldl closed 3 years ago

dnlldl commented 3 years ago

Every update since I installed the apcaccess plugin (just did 2.0.0p3 to 2.0.0p4), I get this error:

OMD[test]:~$ cmk-update-config -v
Initializing application...
Loading GUI plugins...
Updating Checkmk configuration...
ATTENTION: Some steps may take a long time depending on your installation, e.g. during major upgrades.
 1/15 Migrate deprecated network topology dashlet...
 2/15 Update global settings...
 3/15 Rewriting WATO tags...
 4/15 Rewriting WATO hosts and folders...
 5/15 Rewriting WATO rulesets...
Replacing ruleset non_inline_snmp_hosts with snmp_backend_hosts
 6/15 Rewriting autochecks...
Transform failed: host='server', plugin='apcaccess', ruleset='apcaccess', params={'model': 'apcupsd.conf'}, error=AssertionError('non-empty params vanished')
 7/15 Cleanup version specific caches...
 8/15 Migrating fs_used name...
 9/15 Migrate pagetype topics...
 10/15 Migrate LDAP connections...
 11/15 Rewrite BI Configuration...
Skipping conversion of bi.mk (already done)
 12/15 Set version specific user attributes...
 13/15 Rewriting inventory data...
Skipping py2 inventory data update (already done)
 14/15 Migrate audit log...
No audit log present. Skipping.
 15/15 Rename discovered host label files...
Done
dnlldl commented 3 years ago

Some more insights.

...
Loading autochecks from /omd/sites/home/var/check_mk/autochecks/server.mk
Transform failed: host='server', plugin='apcaccess', ruleset='apcaccess', params={'model': 'apcupsd.conf'}, error=AssertionError('non-empty params vanished')
Try aquire lock on /omd/sites/home/var/check_mk/autochecks/server.mk
Got lock on /omd/sites/home/var/check_mk/autochecks/server.mk
Releasing lock on /omd/sites/home/var/check_mk/autochecks/server.mk
Released lock on /omd/sites/home/var/check_mk/autochecks/server.mk
...

And /omd/sites/home/var/check_mk/autochecks/server.mk:

OMD[home]:~$ grep apcaccess /omd/sites/home/var/check_mk/autochecks/server.mk
  {'check_plugin_name': 'apcaccess', 'item': 'CP1500PFCLCD', 'parameters': {'model': 'apcupsd.conf'}, 'service_labels': {}},

And just to be sure I removed the service (which removed it from server.mk) and rediscovered it, issue is still here, there is something wrong in the parameters that isn't properly handled after the latest commit on this plugin.

dnlldl commented 3 years ago

Problem is still present with 2.0.0p5

gurubert commented 3 years ago

Are you using the latest apcaccessd MKP from https://github.com/HeinleinSupport/check_mk_extensions/tree/cmk2.0/apcaccess ?

dnlldl commented 3 years ago

Are you using the latest apcaccessd MKP from https://github.com/HeinleinSupport/check_mk_extensions/tree/cmk2.0/apcaccess ?

You made me doubt so I reinstalled it and yes, I was using last. It's even worst by default however, I have to delete a file to prevent another error because I am using the CRE version.

OMD[home]:~$ wget https://github.com/HeinleinSupport/check_mk_extensions/raw/cmk2.0/apcaccess/apcaccess-4.3.mkp
...
OMD[home]:~$ mkp install apcaccess-4.3.mkp

OMD[home]:~$ cmk-update-config -v
Initializing application...
Loading GUI plugins...
Failed to load plugin /omd/sites/home/local/share/check_mk/web/plugins/wato/apcaccess_cee.py: No module named 'cmk.gui.cee'
Traceback (most recent call last):
  File "/omd/sites/home/lib/python3/cmk/gui/utils/__init__.py", line 172, in load_web_plugins
    exec(f.read(), globalvars)
  File "<string>", line 22, in <module>
ModuleNotFoundError: No module named 'cmk.gui.cee'

ERROR: Failed to load some GUI plugins. You will either have
       to remove or update them to be compatible with this
       Checkmk version.

Updating Checkmk configuration...
ATTENTION: Some steps may take a long time depending on your installation, e.g. during major upgrades.
 1/15 Migrate deprecated network topology dashlet...
 2/15 Update global settings...
 3/15 Rewriting WATO tags...
 4/15 Rewriting WATO hosts and folders...
 5/15 Rewriting WATO rulesets...
Replacing ruleset non_inline_snmp_hosts with snmp_backend_hosts
 6/15 Rewriting autochecks...
Transform failed: host='server', plugin='apcaccess', ruleset='apcaccess', params={'model': 'apcupsd.conf'}, error=AssertionError('non-empty params vanished')
 7/15 Cleanup version specific caches...
 8/15 Migrating fs_used name...
 9/15 Migrate pagetype topics...
 10/15 Migrate LDAP connections...
 11/15 Rewrite BI Configuration...
Skipping conversion of bi.mk (already done)
 12/15 Set version specific user attributes...
 13/15 Rewriting inventory data...
Skipping py2 inventory data update (already done)
 14/15 Migrate audit log...
No audit log present. Skipping.
 15/15 Rename discovered host label files...
Done
gurubert commented 3 years ago

This is an issue in cmk-update-config which will be fixed soon: https://checkmk.com/werk/12894

If this does not fix it please contact the checkmk developers.

dnlldl commented 3 years ago

This is an issue in cmk-update-config which will be fixed soon: https://checkmk.com/werk/12894

If this does not fix it please contact the checkmk developers.

I already applied this fix (which fixed the error from the werk, that's a different error than the one I'm getting now). You're right that it's probably a problem with Checkmk and not the plugin itself. However, the second error I feel like is really about the plugin.

Transform failed: host='server', plugin='apcaccess', ruleset='apcaccess', params={'model': 'apcupsd.conf'}, error=AssertionError('non-empty params vanished')
gurubert commented 3 years ago

The developers of checkmk just confirmed that this is another issue in cmk-update-config and not the apcaccess extension.

I will keep you informed about updates.

gurubert commented 3 years ago

This cannot be fixed currently, but you can just ignore the error message from cmk-update-config.

dnlldl commented 3 years ago

The error is slightly different under 2.0.0p9, hinting even more towards a problem with the actual plugin. Do you have a link/source about the developers confirmation it's an issue with cmk-update-config?

OMD[home]:~$ cmk-update-config
Failed to load plugin /omd/sites/home/local/share/check_mk/web/plugins/wato/apcaccess_cee.py: No module named 'cmk.gui.cee'
Traceback (most recent call last):
  File "/omd/sites/home/lib/python3/cmk/gui/utils/__init__.py", line 172, in load_web_plugins
    exec(f.read(), globalvars)
  File "<string>", line 22, in <module>
ModuleNotFoundError: No module named 'cmk.gui.cee'

ERROR: Failed to load some GUI plugins. You will either have
       to remove or update them to be compatible with this
       Checkmk version.

Transform failed: host='server', plugin='apcaccess', ruleset='apcaccess', params={'model': 'apcupsd.conf'}, error=AssertionError('non-empty params vanished')
Skipping conversion of bi.mk (already done)
dnlldl commented 3 years ago

Deleting /omd/sites/<site>/local/share/check_mk/web/plugins/wato/apcaccess_cee.py entirely fixes the issue. Is the CEE file necessary? I'm running CRE.

gurubert commented 3 years ago

If running CRE you can delete the CEE file. It's for the agent bakery. Unfortunately there is currently no method to distinguish the editions in a better way.

dnlldl commented 3 years ago

I noticed another issue, if the agent is executed directly from the client (/usr/bin/check_mk_agent) the plugin loops and run indefinitely (eventually crashing the server).

root@client:~# /usr/bin/check_mk_agent
<<<apcaccess:sep(58)>>>
[[apcupsd.conf]]
<<<apcaccess:sep(58)>>>
[[apcupsd.conf]]
<<<apcaccess:sep(58)>>>
[[apcupsd.conf]]
<<<apcaccess:sep(58)>>>
[[apcupsd.conf]]
<<<apcaccess:sep(58)>>>
[[apcupsd.conf]]
<<<apcaccess:sep(58)>>>
[[apcupsd.conf]]
<<<apcaccess:sep(58)>>>
[[apcupsd.conf]]
<<<apcaccess:sep(58)>>>
[[apcupsd.conf]]
<<<apcaccess:sep(58)>>>
[[apcupsd.conf]]
<<<apcaccess:sep(58)>>>
[[apcupsd.conf]]
<<<apcaccess:sep(58)>>>
[[apcupsd.conf]]
<<<apcaccess:sep(58)>>>
[[apcupsd.conf]]
<<<apcaccess:sep(58)>>>
[[apcupsd.conf]]
<<<apcaccess:sep(58)>>>
[[apcupsd.conf]]
<<<apcaccess:sep(58)>>>
[[apcupsd.conf]]
<<<apcaccess:sep(58)>>>
[[apcupsd.conf]]
<<<apcaccess:sep(58)>>>
[[apcupsd.conf]]
<<<apcaccess:sep(58)>>>
[[apcupsd.conf]]
<<<apcaccess:sep(58)>>>
[[apcupsd.conf]]
<<<apcaccess:sep(58)>>>
[[apcupsd.conf]]
...

Haven't investigated yet, this doesn't happen when executed by the checkmk server.

gurubert commented 3 years ago

Please have a look at the agent plugin. There is no loop around echo "<<<apcaccess:sep(58)>>>". This is not caused by the plugin.

dnlldl commented 3 years ago

It's a weird issue, I agree it's not caused by the plugin code. This issue can be closed. I suggest adding something to the README about people running CRE having to delete that one apcaccess_cee.py file. I am unsure how the other plugins do it, since they don't have that issue, but either way, from my POV it's solved.

dnlldl commented 2 years ago

Checkmk issued a fix in 2.0.0p5 (right after p4) : https://checkmk.com/werk/12894