diff options
author | Maxim Cournoyer <maxim.cournoyer@gmail.com> | 2021-01-13 23:39:52 -0500 |
---|---|---|
committer | Maxim Cournoyer <maxim.cournoyer@gmail.com> | 2021-01-13 23:45:53 -0500 |
commit | 01f0707207741ce2a5d7509a175464799b08aea6 (patch) | |
tree | 08e8f4da56f26363c3b53e0442a21b286b55e0e5 /gnu/services/monitoring.scm | |
parent | 734bcf13139119daf8685f93b056c3422dbfa264 (diff) | |
parent | 6985a1acb3e9cc4cad8b6f63d77154842d25c929 (diff) | |
download | guix-patches-01f0707207741ce2a5d7509a175464799b08aea6.tar guix-patches-01f0707207741ce2a5d7509a175464799b08aea6.tar.gz |
Merge branch 'staging' into 'core-updates'.
Conflicts:
gnu/local.mk
gnu/packages/cmake.scm
gnu/packages/curl.scm
gnu/packages/gl.scm
gnu/packages/glib.scm
gnu/packages/guile.scm
gnu/packages/node.scm
gnu/packages/openldap.scm
gnu/packages/package-management.scm
gnu/packages/python-xyz.scm
gnu/packages/python.scm
gnu/packages/tls.scm
gnu/packages/vpn.scm
gnu/packages/xorg.scm
Diffstat (limited to 'gnu/services/monitoring.scm')
-rw-r--r-- | gnu/services/monitoring.scm | 85 |
1 files changed, 68 insertions, 17 deletions
diff --git a/gnu/services/monitoring.scm b/gnu/services/monitoring.scm index da3d736ba6..5123a8c441 100644 --- a/gnu/services/monitoring.scm +++ b/gnu/services/monitoring.scm @@ -1,7 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2018 Sou Bunnbu <iyzsong@member.fsf.org> ;;; Copyright © 2018, 2019 Gábor Boskovits <boskovits@gmail.com> -;;; Copyright © 2018, 2019 Oleg Pykhalov <go.wigust@gmail.com> +;;; Copyright © 2018, 2019, 2020 Oleg Pykhalov <go.wigust@gmail.com> ;;; ;;; This file is part of GNU Guix. ;;; @@ -36,8 +36,12 @@ #:use-module (srfi srfi-26) #:use-module (srfi srfi-35) #:export (darkstat-configuration - prometheus-node-exporter-configuration darkstat-service-type + + prometheus-node-exporter-configuration + prometheus-node-exporter-configuration? + prometheus-node-exporter-configuration-package + prometheus-node-exporter-web-listen-address prometheus-node-exporter-service-type zabbix-server-configuration @@ -110,6 +114,11 @@ HTTP.") (service-extension shepherd-root-service-type (compose list darkstat-shepherd-service)))))) + +;;; +;;; Prometheus node exporter +;;; + (define-record-type* <prometheus-node-exporter-configuration> prometheus-node-exporter-configuration make-prometheus-node-exporter-configuration @@ -117,31 +126,73 @@ HTTP.") (package prometheus-node-exporter-configuration-package (default go-github-com-prometheus-node-exporter)) (web-listen-address prometheus-node-exporter-web-listen-address - (default ":9100"))) + (default ":9100")) + (textfile-directory prometheus-node-exporter-textfile-directory + (default "/var/lib/prometheus/node-exporter")) + (extra-options prometheus-node-exporter-extra-options + (default '()))) + +(define %prometheus-node-exporter-accounts + (list (user-account + (name "prometheus-node-exporter") + (group "prometheus-node-exporter") + (system? #t) + (comment "Prometheus node exporter daemon user") + (home-directory "/var/empty") + (shell (file-append shadow "/sbin/nologin"))) + (user-group + (name "prometheus-node-exporter") + (system? #t)))) (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)))))) + package web-listen-address textfile-directory extra-options) + (list + (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 + #$@(if textfile-directory + (list "--collector.textfile.directory" + textfile-directory) + '()) + #$@extra-options) + #:user "prometheus-node-exporter" + #:group "prometheus-node-exporter" + #:log-file "/var/log/prometheus-node-exporter.log")) + (stop #~(make-kill-destructor))))))) + +(define (prometheus-node-exporter-activation config) + (with-imported-modules '((guix build utils)) + #~(let ((textfile-directory + #$(prometheus-node-exporter-textfile-directory config))) + (use-modules (guix build utils)) + + (when textfile-directory + (let ((user (getpw "prometheus-node-exporter"))) + #t + (mkdir-p textfile-directory) + (chown textfile-directory (passwd:uid user) (passwd:gid user)) + (chmod textfile-directory #o775)))))) (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.") +Prometheus.") (extensions - (list (service-extension - shepherd-root-service-type - (compose list prometheus-node-exporter-shepherd-service)))) + (list + (service-extension account-service-type + (const %prometheus-node-exporter-accounts)) + (service-extension activation-service-type + prometheus-node-exporter-activation) + (service-extension shepherd-root-service-type + prometheus-node-exporter-shepherd-service))) (default-value (prometheus-node-exporter-configuration)))) @@ -343,7 +394,7 @@ configuration file.")) (group "zabbix") "Group who will run the Zabbix agent.") (hostname - (string "Zabbix server") + (string "") "Unique, case sensitive hostname which is required for active checks and must match hostname as configured on the server.") (log-type |