Disable and enable service using checkmk api

CMK version: 2.3.0p25

Hi Team,

Is there an API method to enable or disable a specific service on a host in Checkmk?
I have checked through the API documentation but found no direct options. A forum mentioned that rules can be created via API, could this be a possible approach? Any suggestions?

Regards,
Benson Thomas

Hi,

You cant list or get rules you have on checkmk through its own REST API, then knowing which rule (ID) you want/need to change you can then modify it (enable/disable) the rule.

You have more detailed info on this on the API documentation @ host:port/site/check_mk/api/doc/#operation/cmk.gui.openapi.endpoints.rule.list_rules

Thanks.

I tested and created a rule for disabling Checkmk service inside the host cmkhost and activated the rule but unfortunately the rule is not reflected inside the GUI. .

{
        "ruleset": "extra_service_conf:active_checks_enabled",
        "folder": "/",     
        "properties": {
          "description": "disable active checks for a service",
          "disabled": false
        },
        "value_raw": "'0'",
        "conditions": {
          "host_name": {
            "match_on": [
              "CMKHOST"
            ],
            "operator": "one_of"
          },
          "host_tags": [],
          "host_label_groups": [],
          "service_label_groups": [],
          "service_description": {
            "match_on": [
              "Check_MK$"
            ],
            "operator": "one_of"
          }
        }
      }

The check is still active.

I think “Disable active checks” is not the right ruleset:

“Setup->Services->Service discovery rules->Disabled services” should be the right one for you needs.

Hi All,

I used the API method to schedule, list, modify, and delete downtime for the host services to fulfill the required purpose.

Thank you,
Benson Thomas

Hello!

If one of the answers helped you solve your question, please mark it as the solution. This way, you thank the person who helped you and also indicate that the question has been resolved. This, in turn, helps others who come across the same question.

Solution

Thank you!

1 Like

Terrible idea. This is your data source. Disabling it will kill your monitoring for that host. Never disable services starting with “Check_MK”.

@robin.gierse It was a just a test utilizing the REST API. The primary objective was to disable monitoring for specific custom application services configured within Checkmk. Later, I used the REST API functionality to schedule downtime for these services.

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.