[API] How to add Host Problems with API?

Hey, I have a Zabbix instance and would like to import problems from there into Checkmk via API. The data export from Zabbix is ready and the basic authentication has also worked with Checkmk.

I have seen that I can add hosts via API. But how can I display a new problem entry in the CheckMk dashboard? Do I have to create a rule first? What would the specific endpoint be called?

Thank you very much!

Hi @jlknvl

welcome to the forum!

That is an odd question…

I’m not going to question why you want to use Zabbix and Checkmk in parallel. You probably have your reasons…

If I understand you correctly, you are trying to use Checkmk a bit like Grafana, as a dashboarding tool that displays information from other systems. Here’s how I understood your setup and what you would like to achieve:

  1. You are monitoring a host in Zabbix
  2. If a host has a problem, this will show up in Zabbix first.
  3. You then take the information that this host has a problem (I don’t know what Zabbix calls this - a state? notification? alert?) and put it into some kind of structured data export (JSON, …)
  4. You want Checkmk to import this information and “display a new problem entry in the CheckMk dashboard”

First of all: There is not “THE Checkmk dashboard”, there are many. Let’s assume you mean the “Host and Service Problems” dashboard.

For a problem to show up there, the host in question first would need to exist in Checkmk. So in a first step the host in question would need to be created in Checkmk. As you rightly pointed out, that can be done by the Rest API. So in theory, you could create a sort of mirror image of the entire infrastructure you are monitoring in Zabbix in Checkmk. That would work.

But now about importing a host problem - that’s where you lost me…

The whole purpose of Checkmk is to detect if a host has a problem. Setting a host state through the API would lead this function ‘ad absurdum’. That would be kind of like taking a Sharpie and writing Pulse: 68 on a heart rate monitor when in reality the patient is flatlining. This is also why there is no API endpoint for this, because this is the whole purpose of a tool like Checkmk to find that out.

Or am I completely misunderstanding what you are trying to do?

1 Like

You could use the Event Console to process alert messages generated by Zabbix.

Or you could create passive checks in Checkmk and set their state from the data that Zabbix provides.

2 Likes

Thank you very much for your quick reply. Let’s assume I want to push events to the Event Console. I have a Python script that pulls the data from Zabbix, how can I generate new Event Console entries in Checkmk using Python? I have seen that there are probably UDP port and SNMP for this. Is it correct that there is no REST-API endpoint?
Thank you

You can write the lines of text directly into the pipe at $OMD_ROOT/tmp/run/mkeventd/events.

2 Likes