Single active check that generates multiple services

Hello internet,
I would like to have a single active check, that generates multiple “items”.

OMD[live]:~/local/share/check_mk/checks$ /omd/versions/default/lib/nagios/plugins/webcheck.rb http://kervyn.de
0 webcheck-http://kervyn.de response_time=120ms
0 certificate-kervyn.de lifetime=64 Certificate: kervyn.de
0 certificate-kervyn.de-chain-1 lifetime=244 Certificate: Let's Encrypt Authority X3

If I add this script via “Classical active and passive Monitoring checks” I only get one single service on the system that chained the output of that script together.

What do I need to do, to have each entry it’s own item? Because this check reports all certificates a server sends, the list can be between 1 (no ssl) to n (multiple ssl certs including the chains) items.

Your script outputs “local check” output. It is possible to run this script with this output within a normal CMK agent.
What you also see the script uses the complete output in your configuration as only text output without using the status code at the start and the performance data.

This location is a little bit strange for the script file. In the default setup there is no Ruby script there :wink:
All your own classic checks (this is no classic check) should be copied to “~/local/lib/nagios/plugins/”

1 Like

ok.

I want to have this script as an active check from the cmk server to check a website and create multiple items/services within given host. How do I get what I want?

Output, location, how to call it cann all be changed.

An active check (aka Nagios Plugin) can only return the state of one service check.

For your use case you could turn the script into an agent plugin that is started by the agent on the monitoring server and outputs piggyback data so that in the end the local checks are asigned to the correct hosts.

Or you create a special agent (data source program) that generates the data and is configured per host where needed.

2 Likes

The problem with “configure and agent” is the acceptance from other people. I want it as easy as possible for them to just add a hostname or a website and the get back all the data the want.

Data source program is something I tried, but then I got rid of the agent data.

Currently this annoys the shit out of me, like it is hard to turn some data into individual fields.

Why so aggressiv?

Remember your script outputs three different checks with the parameter of one domain.
Do you need really three single checks or would be one check enough with three performance data and also with a combined result instead of three?

If you use the enterprise edition (what i don’t know as you not mentioned your version) it would be possible to deploy scripts as local checks with some parameters and then the local check is done like you want it.

The other options are already shown by @r.sander

Please excuse me. It wasn’t meant to be aggressiv.

We use the checkmk-raw edition (I added the tag).

Of course it would be possible to have everything in a single check and monitor the whole stack at once, but it would be nicer to have it split up. I don’t monitor a whole system as a single item and add errors to the alert if something is not working ¯\_(ツ)_/¯

If theese are all options:

  • Only have it in one service
  • Descide if I want to have the agent data OR this data
  • Create some sort of loop and let the servers agent handle it, so I do not know to which system that belongs

well… I can’t change it so I need to live with that. I just tried something I personally thought would be nice.

Btw, I sensed your frustration, rather than aggression. Sometimes things don’t translate well into other cultures and certainly not when everything is just “text”.

I think what you are wanting is interesting.

In short, people are trying their best to help. But I know that doesn’t necessarily help with the frustration for something that looks like it should be simple (I too get frustrated. I really love CheckMK, and maybe that’s why I get more frustrated when it says “no” to something I want).

There is no this or that - you can have booth agent data and your special agent data for these checks.

It would be good to know from where this script is. As Ruby is not such a command language in the monitoring environment of CMK.
Most times it is really simple to translate such a local check script so something else. But i need to see the source code.

The documentation and my own experience states exaclty that, if data source program is used.

I Frankensteined it on my own. This does nothing special and I don’t know why the code is relevant when I posted the output. But for clarification: simple webcheck script ($1996520) · Snippets · GitLab

This script gives you EVERY certificate the webserver sends. Like this:

➜  webmonitor git:(master) ✗ ./webcheck.rb https://cloud.home.example.com
<<<local>>>
0 webcheck-cloud.home.example.com time=709ms https://cloud.home.example.com
0 certificate-cloud.home.example.com lifetime=47 Certificate: cloud.home.example.com
0 certificate-cloud.home.example.com-chain-1 lifetime=243 Certificate: Let's Encrypt Authority X3
0 certificate-cloud.home.example.com-chain-2 lifetime=47 Certificate: example.tech
0 certificate-cloud.home.example.com-chain-3 lifetime=243 Certificate: Let's Encrypt Authority X3
0 certificate-cloud.home.example.com-chain-4 lifetime=47 Certificate: srv01.home.example.com
0 certificate-cloud.home.example.com-chain-5 lifetime=243 Certificate: Let's Encrypt Authority X3
2 certificate-cloud.home.example.com-chain-6 lifetime=-209 Certificate: wiki.example.com
0 certificate-cloud.home.example.com-chain-7 lifetime=243 Certificate: Let's Encrypt Authority X3
0 certificate-cloud.home.example.com-chain-8 lifetime=47 Certificate: yt.example.tech
0 certificate-cloud.home.example.com-chain-9 lifetime=243 Certificate: Let's Encrypt Authority X3

@andreas-doehler any new insights?

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