summary refs log tree commit diff
path: root/gnu/services
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/services')
-rw-r--r--gnu/services/monitoring.scm38
1 files changed, 37 insertions, 1 deletions
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 <iyzsong@member.fsf.org>
+;;; Copyright © 2018 Gábor Boskovits <boskovits@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -26,7 +27,9 @@
   #: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 @@ HTTP.")
                              (const %darkstat-accounts))
           (service-extension shepherd-root-service-type
                              (compose list darkstat-shepherd-service))))))
+
+(define-record-type* <prometheus-node-exporter-configuration>
+  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
+    (( $ <prometheus-node-exporter-configuration>
+         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))))))