Run python scripts checks

Hi All,

I have developed a script that is similar to this Nagios checks: https://exchange.nagios.org/directory/Plugins/Websites,-Forms-and-Transactions/check_json--2D-check-JSON-attributes-via-http(s)/details

Would it be possible to execute it in the same way we would run legacy nagios checks? via [Classical active and passive Monitoring checks]

it seems there it tries to run Perl files?

Thanks,
Lucas

You can run all scripts you like as classical active and passive monitoring checks. It’s just important that the script has the output checkmk need. See also https://checkmk.com/cms_localchecks.html

2 Likes

Thanks!

I managed to get it working providing the full path of python before the script.

I followed the documentation and in my python script I output

0 myservice count1=42|count2=21;23;27|count3=73 This is my custom output

I created a Classical active and passive Monitoring checks then on checkmk service description it doesn’t detect all the metrics and classify both the metrics and custom output as performance data?

When I check the service overview page I see under the attributes

Output of check plugin 0 check_json count1=42
Service Metrics Count2: 21.0
Service performance data (source code) count2=21;23;27|count3=73 This is my custom output

Is the issue related to how I execute the script? instead of the local agent I use the Classical active and passive Monitoring check?

Thanks,
Lucas

Are you running CRE version or CEE? If you use CEE is the microcore or nagios core active?

I guess there were a situation the nagios core expect the output in a differnt manner. Additional the checkbox for metrics need to be checked at the rule for classical active and passive monitoring checks.

Your output is no Classical active and passive Monitoring checks.
This is a normal Local check. It should be put inside the folder “/usr/lib/check_mk_agent/local” on the host it should run on.
The link from @tosch was not the right one for classical active and passive monitoring checks it was for the local checks.
Inside the link you find also the information where these scripts should be placed.

Sorry for the confusion.

Thank you for the replies,

I managed to get it working, my mistake is that I was mixing two concepts, local checks and Nagios classical checks.

I changed my output format to Nagios
https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/3/en/perfdata.html

PING ok - Packet loss = 0%, RTA = 0.80 ms | percent_packet_loss=0, rta=0.80

[TEXT] | [Perform Data1], [Perform Data2], [Perform Data3]

and it is now working.

My actual use-case is:

I would like to check the Json response of an http get request call, and I would like to create services with parameters that define the url, the json path and critical and warning values.

I have create a small python script that takes all these parameters and returns, now, the Nagio output format. Is that the way to go?

Thanks,
Lucas

If your check should create other services depending on the json output, it should contain a inventory function. Check out the manual at https://checkmk.de/cms_legacy_devel_agentbased.html
It explains how to write such checks.
Regards,
Simon