From: Tristan Kohl via <help-guix@gnu.org>
To: help-guix@gnu.org
Subject: How to configure smartd and send notifications?
Date: Mon, 20 May 2024 00:48:20 +0200 [thread overview]
Message-ID: <4D873504-6540-477A-A2DB-DE293395CAFC@ymail.com> (raw)
In-Reply-To: 4D873504-6540-477A-A2DB-DE293395CAFC.ref@ymail.com
Hello Guix gurus,
I have a hard time wrapping my head around how to configure smartd (1) and send notifications via ntfy.sh (2).
1. Configuration of smartd
I could not find anything in the admin module in the Guix repository on how to configure smartd (i.e. smartd-configuration) - there I found only smartmontools build procedure.
When checking /var/log/messages I could see that smartd defaults to some configuration file in the store rather than the default /etc/smartd.conf. So I tried to write my own:
(define smartd-send-ntfy
(plain-file "/usr/local/sbin/send-ntfy" "#!/bin/sh\ncurl ntfy.sh/<my-topic> -d 'curl -Ls -H "Title: $SMARTD_SUBJECT" -d "$SMARTD_FAILTYPE Device: $SMARTD_DEVICE Time: $SMARTD_TFIRST Message: $SMARTD_FULLMESSAGE"'))
(define smartd-config-file
(plain-file "smartd.conf" "DEVICESCAN -a -s (S/../.././03|L/../01/./04) -m <nomailer> -M exec /usr/local/sbin/send-ntfy -M test"))
(services
(append
(list
...
(simple-service
'smartd-service
shepherd-root-service-type
(list
(shepherd-service
(documentation "Monitor disks for failure.")
(provision '(smartd))
(requirement '(udev user-processes))
(start
#~(make-forkexec-constructor
(list "/run/current-system/profile/sbin/smartd" "--no-fork" "-c" smartd-config-file)))
(stop #~(make-kill-destructor))))))
%base-services))
This results in a warning "possibly unbound variable `smartd-config-file". Tried to understand G-expressions and put #$smartd-config-file in there but I am already overwhelmed with (un)quote so I guess I am missing the point here. Also how do I get the store path from smartd-notify-send into smartd-config-file because my naive approach putting the path into plain-file name argument does not work.
2. Notifications
Also I have a bunch of mcron jobs which I also would like to use ntfy.sh to send messages to me. How do I append a string to the srcub job passing a message to msg? Is this even the right way?
(define (notify msg)
(string-append "curl ntfy.sh/sTu0vFzNZqfMSLJiRAxuTHEUHy8BYWW6 -d '" msg "'"))
(define monthly-srub-job
#~(job
"0 3 1 * *"
"btrfs scrub start -dB /pool" ))
Sorry for these beginner questions, I just started diverting from copy-pasting config parts from others.
Thank you!
next parent reply other threads:[~2024-05-19 22:48 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <4D873504-6540-477A-A2DB-DE293395CAFC.ref@ymail.com>
2024-05-19 22:48 ` Tristan Kohl via [this message]
2024-05-20 11:30 ` How to configure smartd and send notifications? Felix Lechner via
2024-05-20 13:56 ` Tristan Kohl via
2024-05-20 15:04 ` Felix Lechner via
2024-05-20 19:15 ` Tristan Kohl via
2024-05-20 23:42 ` Felix Lechner via
2024-05-21 15:33 ` Tristan Kohl via
2024-05-21 15:50 ` Tomas Volf
2024-05-23 19:25 ` Tristan Kohl via
2024-05-24 4:10 ` Felix Lechner via
2024-05-24 10:19 ` Tomas Volf
2024-05-31 13:42 ` Tristan Kohl via
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4D873504-6540-477A-A2DB-DE293395CAFC@ymail.com \
--to=help-guix@gnu.org \
--cc=blobbyjj@ymail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.