Page MenuHomeDevCentral

D3369.id8693.diff
No OneTemporary

D3369.id8693.diff

diff --git a/map.jinja b/map.jinja
--- a/map.jinja
+++ b/map.jinja
@@ -125,6 +125,7 @@
'pear': 'php-pear',
'phpcs': 'php-codesniffer',
'postgresql': 'postgresql-15',
+ 'prometheus-node-exporter': 'prometheus-node-exporter',
'sphinx': 'python3-sphinx',
'tcl': 'tcl8.6-dev',
'tcltls': 'tcl-tls',
@@ -149,6 +150,7 @@
'node': 'nodejs',
'pear': 'php-pear',
'phpcs': 'php-pear-PHP-CodeSniffer',
+ 'prometheus-node-exporter': 'golang-github-prometheus-node-exporter',
'sphinx': 'python3-sphinx',
'tcl': 'tcl',
'tcltls': 'tcltls',
@@ -190,6 +192,7 @@
'phpcs': 'pear-PHP_CodeSniffer',
'postgresql': 'postgresql15-server',
'postgresql-contrib': 'postgresql15-contrib',
+ 'prometheus-node-exporter': 'node_exporter',
'sphinx': 'py36-sphinx',
'tcl': 'tcl86',
'tcltls': 'tcltls',
diff --git a/roles/core/monitoring/files/prometheus-node-exporter.env b/roles/core/monitoring/files/prometheus-node-exporter.env
new file mode 100644
--- /dev/null
+++ b/roles/core/monitoring/files/prometheus-node-exporter.env
@@ -0,0 +1,16 @@
+# -------------------------------------------------------------
+# Prometheus :: node exporter
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# License: Trivial work, not eligible to copyright
+# Source file: roles/core/monitoring/files/prometheus-node-exporter.env
+# -------------------------------------------------------------
+#
+# <auto-generated>
+# This file is managed by our rOPS SaltStack repository.
+#
+# Changes to this file may cause incorrect behavior
+# and will be lost if the state is redeployed.
+# </auto-generated>
+
+ARGS='--web.listen-address="{{ ip }}:9100"'
diff --git a/roles/core/monitoring/files/rc/prometheus-node-exporter.conf b/roles/core/monitoring/files/rc/prometheus-node-exporter.conf
new file mode 100644
--- /dev/null
+++ b/roles/core/monitoring/files/rc/prometheus-node-exporter.conf
@@ -0,0 +1,17 @@
+# -------------------------------------------------------------
+# Prometheus :: node exporter
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# License: Trivial work, not eligible to copyright
+# Source file: roles/core/monitoring/files/rc/prometheus-node-exporter.conf
+# -------------------------------------------------------------
+#
+# <auto-generated>
+# This file is managed by our rOPS SaltStack repository.
+#
+# Changes to this file may cause incorrect behavior
+# and will be lost if the state is redeployed.
+# </auto-generated>
+
+node_exporter_enable="YES"
+node_exporter_listen_address="{{ ip }}:9100"
diff --git a/roles/core/monitoring/init.sls b/roles/core/monitoring/init.sls
--- a/roles/core/monitoring/init.sls
+++ b/roles/core/monitoring/init.sls
@@ -7,3 +7,4 @@
include:
- .checks
+ - .prometheus
diff --git a/roles/core/monitoring/init.sls b/roles/core/monitoring/map.jinja
copy from roles/core/monitoring/init.sls
copy to roles/core/monitoring/map.jinja
--- a/roles/core/monitoring/init.sls
+++ b/roles/core/monitoring/map.jinja
@@ -5,5 +5,11 @@
# License: Trivial work, not eligible to copyright
# -------------------------------------------------------------
-include:
- - .checks
+{% set monitoring_services = salt["grains.filter_by"]({
+ "Debian": {
+ "prometheus-node-exporter": "prometheus-node-exporter",
+ },
+ "FreeBSD": {
+ "prometheus-node-exporter": "node_exporter",
+ },
+}, default="Debian") %}
diff --git a/roles/core/monitoring/prometheus.sls b/roles/core/monitoring/prometheus.sls
new file mode 100644
--- /dev/null
+++ b/roles/core/monitoring/prometheus.sls
@@ -0,0 +1,46 @@
+# -------------------------------------------------------------
+# Salt — Monitoring
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# License: Trivial work, not eligible to copyright
+# -------------------------------------------------------------
+
+{% from "map.jinja" import dirs, packages, services with context %}
+{% from "roles/core/monitoring/map.jinja" import monitoring_services with context %}
+
+{% set network = salt["node.resolve_network"]() %}
+
+# -------------------------------------------------------------
+# Software
+#
+# :: prometheus-node-exporter for kernel and hardware metrics
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+monitoring_prometheus_software:
+ pkg.installed:
+ - pkgs:
+ - {{ packages["prometheus-node-exporter"] }}
+
+# -------------------------------------------------------------
+# Services
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+{% if services["manager"] == "rc" %}
+ {% set source = "rc/prometheus-node-exporter.conf" %}
+ {% set target = "/etc/rc.conf.d/" + monitoring_services["prometheus-node-exporter"] %}
+{% elif services["manager"] == "systemd" %}
+ {% set source = "prometheus-node-exporter.env" %}
+ {% set target = "/etc/default/prometheus-node-exporter" %}
+{% endif %}
+
+prometheus_node_exporter_service_config:
+ file.managed:
+ - name: {{ target }}
+ - source: salt://roles/core/monitoring/files/{{ source }}
+ - template: jinja
+ - context:
+ ip: {{ network.private_ipv4_address }}
+
+prometheus_node_exporter_running:
+ service.running:
+ - name: {{ monitoring_services["prometheus-node-exporter"] }}

File Metadata

Mime Type
text/plain
Expires
Thu, Dec 19, 20:54 (20 h, 45 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2306642
Default Alt Text
D3369.id8693.diff (5 KB)

Event Timeline