diff options
author | Franz Geffke <franz@pantherx.org> | 2023-11-06 20:08:14 +0000 |
---|---|---|
committer | Franz Geffke <franz@pantherx.org> | 2023-11-06 20:08:14 +0000 |
commit | 47b4c9c854915df93893dbaa993accfacf9027fe (patch) | |
tree | 4f9b1742d63fcfbc94cc6b8d84f76c4d00c3a0b7 /px/services/monitoring.scm | |
parent | 0b426d7b7ed8e176bf464ef9e0683f74a6c9d20f (diff) |
rewrite: apply guix-reference formatting; cleanup some module imports
Diffstat (limited to 'px/services/monitoring.scm')
-rw-r--r-- | px/services/monitoring.scm | 143 |
1 files changed, 83 insertions, 60 deletions
diff --git a/px/services/monitoring.scm b/px/services/monitoring.scm index a5c64e5..7beeb07 100644 --- a/px/services/monitoring.scm +++ b/px/services/monitoring.scm @@ -21,10 +21,12 @@ ;; (define-record-type* <px-remote-status-service-configuration> - px-remote-status-service-configuration make-px-remote-status-configuration + px-remote-status-service-configuration + make-px-remote-status-configuration px-remote-status-service-configuration? - (package px-remote-status-service-configuration-package - (default px-org-remote-status-service)) + (package + px-remote-status-service-configuration-package + (default px-org-remote-status-service)) (interval px-remote-status-service-configuration-interval (default 300)) (jobs px-remote-status-service-configuration-jobs @@ -34,17 +36,15 @@ "Return monitrc file for config" (match config (($ <px-remote-status-service-configuration> jobs) - (computed-file - "monitrc" - (with-imported-modules - '((guix build utils)) - #~(begin - (use-modules (guix build utils) - (ice-9 match)) - (call-with-output-file #$output - (lambda (port) - (display "\ -### Monit default configurations + (computed-file "monitrc" + (with-imported-modules '((guix build utils)) + #~(begin + (use-modules (guix build utils) + (ice-9 match)) + (call-with-output-file #$output + (lambda (port) + (display + "### Monit default configurations ## Check interval set daemon 30 # check services at 30 seconds intervals # with start delay 240 # optional: delay the first check by 4-minutes (by @@ -59,58 +59,81 @@ set httpd port 2812 and allow localhost # allow localhost to connect to the server and allow admin:monit # require user 'admin' with password 'monit' -### Monit job definitions\n" port) - (for-each (lambda (job) - (display (string-append job "\n") port)) - '#$(px-remote-status-service-configuration-jobs config)) - )))))))) +### Monit job definitions +" + port) + (for-each (lambda (job) + (display (string-append + job + "\n") + port)) + '#$(px-remote-status-service-configuration-jobs + config)))))))))) (define (px-remote-status-shepherd-service config) "Return <shepherd-service> running px-org-remote-status-service" (match config (($ <px-remote-status-service-configuration> package interval) (let ((monitrc (px-remote-service-configuration->monitrc config))) - (list (shepherd-service - (provision '(px-remote-status)) - (documentation "Run px-org-remote-status-service as a shepherd daemon") - (requirement '(networking user-processes px-device-identity)) - (modules `((srfi srfi-1) - (srfi srfi-26) - ,@%default-modules)) - (start #~(make-forkexec-constructor - (list (string-append #$screen "/bin/screen") - "-D" "-m" "-S" "remote-status" - (string-append #$package "/bin/px-org-remote-status-service") - "-i" (number->string #$interval) - "-m" #$monitrc) - #:environment-variables - (cons* (string-append "PATH=" - #$monit "/bin:" - #$network-manager "/bin:" - #$lshw "/sbin:" - #$coreutils "/bin:" - #$sysstat "/bin:" - #$curl "/bin:" - #$util-linux+udev "/bin:" - #$px-device-identity "/bin:" - "/run/current-system/profile/bin:" - (getenv "PATH")) - "HOME=/root" - "XDG_DATA_HOME=/root/.local/share" - "XDG_CONFIG_HOME=/root/.config" - "SSL_CERT_DIR=/run/current-system/profile/etc/ssl/certs" - "SSL_CERT_FILE=/run/current-system/profile/etc/ssl/certs/ca-certificates.crt" - (remove (cut string-prefix? "PATH=" <>) - (environ))))) - (stop #~(make-kill-destructor)))))))) - - + (list (shepherd-service (provision '(px-remote-status)) + (documentation + "Run px-org-remote-status-service as a shepherd daemon") + (requirement '(networking user-processes + px-device-identity)) + (modules `((srfi srfi-1) + (srfi srfi-26) + ,@%default-modules)) + (start #~(make-forkexec-constructor (list (string-append #$screen + "/bin/screen") + "-D" + "-m" + "-S" + "remote-status" + (string-append #$package + "/bin/px-org-remote-status-service") + "-i" + (number->string #$interval) + "-m" + #$monitrc) + #:environment-variables + (cons* (string-append + "PATH=" + #$monit + "/bin:" + #$network-manager + "/bin:" + #$lshw + "/sbin:" + #$coreutils + "/bin:" + #$sysstat + "/bin:" + #$curl + "/bin:" + #$util-linux+udev + "/bin:" + #$px-device-identity + "/bin:" + "/run/current-system/profile/bin:" + (getenv + "PATH")) + "HOME=/root" + "XDG_DATA_HOME=/root/.local/share" + "XDG_CONFIG_HOME=/root/.config" + "SSL_CERT_DIR=/run/current-system/profile/etc/ssl/certs" + "SSL_CERT_FILE=/run/current-system/profile/etc/ssl/certs/ca-certificates.crt" + (remove (cut + string-prefix? + "PATH=" + <>) + (environ))))) + (stop #~(make-kill-destructor)))))))) (define px-remote-status-service-type - (service-type - (name 'px-remote-status) - (description "PantherX remote status service") - (extensions (list (service-extension shepherd-root-service-type - px-remote-status-shepherd-service))) - (default-value (px-remote-status-service-configuration)))) + (service-type (name 'px-remote-status) + (description "PantherX remote status service") + (extensions (list (service-extension + shepherd-root-service-type + px-remote-status-shepherd-service))) + (default-value (px-remote-status-service-configuration)))) |