From a33652ee336ae9a5d2ab5fd54bf2397caec42a0e Mon Sep 17 00:00:00 2001 From: Gábor Boskovits Date: Mon, 18 Jun 2018 12:43:42 +0200 Subject: services: Add prometheus-node-exporter-service-type. * gnu/services/monitoring.scm (prometheus-node-exporter-service-type): New variable. (): New record type. (prometheus-node-exporter-shepherd-service): New procedure. * gnu/doc/guix.texi (Monitoring Services): Document it. * gnu/tests/monitoring.scm: New file. * gnu/local.mk (GNU_SYSTEM_MODULES): Add test module. --- gnu/services/monitoring.scm | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) (limited to 'gnu/services') diff --git a/gnu/services/monitoring.scm b/gnu/services/monitoring.scm index 49a65db4b5..aa3b63a0e4 100644 --- a/gnu/services/monitoring.scm +++ b/gnu/services/monitoring.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2018 Sou Bunnbu +;;; Copyright © 2018 Gábor Boskovits ;;; ;;; This file is part of GNU Guix. ;;; @@ -26,7 +27,9 @@ (define-module (gnu services monitoring) #:use-module (guix records) #:use-module (ice-9 match) #:export (darkstat-configuration - darkstat-service-type)) + prometheus-node-exporter-configuration + darkstat-service-type + prometheus-node-exporter-service-type)) ;;; @@ -89,3 +92,36 @@ (define darkstat-service-type (const %darkstat-accounts)) (service-extension shepherd-root-service-type (compose list darkstat-shepherd-service)))))) + +(define-record-type* + prometheus-node-exporter-configuration + make-prometheus-node-exporter-configuration + prometheus-node-exporter-configuration? + (package prometheus-node-exporter-configuration-package + (default go-github-com-prometheus-node-exporter)) + (web-listen-address prometheus-node-exporter-web-listen-address + (default ":9100"))) + +(define prometheus-node-exporter-shepherd-service + (match-lambda + (( $ + package web-listen-address) + (shepherd-service + (documentation "Prometheus node exporter.") + (provision '(prometheus-node-exporter)) + (requirement '(networking)) + (start #~(make-forkexec-constructor + (list #$(file-append package "/bin/node_exporter") + "--web.listen-address" #$web-listen-address))) + (stop #~(make-kill-destructor)))))) + +(define prometheus-node-exporter-service-type + (service-type + (name 'prometheus-node-exporter) + (description + "Run @command{node_exporter} to serve hardware and OS metrics to +prometheus.") + (extensions + (list (service-extension + shepherd-root-service-type + (compose list prometheus-node-exporter-shepherd-service)))))) -- cgit v1.2.3