add new zabbix template so we can automatically add new checks
This commit is contained in:
parent
242a6d1cca
commit
bb5ee5085f
4 changed files with 33 additions and 0 deletions
12
roles/ppm/files/ppmzabbixagent
Normal file
12
roles/ppm/files/ppmzabbixagent
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
# Zabbix agent config for ppm
|
||||||
|
|
||||||
|
{%- set ns = namespace() -%}
|
||||||
|
{%- set ns.allchecks = [] -%}
|
||||||
|
{%- for app in otherapps -%}
|
||||||
|
{%- if "monitoring" in otherapps[app]["imports"] -%}
|
||||||
|
{%- for check in otherapps[app]["imports"]["monitoring"]["checks"] %}
|
||||||
|
{%- set ns.allchecks = ns.allchecks + [check | combine({'app':app})] -%}
|
||||||
|
{% endfor -%}{%- endif -%}{%- endfor %}
|
||||||
|
|
||||||
|
UserParameter=ppm.discover,/bin/echo '{{ ns.allchecks | tojson }}'
|
||||||
|
UserParameter=ppm.app[*],/bin/bash -c 'echo $2 | nc -U {{ statedir }}/$1.monitoring'
|
||||||
|
|
@ -1,3 +1,8 @@
|
||||||
- name: Restart firewall
|
- name: Restart firewall
|
||||||
ansible.builtin.command: /etc/network/if-pre-up.d/firewall
|
ansible.builtin.command: /etc/network/if-pre-up.d/firewall
|
||||||
changed_when: true
|
changed_when: true
|
||||||
|
|
||||||
|
- name: Restart zabbix-agent2
|
||||||
|
ansible.builtin.service:
|
||||||
|
name: zabbix-agent2
|
||||||
|
state: restarted
|
||||||
|
|
|
||||||
|
|
@ -11,3 +11,6 @@
|
||||||
|
|
||||||
- name: Arrange firewall
|
- name: Arrange firewall
|
||||||
ansible.builtin.import_tasks: firewall.yml
|
ansible.builtin.import_tasks: firewall.yml
|
||||||
|
|
||||||
|
- name: Arrange zabbix
|
||||||
|
ansible.builtin.import_tasks: zabbix.yml
|
||||||
|
|
|
||||||
13
roles/ppm/tasks/zabbix.yml
Normal file
13
roles/ppm/tasks/zabbix.yml
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
- name: Configure firewall options
|
||||||
|
ansible.builtin.copy:
|
||||||
|
dest: /home/.zabbixagenttemplate
|
||||||
|
group: root
|
||||||
|
owner: root
|
||||||
|
mode: "0755"
|
||||||
|
src: ppmzabbixagent
|
||||||
|
|
||||||
|
- name: Render zabbix template
|
||||||
|
ansible.builtin.command: ppm template /home/.zabbixagenttemplate /etc/zabbix/zabbix_agent2.d/ppm.conf
|
||||||
|
register: zabbix_render
|
||||||
|
changed_when: "'content did not change' not in zabbix_render.stdout"
|
||||||
|
notify: Restart zabbix-agent2
|
||||||
Loading…
Add table
Add a link
Reference in a new issue