summaryrefslogtreecommitdiff
path: root/roles
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2021-07-27 22:19:18 +0200
committerChristian Pointner <equinox@spreadspace.org>2021-07-27 22:19:18 +0200
commita7f837c47621f01723feb96f5fd0d54a13376a01 (patch)
tree67b468c68392e4774922a17364f5365881f95ce4 /roles
parentadd prometheus to ele-router (diff)
add nut aka UPS to prometheus monitoring
Diffstat (limited to 'roles')
-rw-r--r--roles/monitoring/prometheus/exporter/blackbox/tasks/main.yml2
-rw-r--r--roles/monitoring/prometheus/exporter/meta/main.yml2
-rw-r--r--roles/monitoring/prometheus/exporter/node/tasks/main.yml2
-rw-r--r--roles/monitoring/prometheus/exporter/nut/handlers/main.yml11
-rw-r--r--roles/monitoring/prometheus/exporter/nut/tasks/main.yml28
-rw-r--r--roles/monitoring/prometheus/exporter/nut/templates/service.j230
6 files changed, 73 insertions, 2 deletions
diff --git a/roles/monitoring/prometheus/exporter/blackbox/tasks/main.yml b/roles/monitoring/prometheus/exporter/blackbox/tasks/main.yml
index 3b8e997d..7ecd8113 100644
--- a/roles/monitoring/prometheus/exporter/blackbox/tasks/main.yml
+++ b/roles/monitoring/prometheus/exporter/blackbox/tasks/main.yml
@@ -21,7 +21,7 @@
dest: /etc/systemd/system/prometheus-blackbox-exporter.service
notify: restart prometheus-blackbox-exporter
-- name: make sure prometheus-exporter-exporter is enabled and started
+- name: make sure prometheus-blackbox-exporter is enabled and started
systemd:
name: prometheus-blackbox-exporter.service
daemon_reload: yes
diff --git a/roles/monitoring/prometheus/exporter/meta/main.yml b/roles/monitoring/prometheus/exporter/meta/main.yml
index d1d3eac7..01e3f7f2 100644
--- a/roles/monitoring/prometheus/exporter/meta/main.yml
+++ b/roles/monitoring/prometheus/exporter/meta/main.yml
@@ -5,3 +5,5 @@ dependencies:
when: "'node' in (prometheus_exporters_default | union(prometheus_exporters_extra))"
- role: monitoring/prometheus/exporter/blackbox
when: "'blackbox' in (prometheus_exporters_default | union(prometheus_exporters_extra))"
+ - role: monitoring/prometheus/exporter/nut
+ when: "'nut' in (prometheus_exporters_default | union(prometheus_exporters_extra))"
diff --git a/roles/monitoring/prometheus/exporter/node/tasks/main.yml b/roles/monitoring/prometheus/exporter/node/tasks/main.yml
index c8756acf..8392e580 100644
--- a/roles/monitoring/prometheus/exporter/node/tasks/main.yml
+++ b/roles/monitoring/prometheus/exporter/node/tasks/main.yml
@@ -15,7 +15,7 @@
dest: /etc/systemd/system/prometheus-node-exporter.service
notify: restart prometheus-node-exporter
-- name: make sure prometheus-exporter-exporter is enabled and started
+- name: make sure prometheus-node-exporter is enabled and started
systemd:
name: prometheus-node-exporter.service
daemon_reload: yes
diff --git a/roles/monitoring/prometheus/exporter/nut/handlers/main.yml b/roles/monitoring/prometheus/exporter/nut/handlers/main.yml
new file mode 100644
index 00000000..6e10f43b
--- /dev/null
+++ b/roles/monitoring/prometheus/exporter/nut/handlers/main.yml
@@ -0,0 +1,11 @@
+---
+- name: restart prometheus-nut-exporter
+ service:
+ name: prometheus-nut-exporter
+ state: restarted
+
+- name: reload prometheus-exporter-exporter
+ service:
+ name: prometheus-exporter-exporter
+ ## TODO: implement reload once exporter_exporter supports this...
+ state: restarted
diff --git a/roles/monitoring/prometheus/exporter/nut/tasks/main.yml b/roles/monitoring/prometheus/exporter/nut/tasks/main.yml
new file mode 100644
index 00000000..519ac7a0
--- /dev/null
+++ b/roles/monitoring/prometheus/exporter/nut/tasks/main.yml
@@ -0,0 +1,28 @@
+---
+- name: install apt packages
+ apt:
+ name: prom-exporter-nut
+ state: present
+
+- name: generate systemd service unit
+ template:
+ src: service.j2
+ dest: /etc/systemd/system/prometheus-nut-exporter.service
+ notify: restart prometheus-nut-exporter
+
+- name: make sure prometheus-nut-exporter is enabled and started
+ systemd:
+ name: prometheus-nut-exporter.service
+ daemon_reload: yes
+ state: started
+ enabled: yes
+
+- name: register exporter
+ copy:
+ content: |
+ method: http
+ http:
+ port: 9199
+ path: /ups_metrics
+ dest: /etc/prometheus/exporter/enabled/nut.yml
+ notify: reload prometheus-exporter-exporter
diff --git a/roles/monitoring/prometheus/exporter/nut/templates/service.j2 b/roles/monitoring/prometheus/exporter/nut/templates/service.j2
new file mode 100644
index 00000000..ffafcb3c
--- /dev/null
+++ b/roles/monitoring/prometheus/exporter/nut/templates/service.j2
@@ -0,0 +1,30 @@
+[Unit]
+Description=Prometheus nut exporter
+
+[Service]
+Restart=always
+User=prometheus-exporter
+ExecStart=/usr/bin/prometheus-nut-exporter --web.listen-address="127.0.0.1:9199"
+
+# systemd hardening-options
+AmbientCapabilities=
+CapabilityBoundingSet=
+DeviceAllow=/dev/null rw
+DevicePolicy=strict
+LockPersonality=true
+MemoryDenyWriteExecute=true
+NoNewPrivileges=true
+PrivateDevices=true
+PrivateTmp=true
+ProtectControlGroups=true
+ProtectHome=true
+ProtectKernelModules=true
+ProtectKernelTunables=true
+ProtectSystem=strict
+RemoveIPC=true
+RestrictNamespaces=true
+RestrictRealtime=true
+SystemCallArchitectures=native
+
+[Install]
+WantedBy=multi-user.target