Christian Boltz 52a91e
common_monitoring_packages:
Christian Boltz 52a91e
  pkg.installed:
Christian Boltz 52a91e
    - pkgs:
Christian Boltz 52a91e
      - check_mk-agent
Christian Boltz 52a91e
      - monitoring-plugins-common
Christian Boltz 52a91e
      - nrpe
Christian Boltz 52a91e
Christian Boltz 785676
{% for dir in ['/etc/nrpe.d', '/etc/monitoring-plugins'] %}
Christian Boltz bba3f0
{{ dir }}:
Christian Boltz bba3f0
  file.directory:
Christian Boltz bba3f0
    - user: root
Christian Boltz bba3f0
    - group: root
Christian Boltz bba3f0
    - mode: 755
Christian Boltz bba3f0
{% endfor %}
Christian Boltz bba3f0
Christian Boltz d020e3
{% set checks = salt['pillar.get']('profile:monitoring:checks', {}) %}
Christian Boltz bba3f0
{% for check, cmd in checks.items() %}
Christian Boltz bba3f0
/etc/nrpe.d/{{ check }}.cfg:
Christian Boltz bba3f0
  file.managed:
Christian Boltz bba3f0
    - contents:
Christian Boltz bba3f0
      - "command[{{ check }}]={{ cmd }}"
Christian Boltz bba3f0
    - user: root
Christian Boltz bba3f0
    - group: root
Christian Boltz bba3f0
    - mode: 444
Christian Boltz bba3f0
{% endfor %}
Christian Boltz bba3f0
Christian Boltz 785676
/etc/monitoring-plugins/check_zypper-ignores.txt:
Christian Boltz bba3f0
  file.managed:
Christian Boltz bba3f0
    - source: salt://profile/monitoring/files/check_zypper-ignores.txt
Christian Boltz bba3f0
    - template: jinja
Christian Boltz bba3f0
    - user: root
Christian Boltz bba3f0
    - group: root
Christian Boltz bba3f0
    - mode: 444
Christian Boltz 637d77
Christian Boltz dbc8b9
/etc/nrpe.cfg:
Christian Boltz dbc8b9
  file.managed:
Christian Boltz dbc8b9
    - source: salt://profile/monitoring/files/nrpe.cfg
Christian Boltz dbc8b9
    - user: root
Christian Boltz dbc8b9
    - group: root
Christian Boltz dbc8b9
    - mode: 444
Christian Boltz dbc8b9
Christian Boltz d2a3b3
# cleanup old xinetd config for nrpe (pre-Leap 15.5)
a5ae7c
{%- set restart_xinetd_for_nrpe = False %}
a5ae7c
{%- for file in ['nrpe', 'nrpe.rpmnew', 'nrpe.rpmsave'] %}
a5ae7c
{%- if salt['file.file_exists'](file) %}
Christian Boltz d2a3b3
/etc/xinetd.d/{{ file }}:
Christian Boltz d2a3b3
  file.absent
a5ae7c
{%- if file == 'nrpe' %}
a5ae7c
{%- set restart_xinetd_for_nrpe = True %}
a5ae7c
{%- endif %}
a5ae7c
{%- endif %}
a5ae7c
{%- endfor %}
Christian Boltz d2a3b3
Christian Boltz d2a3b3
/etc/xinetd.d/check_mk:
Christian Boltz 637d77
  file.managed:
Christian Boltz 637d77
    - contents:
Christian Boltz d2a3b3
    - source: salt://profile/monitoring/files/xinetd-check_mk
Christian Boltz 637d77
    - user: root
Christian Boltz 637d77
    - group: root
Christian Boltz 637d77
    - mode: 444
Christian Boltz 637d77
Christian Boltz 637d77
xinetd:
Christian Boltz 637d77
  pkg.installed: []
Christian Boltz 637d77
  service.running:
Christian Boltz 637d77
    - enable: True
a5ae7c
    - watch:
a5ae7c
    {%- if restart_xinetd_for_nrpe %}
a5ae7c
      - file: /etc/xinetd.d/nrpe
a5ae7c
    {%- endif %}
a5ae7c
      - file: /etc/xinetd.d/check_mk
a5ae7c
a5ae7c
nrpe.service:
a5ae7c
  service.running:
a5ae7c
    - enable: True
a5ae7c
    - watch:
a5ae7c
      - file: /etc/nrpe.cfg