Skip to content
Snippets Groups Projects
Commit 42d5df1e authored by Fynn Becker's avatar Fynn Becker :crab:
Browse files

Ensure monitor_postgrest works for all configs

postgrest-formula allows for configuration of multiple instances on the
same machine. Because multiple instances have distinct configurations,
the local check script can not assume the `admin-server-port` setting to
be present for all instances.
If no instance has the setting specified, the state ensures removal of
the local check script.
parent 23d2642a
No related branches found
No related tags found
No related merge requests found
......@@ -3,8 +3,10 @@
instance_names=()
instance_admin_ports=()
{% for instance_name, instance_conf in instances.items() %}
{% if 'admin-server-port' in instance_conf['config'] %}
instance_names+=("{{ instance_name }}")
instance_admin_ports+=("{{ instance_conf['config']['admin-server-port'] }}")
{% endif %}
{% endfor %}
function check_endpoint() {
......
{% set instances = salt['pillar.get']("postgrest:instances") %}
{% set has_ports_configured = salt['pillar.get']("postgrest:instances").values()|selectattr("config", "defined")|selectattr("config.admin-server-port", "defined") %}
{% set file_path= '/usr/lib/check_mk_agent/local/monitor-postgrest' %}
hsh_checkmk_monitor_postgrest_plugin:
{% if has_ports_configured|list %}
{% set instances = salt['pillar.get']("postgrest:instances") %}
file.managed:
- name: /usr/lib/check_mk_agent/local/monitor-postgrest
- name: {{ file_path }}
- source: salt://checkmk/custom-files/local/monitor-postgrest
- template: jinja
- context:
......@@ -10,3 +13,7 @@ hsh_checkmk_monitor_postgrest_plugin:
- mode: 755
- user: root
- group: root
{% else %}
file.absent:
- name: {{ file_path }}
{% endif %}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment