Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 35 additions & 7 deletions zabbix/files/default/etc/zabbix/zabbix_agentd.conf.jinja
Original file line number Diff line number Diff line change
@@ -1,4 +1,32 @@
{% from "zabbix/map.jinja" import zabbix with context -%}
{# Consider a value, keep a string, join a list, or join a dict's sorted keys -#}
{% macro flexjoin(srcval, sep=' ') -%}
{# If it's a simple value, emit it. -#}
{% if srcval is string or srcval is number -%}
{{ srcval -}}
{# If it's a dict, take the keys (for pillar merging), sort them (for stability), flexjoin them. -#}
{% elif srcval is mapping -%}
{{ flexjoin( srcval.keys()|sort, sep) -}}
{# If it's a list, join it. -#}
{% else -%}
{{ srcval|join(sep) -}}
{% endif -%}
{% endmacro -%}

{# Consider a value, iterate callback over a list or a dict's sorted keys. -#}
{% macro flexcall(srcval) -%}
{# If srcval is a dict, take the keys (for pillar mergin), sort them (for stability), iterate. -#}
{% if srcval is mapping -%}
{% for val in srcval.keys()|sort -%}
{{ caller(val) -}}
{% endfor -%}
{# If it's just a list, call back for each item in the list. -#}
{% elif srcval is iterable and srcval is not string -%}
{% for val in srcval -%}
{{ caller(val) -}}
{% endfor -%}
{% endif -%}
{% endmacro -%}
{% set settings = salt['pillar.get']('zabbix-agent', {}) -%}
# Managed by saltstack
# do not edit this file.
Expand Down Expand Up @@ -80,7 +108,7 @@
# Incoming connections will be accepted only from the hosts listed here.
# If IPv6 support is enabled then '127.0.0.1', '::127.0.0.1', '::ffff:127.0.0.1' are treated equally.
#
Server={{ settings.get('server', ['localhost'])|join(',') }}
Server={{ flexjoin(settings.get('server', ['localhost']), ',') }}

### Option: ListenPort
# Agent will listen on this port for connections from the server.
Expand All @@ -91,7 +119,7 @@ Server={{ settings.get('server', ['localhost'])|join(',') }}
# List of comma delimited IP addresses that the agent should listen on.
# First IP address is sent to Zabbix server if connecting to it to retrieve list of active checks.
#
{% if settings.get('listenip', false) %}ListenIP={{ settings.get('listenip') }}{% endif %}
{% if settings.get('listenip', false) %}ListenIP={{ flexjoin(settings.get('listenip'), ',') }}{% endif %}

### Option: StartAgents
# Number of pre-forked instances of zabbix_agentd that process passive checks.
Expand All @@ -109,7 +137,7 @@ Server={{ settings.get('server', ['localhost'])|join(',') }}
# If this parameter is not specified, active checks are disabled.
# Example: ServerActive=127.0.0.1:20051,zabbix.domain,[::1]:30051,::1,[12fc::1]
#
{% if settings.get('serveractive', false) %}ServerActive={{ settings.get('serveractive')|join(',') }}{% endif %}
{% if settings.get('serveractive', false) %}ServerActive={{ flexjoin(settings.get('serveractive'), ',') }}{% endif %}

### Option: Hostname
# Unique, case sensitive hostname.
Expand Down Expand Up @@ -225,9 +253,9 @@ Hostname={{ settings.get('hostname', salt['grains.get']('id')) }}
# Format: UserParameter=<key>,<shell command>
# See 'zabbix_agentd' directory for examples.
#
{% for userparameter in settings.get('userparameters', []) -%}
{% call(userparameter) flexcall(settings.get('userparameters', [])) -%}
UserParameter={{ userparameter }}
{% endfor -%}
{% endcall -%}

####### LOADABLE MODULES #######
{% if zabbix.version_repo >= '2.4' -%}
Expand All @@ -244,9 +272,9 @@ UserParameter={{ userparameter }}
# The modules must be located in directory specified by LoadModulePath.
# It is allowed to include multiple LoadModule parameters.
#
{% for loadmodule in settings.get('loadmodules', []) -%}
{% call(loadmodule) flexcall(settings.get('loadmodules', [])) -%}
LoadModule={{ loadmodule }}
{% endfor -%}
{% endcall -%}

{% if zabbix.version_repo >= '3.0' -%}
####### TLS-RELATED PARAMETERS #######
Expand Down