From b32859ecc8d27237ff709d2d4c04610ca87d7d9f Mon Sep 17 00:00:00 2001 From: Alexandre Iooss <erdnaxe@crans.org> Date: Tue, 14 May 2019 09:10:48 +0200 Subject: [PATCH] [prometheus] Monitor UPS --- monitoring.yml | 2 +- roles/prometheus/tasks/main.yml | 10 +++++----- .../prometheus/templates/prometheus/prometheus.yml.j2 | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/monitoring.yml b/monitoring.yml index 759e121d..7431fd7f 100644 --- a/monitoring.yml +++ b/monitoring.yml @@ -27,7 +27,7 @@ job: prometheus targets: - localhost:9090 - prometheus_snmp_targets: + prometheus_ups_snmp_targets: - targets: - pulsar.adm.crans.org # Debian non-free mirror diff --git a/roles/prometheus/tasks/main.yml b/roles/prometheus/tasks/main.yml index 12151282..41d909cd 100644 --- a/roles/prometheus/tasks/main.yml +++ b/roles/prometheus/tasks/main.yml @@ -23,13 +23,13 @@ notify: Restart Prometheus # Doesn't work on Debian Stretch -- name: Make Prometheus snmp-exporter listen on adm only +- name: Make Prometheus snmp-exporter listen on localhost only when: - ansible_lsb.codename == 'buster' lineinfile: path: /etc/default/prometheus-snmp-exporter regexp: '^ARGS=' - line: "ARGS=\"--web.listen-address={{ ansible_fqdn }}:9116\"" + line: "ARGS=\"--web.listen-address=127.0.0.1:9116\"" notify: Restart prometheus-snmp-exporter # We don't need to restart Prometheus when updating nodes @@ -39,10 +39,10 @@ dest: /etc/prometheus/targets.json # We don't need to restart Prometheus when updating nodes -- name: Configure Prometheus SNMP devices +- name: Configure Prometheus UPS SNMP devices copy: - content: "{{ prometheus_snmp_targets | to_nice_json }}" - dest: /etc/prometheus/targets_snmp.json + content: "{{ prometheus_ups_snmp_targets | to_nice_json }}" + dest: /etc/prometheus/targets_ups_snmp.json - name: Activate prometheus service systemd: diff --git a/roles/prometheus/templates/prometheus/prometheus.yml.j2 b/roles/prometheus/templates/prometheus/prometheus.yml.j2 index 05711426..0992ee53 100644 --- a/roles/prometheus/templates/prometheus/prometheus.yml.j2 +++ b/roles/prometheus/templates/prometheus/prometheus.yml.j2 @@ -29,13 +29,13 @@ scrape_configs: file_sd_configs: - files: - '/etc/prometheus/targets.json' - - job_name: snmp + - job_name: ups_snmp file_sd_configs: - files: - - '/etc/prometheus/targets_snmp.json' + - '/etc/prometheus/targets_ups_snmp.json' metrics_path: /snmp params: - module: [if_mib] + module: [eatonups] relabel_configs: - source_labels: [__address__] target_label: __param_target -- GitLab