summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2021-10-20 23:09:14 +0200
committerChristian Pointner <equinox@spreadspace.org>2021-10-20 23:09:14 +0200
commitcde5169221233788f32d6909688b5861349c952d (patch)
treeec4513cb507e48e4228b115c7c8b4c9b8ae2129e
parentcosmetic fixes (diff)
move prometheus node-exporter text collector scripts to templates
-rw-r--r--roles/monitoring/prometheus/exporter/node/tasks/textfile_collector_generic.yml4
-rw-r--r--[-rwxr-xr-x]roles/monitoring/prometheus/exporter/node/templates/textfile-collector-scripts/apt.j2 (renamed from roles/monitoring/prometheus/exporter/node/files/apt)0
-rw-r--r--[-rwxr-xr-x]roles/monitoring/prometheus/exporter/node/templates/textfile-collector-scripts/deleted-libraries.j2 (renamed from roles/monitoring/prometheus/exporter/node/files/deleted-libraries)4
-rw-r--r--roles/monitoring/prometheus/exporter/node/templates/textfile-collector-scripts/smartmon.j2 (renamed from roles/monitoring/prometheus/exporter/node/files/smartmon)4
4 files changed, 6 insertions, 6 deletions
diff --git a/roles/monitoring/prometheus/exporter/node/tasks/textfile_collector_generic.yml b/roles/monitoring/prometheus/exporter/node/tasks/textfile_collector_generic.yml
index 5c068fe7..e5bf2ce5 100644
--- a/roles/monitoring/prometheus/exporter/node/tasks/textfile_collector_generic.yml
+++ b/roles/monitoring/prometheus/exporter/node/tasks/textfile_collector_generic.yml
@@ -1,7 +1,7 @@
---
- name: install the collector script
- copy:
- src: "{{ textfile_collector_name }}"
+ template:
+ src: "textfile-collector-scripts/{{ textfile_collector_name }}.j2"
dest: "/usr/local/share/prometheus-node-exporter/{{ textfile_collector_name }}"
mode: 0755
diff --git a/roles/monitoring/prometheus/exporter/node/files/apt b/roles/monitoring/prometheus/exporter/node/templates/textfile-collector-scripts/apt.j2
index 015addb0..015addb0 100755..100644
--- a/roles/monitoring/prometheus/exporter/node/files/apt
+++ b/roles/monitoring/prometheus/exporter/node/templates/textfile-collector-scripts/apt.j2
diff --git a/roles/monitoring/prometheus/exporter/node/files/deleted-libraries b/roles/monitoring/prometheus/exporter/node/templates/textfile-collector-scripts/deleted-libraries.j2
index e3e19cbd..aeddc903 100755..100644
--- a/roles/monitoring/prometheus/exporter/node/files/deleted-libraries
+++ b/roles/monitoring/prometheus/exporter/node/templates/textfile-collector-scripts/deleted-libraries.j2
@@ -1,4 +1,4 @@
-#!/usr/bin/env python3
+#!/usr/bin/env {{ python_basename }}
"""
Script to count the number of deleted libraries that are linked by running
processes and expose a summary as Prometheus metrics.
@@ -63,7 +63,7 @@ def main():
dir_path, basename = os.path.split(library)
basename = basename.replace('"', '\\"')
dir_path = dir_path.replace('"', '\\"')
- print('{0}{{library_path="{1}", library_name="{2}"}} {3}'.format(
+ print('{0}{{ '{{' }}library_path="{1}", library_name="{2}"{{ '}}' }} {3}'.format(
metric_name,
dir_path,
basename,
diff --git a/roles/monitoring/prometheus/exporter/node/files/smartmon b/roles/monitoring/prometheus/exporter/node/templates/textfile-collector-scripts/smartmon.j2
index fd03e45f..b033faf0 100644
--- a/roles/monitoring/prometheus/exporter/node/files/smartmon
+++ b/roles/monitoring/prometheus/exporter/node/templates/textfile-collector-scripts/smartmon.j2
@@ -1,4 +1,4 @@
-#!/usr/bin/env python3
+#!/usr/bin/env {{ python_basename }}
import argparse
import collections
import csv
@@ -101,7 +101,7 @@ def metric_format(metric, prefix=''):
'{k}="{v}"'.format(k=k, v=v.replace('"', '\\"')) for k, v in metric.labels.items())
value = decimal.Decimal(metric.value)
- return '{key}{{{labels}}} {value}'.format(
+ return '{key}{{ '{{{' }}labels{{ '}}}' }} {value}'.format(
key=key, labels=labels, value=value)