Access host variables in custom agent based plugin

Hello!
I’m writing a custom plugin to monitor a service.
In the agent side, I wrote a plugin with the following example output:

<<<myapp_webservice>>>
appname^51000

Then, in the check_mk server, I want to write the discovery and check functions to work with this data.
For my check function, I need to known the IP address of the host, linke in the $HOSTADDRESS$ macro but within the python script.
So the check will be monitoring the service in the URL:
http://{hostaddress}:51000/appname

Can you tell me how I can know the host IP address from within the python script?

Thanks!

Why not sending the host IP in agent output?

A check plugin for checkmk’s check engine should not have such side effects (like opening a HTTP connection).

You will need to come up with another solution.

Yes, a datasource agent would be the better solution I guess.
If you just want to check HTTP you may use check_http together with Nagios macros.
We put for example the application in host alias and use $HOSTALIAS$ to build the URL.

See:
https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/3/en/macrolist.html

Thanks for your answers!

I’m not sending the host IP because it may be several IP address in the host, and I’m interested in the one that CheckMK server has configured for monitoring that host.

I understand the limitation. I suppose I will be doing a local check then, because I want this to be automated when I deploy the agent, and in check_http service I will still need to manualy enter the port.

Regards

@enzote84 I wonder did you find a way to get HOST configuration details from plugin?

Nope… I ended up doing a local check: http://localhost:51000 in the monitored host.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed. Contact an admin if you think this should be re-opened.