schoekek / lgb_check_mk_plugins

LGB Check_MK plugin repository.
43 stars 17 forks source link

Problem with SSLLabs Plugin in Checkmk 2.2.0 #20

Open toxicvengeance opened 1 year ago

toxicvengeance commented 1 year ago

Hi,

there seems to be an issue with the ssllabs api check Plugin(downloaded from https://exchange.checkmk.com/p/ssllabs) in Checkmk 2.2.0. When I activate the plugin the following error message appears

Some GUI extensions could not be loaded. This may be caused by some incompatible extension packages.

Loading "wato/ssllabs_check_pameters" failed: name 'RegExp' is not defined

I then tried adding the check to a specific host and got the following error

[agent] Success, [special_ssllabs] TypeError: unsupported operand type(s) for +: 'PosixPath' and 'str'CRIT, [piggyback] Success (but no data found for this host), execution time 1.3 sec

Do you have an idea what could be wrong ?

Cheers

moschlar commented 1 year ago

As a workaround:

In web/plugins/wato/ssllabs_check_pameters.py add:

from cmk.gui.i18n import _
from cmk.gui.valuespec import (
    Dictionary,
    Tuple,
    Age,
    RegExpUnicode,
    RegExp,
    TextAscii,
)
from cmk.gui.wato import (
    subgroup_applications,
)
from cmk.gui.plugins.wato.utils import (
    register_check_parameters,
)

before the actual code.

And in special/agent_ssllabs change the definition of cache_dir:

cache_dir = os.environ.get("OMD_ROOT") + "/tmp/check_mk" + "/agents/agent_ssllabs"

If @schoekek would bring the plugin version in this repo up-to-date (#17), I would provide my changes as a PR. :wink:

christmart commented 1 year ago

You also need some more code in ssllabs_datasource_programs.py:

from cmk.gui.i18n import _
from cmk.gui.valuespec import (
    Dictionary,
    Integer,
    TextAscii,
    Transform,
)
from cmk.gui.watolib.rulespecs import (
    register_rule,
)

before the actual code.

schoekek commented 1 year ago

i plan to upload a new mkp version to exchange..

christmart commented 10 months ago

There is a new version 3.1.1 on exchange which has the fixes for ssllabs_check_pameters.py and agent_ssllabs but it misses the fixes to ssllabs_datasource_programs.py

schoekek commented 10 months ago

3.1.1 runs error-free on my installation.

christmart commented 10 months ago

It only runs error-free if you have mkp packages installed which get called before your plugin and already define these imports. Try to load ssllabs mkp with no other mkps installed.

dnlldl commented 8 months ago

Doesn't work anymore on 2.3.0b4-cre.


Error running automation call restart (exit code 5), error:
Error in plugin file /omd/sites/<site>/local/share/check_mk/checks/ssllabs_grade: name 'factory_settings' is not defined
Error precompiling checks for host <hostname>: Cannot find check file needed for agent_ssllabs```
schoekek commented 7 months ago

We won't switch to 2.3 until QIII/2024. Unfortunately there is no new mkp before then.

dnlldl commented 6 months ago

We won't switch to 2.3 until QIII/2024. Unfortunately there is no new mkp before then.

Any update on this?

philrandal commented 5 months ago

@christmart is right about the additional lines needed in ssllabs_datasource_programs.py.

@dnlldl The 2.3.0 error is a mystery. I get it too. I'll try to get to the bottom of it in the next week or so.

I'm not familiar enough with the checkmk plugin api to be able to do this one quickly, alas.

philrandal commented 5 months ago

OK, if we install into 2.1.0 it works as expected, and if we then upgrade that site to 2.2.0 it still works.

However, when I create a test site in 2.2.0 the mkp installs but we are missing the "Check SSL Server via ssllabs API" other integrations ruleset.

Looks like the whole thing needs updating to the 2.0 API as a first step.

dnlldl commented 5 months ago

OK, if we install into 2.1.0 it works as expected, and if we then upgrade that site to 2.2.0 it still works.

However, when I create a test site in 2.2.0 the mkp installs but we are missing the "Check SSL Server via ssllabs API" other integrations ruleset.

Looks like the whole thing needs updating to the 2.0 API as a first step.

This doesn't work on 2.3 either but you might want to check https://thl-cmk.hopto.org/gitlab/checkmk/various/agent_ssllabs

philrandal commented 5 months ago

Sorry to hijack this issue, but I got the latter working in 2.3 by making the following change to local/lib/python3/cmk/special_agents/agent_ssllabs.py

from cmk.special_agents.utils.agent_common import special_agent_main

from cmk.special_agents.v0_unstable.agent_common import special_agent_main

from cmk.special_agents.utils.argument_parsing import create_default_argument_parser

from cmk.special_agents.v0_unstable.argument_parsing import create_default_argument_parser

Cloned it to github and created a cmk23 branch which has a working mkp for cmk 2.2.0 and 2.3.0

https://github.com/philrandal/agent_ssllabs/tree/cmk23

dnlldl commented 5 months ago

Sorry to hijack this issue, but I got the latter working in 2.3 by making the following change to local/lib/python3/cmk/special_agents/agent_ssllabs.py

from cmk.special_agents.utils.agent_common import special_agent_main from cmk.special_agents.v0_unstable.agent_common import special_agent_main

from cmk.special_agents.utils.argument_parsing import create_default_argument_parser from cmk.special_agents.v0_unstable.argument_parsing import create_default_argument_parser

Cloned it to github and created a cmk23 branch which has a working mkp for cmk 2.2.0 and 2.3.0

https://github.com/philrandal/agent_ssllabs/tree/cmk23

I assume using the "v0_unstable" libraries won't work forever though? There must be something new that needs to be done to make it properly working.

Yogibaer75 commented 5 months ago

I assume using the "v0_unstable" libraries won't work forever though? There must be something new that needs to be done to make it properly working.

At the moment these are the correct imports. This API is not fixed for a version 1 release. I think with 2.4 next year this will be then v1.