Activation of own plugins

Hi there,

I am trying to setup some consistency checks for data warehouses, i.e. compare the contents with the source systems. What I did so far is:

  • created a python script in /share/check_mk/checks
    it provides check_info, check_function, inventory function
  • extended the agent on the warehouse systems to send information, e.g. the name and the port of the data base it uses. Validated with “cmk -d warehouse”
  • extended /etc/check_mk/main.mk so the agent information gets into the inventory of the check
  • added a man page in /share/check_mk/checkman
  • For activation I called “cmk -II” and “cmk -R”

Now I expected the check to be available in WATO -> Hosts -> -> Services
so I can activate it. But unfortunately it is not available.
(If I insert some faulty code in the plugin this page gives me an error message so I know the plugin has been discovered/parsed)

I have been searching the web for hours without finding a proper tutorial or explanation. It seems to work for everyone that the checks just appear in WATO.

Any ideas what I did wrong or what I need to add?

Thanks and cheers,
Nicolas

Just a quick note in general: Please never modify files below ~/share/ directly or put custom files there. That’s not really part of your site but just a symlink to the installed software version:

~/share -> version/share
~/version -> ../../versions/1.6.0p13.cre  # or whichever version your site uses

Instead, use ~/local/share/ so these files won’t be overwritten in an update. Also, you can have Checkmk automatically sync the ~/local hierarchy to your slave sites.

2 Likes

Thanks for the hint. I moved the files.
Any ideas why it is not working?

Does the host to which you want to add the services using the monitoring server side plugins , has any service at the moment ? If yes, then can you check from the hosts services page > WATO > Services : if this particular check exists here after the full scan ?

If it exists, then what is the status of that check ?

Also, can you try running the below command as site user ?

$ cmk --debug -vII --checks

does the output of the above command produces any errors related to Python ?

The above command should tell you the reason if the output from the agent side is being correctly parsed and evaluated from the server side.

Hi Marco,

thanks for the reply!

Yes, the server is visible in WATO with a few standard checks: Check_MK, Check_MK Discovery, CPU Util, Uptime and a few file system checks.
There are a few disabled checks visible (kernel, mount, postfix). But why only so few? Shouldnt there be a very long list similar to the contents of the checks folder in share/check_mk?

The full scan unfortunately does not reveal the new check, tried it several times, also via command line.

The given command says it requires another argument for “checks”. When provdided with the name of the new check it lists all the hosts but no python errors.

I found the source of the problem: the inventory function. If it does not return a name, the service will not get registered.
That on the other hand raised a few other questions. Maybe some examples to clear things up:

def inventory_dwh(info):
inv = {}

for l in info:
    inv.update({l[0] : l[1]})

return [("dwh", inv)]

check_info['dwh'] = {
        "check_function"      : check_dwh,
        "inventory_function"  : inventory_dwh,
        "service_description" : "DWH: %s",
    }

From what I have learned so far is that

  • inventory_dwh only gets information passed in the snippet that starts with “<<>>”
  • if inventory_dwh does not return a string as first part of the tuple the check will not get registered with check_mk
  • The 2nd part of the tuple, the dictionary, gets passed as “params” to the check_dwh function

What I dont understand is

  • How is a check registered that does not have its own part in the host information, i.e. it should not depend on snippets in the host information.
  • How can I use a host information snippet for more than one check? For example I want to provide warehouse information in a snippet “<<>>” and if this information is available not only a check named “dwh” should registert but a series of checks all concerned with consistency for the data warehouse.

Can anyone confirm what I have learned so far and maybe provide some examples on how to solve the problems in the questions? Any help would be greatly appreciated as I already spend a lot of time on this.

Nico

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.