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/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/prometheus.sls b/roles/core/monitoring/prometheus.sls new file mode 100644 --- /dev/null +++ b/roles/core/monitoring/prometheus.sls @@ -0,0 +1,40 @@ +# ------------------------------------------------------------- +# Salt — Monitoring +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# Project: Nasqueron +# License: Trivial work, not eligible to copyright +# ------------------------------------------------------------- + +{% from "map.jinja" import dirs, packages, services with context %} + +# ------------------------------------------------------------- +# 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 network = salt["node.resolve_network"]() %} + +/etc/rc.conf.d/node_exporter: + file.managed: + - source: salt://roles/core/monitoring/files/rc/prometheus-node-exporter.conf + - template: jinja + - context: + ip: {{ network.private_ipv4_address }} + +{% endif %} + +node_exporter_running: + service.running: + - name: node_exporter