Page 1 of 1

Alerting on macos with Example

PostPosted: Fri Dec 02, 2022 2:48 am
by mike0810
Hi,

recently two of my disks were unavailable, gladly out of two different mirror pools.
I discovered this after a long time, but was able to resilver.

But as a general question: How do you configure alerting if the pool degrades or something on macos?
I mean just to get an email would be very nice.

Any suggestions?

Thanks a lot!

Re: Alerting on macos

PostPosted: Sat Dec 03, 2022 4:54 pm
by lundman
In theory, zed runs after OpenZFS install, and it has scripts which can send email. So it could be worth checking into that, just like Linux.

Another more GUI friendly way is ZetaWatch or similar 3rd party software.

Re: Alerting on macos

PostPosted: Sat Dec 17, 2022 4:51 am
by mike0810
I want to share my experience:
So I decided to use pushover APP on ios to get alerts. ZED supports that.
1. Download the app, register your user and a new applicaton. You get a user token and an app token.
2. Open (as sudo) /etc/zfs/zed.d/zed.rc
3. Edit the following sections:
(for testing I set verbosity to 1, will turn it back to 0 later)
Code: Select all
##
# Notification verbosity.
#   If set to 0, suppress notification if the pool is healthy.
#   If set to 1, send notification regardless of pool health.
#
ZED_NOTIFY_VERBOSE=1
...
##
# Pushover token.
# This defines the application from which the notification will be sent.
#   <https://pushover.net/api#registration>
# Disabled by default; uncomment to enable.
# ZED_PUSHOVER_USER, below, must also be configured.
#
ZED_PUSHOVER_TOKEN="<Your_App_Token>"

##
# Pushover user key.
# This defines which user or group will receive Pushover notifications.
#  <https://pushover.net/api#identifiers>
# Disabled by default; uncomment to enable.
# ZED_PUSHOVER_TOKEN, above, must also be configured.
ZED_PUSHOVER_USER="<Your_User_Token>"


After that, run:
Code: Select all
ps aux | grep zed


output:
Code: Select all
root               <your_process_id>   0.0  0.0 409087488   1904   ??  Ss   Wed11AM   0:00.12 /usr/local/zfs/bin/zed -vfF


And then execute HUP with the process ID you got:
Code: Select all
sudo kill -HUP <your_process_id>


Test by creating a sparse image pool and scrub it:
Code: Select all
cd /tmp
dd if=/dev/zero of=sparse_file bs=1 count=0 seek=512M
sudo zpool create test /tmp/sparse_file
sudo zpool scrub test


This should get you an alert on the pushover app.

Re: Alerting on macos

PostPosted: Sat Dec 17, 2022 4:31 pm
by lundman
That's great, cheers for sharing. About the only comment is "pkill -HUP zed", saving you a couple of steps.

hmm you know what, pkill is Solaris, I see I have it aliases to

"killall -HUP zed".