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!

Reply via email to