[SOLVED] ZFS scrub_start event for rpool?

r4dh4l

Active Member
Feb 5, 2018
88
7
28
Hi,

I've configured mail notifications via ZFS Event Daemon / ZED and mail notifications for "ZFS scrub_finish event for rpool ..." work just fine.

I would like to receive mails when ZFS starts scrubbing as well. How can I set this?

Thank you for Proxmox!
 
Hi!

You could base this off from the default shipped "scrub_finish".

So short primer for ZEDLETs (comes from scriplets often used in other projects). The default shipped reside in "/usr/lib/zfs-linux/zed.d/", if they should be enabled they need to be in "/etc/zfs/zed.d/", so by default a symlink is placed there pointing to the default shipped one, see
Code:
ls -l /etc/zfs/zed.d/

So for making the start notification "zedlet" do
Code:
cp /usr/lib/zfs-linux/zed.d/scrub_finish-notify.sh /etc/zfs/zed.d/scrub_start-notify.sh

Now we need to adapt it, we could open it in the editor and figure the changes out, but as this seems like it'd be made for chaging it from "finish" to start events very easily, we can even do this by a simple search-and-replace command, for example with good ol' sed:
Code:
sed -i 's/finish/start/g' /etc/zfs/zed.d/scrub_start-notify.sh

and finally restart the ZFS ZED service to ensure it loads this new zedlet:
Code:
systemctl restart zfs-zed.service

Then it should be working, it does here, at least :)
 
Sorry for never reporting back (didn't find the time to try your suggestion). But thank you very much for your detailed explanation. Will report back asap.
 
Didn't know why I've waited so long.

You could base this off from the default shipped "scrub_finish".

So short primer for ZEDLETs (comes from scriplets often used in other projects). The default shipped reside in "/usr/lib/zfs-linux/zed.d/", if they should be enabled they need to be in "/etc/zfs/zed.d/", so by default a symlink is placed there pointing to the default shipped one, see
Code:
ls -l /etc/zfs/zed.d/

So for making the start notification "zedlet" do
Code:
cp /usr/lib/zfs-linux/zed.d/scrub_finish-notify.sh /etc/zfs/zed.d/scrub_start-notify.sh

Now we need to adapt it, we could open it in the editor and figure the changes out, but as this seems like it'd be made for chaging it from "finish" to start events very easily, we can even do this by a simple search-and-replace command, for example with good ol' sed:
Code:
sed -i 's/finish/start/g' /etc/zfs/zed.d/scrub_start-notify.sh

and finally restart the ZFS ZED service to ensure it loads this new zedlet:
Code:
systemctl restart zfs-zed.service

I had to adjust the paths a little bit:

Code:
ls -la /etc/zfs/zed.d/

cp /usr/lib/x86_64-linux-gnu/zfs/zed.d/scrub_finish-notify.sh /usr/lib/x86_64-linux-gnu/zfs/zed.d/scrub_start-notify.sh

ln -s /usr/lib/x86_64-linux-gnu/zfs/zed.d/scrub_start-notify.sh /etc/zfs/zed.d/scrub_start-notify.sh && ls -la /etc/zfs/zed.d/

sed -i 's/finish/start/g' /etc/zfs/zed.d/scrub_start-notify.sh && cat /etc/zfs/zed.d/scrub_start-notify.sh

systemctl restart zfs-zed.service && systemctl status zfs-zed.service

Is it okay to symlink
Code:
scrub_start-notify.sh
like the other scripts?
 
Didn't know why I've waited so long.



I had to adjust the paths a little bit:

Code:
ls -la /etc/zfs/zed.d/

cp /usr/lib/x86_64-linux-gnu/zfs/zed.d/scrub_finish-notify.sh /usr/lib/x86_64-linux-gnu/zfs/zed.d/scrub_start-notify.sh

ln -s /usr/lib/x86_64-linux-gnu/zfs/zed.d/scrub_start-notify.sh /etc/zfs/zed.d/scrub_start-notify.sh && ls -la /etc/zfs/zed.d/

sed -i 's/finish/start/g' /etc/zfs/zed.d/scrub_start-notify.sh && cat /etc/zfs/zed.d/scrub_start-notify.sh

systemctl restart zfs-zed.service && systemctl status zfs-zed.service

Is it okay to symlink
Code:
scrub_start-notify.sh
like the other scripts?

Confirming that this works. Just got my first "ZFS scrub_start event for rpool on <hostname>" mail.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!