Executing builtin check commands on command line or via API

Is it possible to execute the builtin commands on command line or via REST-API?
I’m thinking about the following commands:

  • cluster
  • icinga
  • cluster-zone

As it is today we have them added as normal icinga services but I would like to be able to have them executed “outside” the icinga2 daemon so to speak.

1 Like

Would be interesting to know if possible;

with most check commands you can execute them outside of Icinga, but not sure about the built-in ones for health.

Example for Freshness:
'/usr/lib64/nagios/plugins/check_freshness.py' '-c' '100' '-H' 'db.local' '-d' 'icinga2' '-u' 'icingauser' '-p' 'some_password' '-w' '100' '-wp' '200%' '-cp' '400%'

I used the Director module to inspect the command executed on the check. However when I do the same for a built-in function, it’s just blank. The properties tell me that it’s built-in.

execute	{ arguments: [ "checkable", "cr", "resolvedMacros", "useResolvedMacros" ], deprecated: false, name: "Internal#PluginCheck", side_effect_free: false, type: "Function" }

If the idea is to have it external to Icinga (because if it’s broke, you can’t rely on it right?), then the API probably wouldn’t be useful.

You could check the logs to see what the API sees when the command is executed.

Unfortunately the answer is no. Only option you have is to trigger the next check via API if you need a fresher result using the reschedule-check action.

So an execute-check action which allowing the same would be a valid request but from discussions in the past executing checks somewhere in the cluster without a service definition would possibly allow running arbitrary code and expose a security risk, so an implementation is unlikely or if done has to be done carefully considering security. Only allowing them locally via CLI could be much simpler but is perhaps to limiting depending on the use case.

1 Like