all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [bug#47905] gnu: Add rasdaemon.
@ 2021-04-20  4:24 elaexuotee--- via Guix-patches via
  2021-04-20  5:04 ` Leo Famulari
                   ` (3 more replies)
  0 siblings, 4 replies; 15+ messages in thread
From: elaexuotee--- via Guix-patches via @ 2021-04-20  4:24 UTC (permalink / raw)
  To: 47905

[-- Attachment #1: Type: text/plain, Size: 341 bytes --]

This is my first patch to gnu/services (and by inclusion doc/guix.texi), so
please scrutinize with abandon!

I did all the standard sanity checks for the package definition (guix lint,
etc/indent-code.el, guix build --check); however, I wasn't sure about the
service, so the sanity checks were limited to testing in a vm.

Cheers!


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-gnu-Add-rasdaemon.patch --]
[-- Type: text/x-patch, Size: 7973 bytes --]

From 1d4e60a9578d3572bf1caff11d0b17e4bc8f1ea9 Mon Sep 17 00:00:00 2001
From: "B. Wilson" <elaexuotee@wilsonb.com>
Date: Tue, 20 Apr 2021 11:49:26 +0900
Subject: [PATCH] gnu: Add rasdaemon.
To: guix-patches@gnu.org

* gnu/packages/linux.scm (rasdaemon): New variable.
* gnu/services/linux.scm (rasdaemon-configuration)
  (rasdaemon-configuration?, rasdaemon-configuration-record?)
  (rasdaemon-service-type): New variables.
* doc/guix.texi (Linux Services): Document it.
---
 doc/guix.texi          | 29 +++++++++++++++++++++++++
 gnu/packages/linux.scm | 45 ++++++++++++++++++++++++++++++++++++++
 gnu/services/linux.scm | 49 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 123 insertions(+)

diff --git a/doc/guix.texi b/doc/guix.texi
index 58bcfbdbb5..73479b8fcf 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -88,6 +88,7 @@ Copyright @copyright{} 2020 John Soo@*
 Copyright @copyright{} 2020 Jonathan Brielmaier@*
 Copyright @copyright{} 2020 Edgar Vincent@*
 Copyright @copyright{} 2021 Maxime Devos@*
+Copyright @copyright{} 2021 B. Wilson@*
 
 Permission is granted to copy, distribute and/or modify this document
 under the terms of the GNU Free Documentation License, Version 1.3 or
@@ -31457,6 +31458,34 @@ parameters, can be done as follow:
 @end lisp
 @end deffn
 
+@cindex rasdaemon
+@cindex Platform Reliability, Availability and Serviceability daemon
+@subsubheading Rasdaemon Service
+
+The Rasdaemon service provides a monitor for Platform Reliability,
+Availability, and Serviceability (RAS) events in the Linux kernel.
+
+@defvr {Scheme Variable} rasdaemon-service-type
+Service type for the @command{rasdaemon} service.  It accepts a
+@code{rasdaemon-configuration} object.  Instantiating like
+
+@lisp
+(service rasdaemon-service-type)
+@end lisp
+
+will load with a default configuration.
+@end defvr
+
+@deftp {Data Type} rasdaemon-configuration
+The data type representing the configuration of @command{rasdaemon}.
+
+@table @asis
+@item @code{record?} (default: @code{#f})
+A boolean indicating whether to record the events in an SQLite database.  The
+database location is hard-coded to @file{/var/lib/rasdaemon/ras-mc_event.db}.
+@end table
+@end deftp
+
 @cindex zram
 @cindex compressed swap
 @cindex Compressed RAM-based block devices
diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm
index 1ea9d80834..fe464bcc8e 100644
--- a/gnu/packages/linux.scm
+++ b/gnu/packages/linux.scm
@@ -53,6 +53,7 @@
 ;;; Copyright © 2020 Zhu Zihao <all_but_last@163.com>
 ;;; Copyright © 2020 David Dashyan <mail@davie.li>
 ;;; Copyright © 2020 pukkamustard <pukkamustard@posteo.net>
+;;; Copyright © 2021 B. Wilson <elaexuotee@wilsonb.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -130,6 +131,7 @@
   #:use-module (gnu packages sdl)
   #:use-module (gnu packages serialization)
   #:use-module (gnu packages slang)
+  #:use-module (gnu packages sqlite)
   #:use-module (gnu packages texinfo)
   #:use-module (gnu packages tls)
   #:use-module (gnu packages valgrind)
@@ -8037,3 +8039,46 @@ kernel side implementation.")
 read-only file system optimized for resource-scarce devices.  This package
 provides user-space tools for creating EROFS file systems.")
     (license license:gpl2+)))
+
+(define-public rasdaemon
+  (package
+    (name "rasdaemon")
+    (version "0.6.6")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/mchehab/rasdaemon")
+             (commit (string-append "v" version))))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "13g39x19lfjf9izdcb0nlyfjrgpliivhv4nw3ndgyzi59l3yqc0v"))))
+    (native-inputs `(("autoconf" ,autoconf)
+                     ("automake" ,automake)
+                     ("libtool" ,libtool)))
+    (inputs `(("sqlite" ,sqlite)))
+    (arguments
+     `(#:configure-flags '("--enable-all"
+                           "--localstatedir=/var")
+       #:phases
+       (modify-phases %standard-phases
+         (add-before 'configure 'munge-autotools
+           (lambda _
+             ;; For some reason upstream forces sysconfdir=/etc.  This results
+             ;; in EPERM during the install phase.  Removing the offending
+             ;; line lets sysconfdir correctly pick up DESTDIR.
+             (substitute* "configure.ac"
+               (("^test .* sysconfdir=/etc\n$") ""))
+             ;; Upstream tries to create /var/lib/rasdaemon at install time.
+             ;; This results in EPERM on guix.  Instead, the service should
+             ;; create this at activation time.
+             (substitute* "Makefile.am"
+               (("^\\s*\\$\\(install_sh\\) -d .*@RASSTATEDIR@.*$") "")))))))
+    (build-system gnu-build-system)
+    (home-page "https://github.com/mchehab/rasdaemon")
+    (synopsis "Platform Reliability, Availability and Serviceability tools")
+    (description "The @code{rasdaemon} program is a daemon which monitors the
+platform Reliablity, Availability and Serviceability (RAS) reports from the
+Linux kernel trace events.  These trace events are logged in
+/sys/kernel/debug/tracing, reporting them via syslog/journald.")
+    (license license:gpl2+)))
diff --git a/gnu/services/linux.scm b/gnu/services/linux.scm
index 340b330030..01723efc07 100644
--- a/gnu/services/linux.scm
+++ b/gnu/services/linux.scm
@@ -3,6 +3,7 @@
 ;;; Copyright © 2020 Brice Waegeneire <brice@waegenei.re>
 ;;; Copyright © 2020 Efraim Flashner <efraim@flashner.co.il>
 ;;; Copyright © 2021 raid5atemyhomework <raid5atemyhomework@protonmail.com>
+;;; Copyright © 2021 B. Wilson <elaexuotee@wilsonb.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -47,6 +48,11 @@
 
             kernel-module-loader-service-type
 
+            rasdaemon-configuration
+            rasdaemon-configuration?
+            rasdaemon-configuration-record?
+            rasdaemon-service-type
+
             zram-device-configuration
             zram-device-configuration?
             zram-device-configuration-size
@@ -188,6 +194,49 @@ representation."
    (extend append)
    (default-value '())))
 
+\f
+;;;
+;;; Reliability, Availability, and Servicability (RAS) daemon
+;;;
+
+(define-record-type* <rasdaemon-configuration>
+  rasdaemon-configuration make-rasdaemon-configuration
+  rasdaemon-configuration?
+  (record? rasdaemon-configuration-record? (default #f)))
+
+(define (rasdaemon-configuration->command-line-args config)
+  "Translate <rasdaemon-configuration> to its command line arguments
+  representation"
+  (let ((record? (rasdaemon-configuration-record? config)))
+    `(,(file-append rasdaemon "/sbin/rasdaemon")
+      "--foreground" ,@(if record? '("--record") '()))))
+
+(define (rasdaemon-activation config)
+  (let ((record? (rasdaemon-configuration-record? config))
+        (rasdaemon-dir "/var/lib/rasdaemon"))
+    (with-imported-modules '((guix build utils))
+      #~(if #$record? (mkdir-p #$rasdaemon-dir)))))
+
+(define (rasdaemon-shepherd-service config)
+  (shepherd-service
+   (documentation "Run rasdaemon")
+   (provision '(rasdaemon))
+   (start #~(make-forkexec-constructor
+             '#$(rasdaemon-configuration->command-line-args config)
+             #:log-file "/var/log/rasdaemon.log"))
+   (stop #~(make-kill-destructor))))
+
+(define rasdaemon-service-type
+  (service-type
+   (name 'rasdaemon)
+   (default-value (rasdaemon-configuration))
+   (extensions
+    (list (service-extension shepherd-root-service-type
+                             (compose list rasdaemon-shepherd-service))
+          (service-extension activation-service-type rasdaemon-activation)))
+   (compose concatenate)
+   (description "Run @command{rasdaemon}, the RAS monitor")))
+
 \f
 ;;;
 ;;; Kernel module loader.
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2021-04-24 16:35 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-20  4:24 [bug#47905] gnu: Add rasdaemon elaexuotee--- via Guix-patches via
2021-04-20  5:04 ` Leo Famulari
2021-04-20  5:07 ` Leo Famulari
2021-04-20  5:54   ` elaexuotee--- via Guix-patches via
2021-04-20 16:08     ` Leo Famulari
2021-04-20  5:30 ` Leo Famulari
2021-04-20  6:18   ` elaexuotee--- via Guix-patches via
2021-04-20 16:19     ` Leo Famulari
2021-04-20  5:33 ` Leo Famulari
2021-04-20  6:23   ` elaexuotee--- via Guix-patches via
2021-04-20 16:20     ` Leo Famulari
2021-04-20  7:10   ` elaexuotee--- via Guix-patches via
2021-04-20 16:23     ` Leo Famulari
2021-04-22 10:01       ` elaexuotee--- via Guix-patches via
2021-04-24 16:33         ` bug#47905: " Leo Famulari

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.