How to read a value from global settings?

Does anyone have an idea how I can access values set in the global CMK config (Setup ➜ General ➜ Global settings) from the command line?

Background:
I’m trying to make a local check for the CMK host that checks the number of stale services, so I can graph them. It would help me play around with my CRE max_concurrent_checks value in combination with normal check interval for service checks.

I already found a good way to get the number of stale services via LiveStatus:

GET services\nStats: staleness >= 1.5\nFilter: host_state = 0\nFilter: scheduled_downtime_depth = 0\nFilter: host_scheduled_downtime_depth = 0

However, the number for staleness should be the same as set in the global configuration key staleness threshold. It has a factory default of 1.5 but might be changed, so for my check to show the same as the sidebar, it should be identical.
My idea was to read out the value from the config. I just don’t know how (or if it’s even possible).

1 Like

I don’t know of some real API call but you said it’s a local check that runs on the checkmk server itself.

So it might want to parse the file ~/etc/check_mk/multisite.d/wato/global.mk. The file is in python syntax, so you can even “load” it with some ast.literal_eval(f.read()) call.

Most (all?) of the global settings can be found in this file. If not, maybe check the other global.mk files (see find ~/etc -name global.mk).

But the staleness_threshold is definitley configured in ~/etc/check_mk/multisite.d/wato/global.mk. I know that because we set it ourself there via Ansible.

2 Likes

Thanks, very helpful!

For future reference:
The line (e.g. staleness_threshold = 2.5) will only be present in that file if the setting has been changed from its factory default of 1.5.
This means it’s not enough to retrieve the value from the file and call it a day - you have to assume a value of 1.5 if you can’t find the key in the file.

2 Likes