openzfs / zfs

OpenZFS on Linux and FreeBSD
https://openzfs.github.io/openzfs-docs
Other
10.68k stars 1.76k forks source link

Make ZED notification system "pluginabble" #4423

Open FireDrunk opened 8 years ago

FireDrunk commented 8 years ago

After playing around with the current zed-functions.sh i think there's a need for a simple structure to launch custom scripts for specific events to perform specific notifications.

The current scripting is hardcoded for Pushbullet, but it might be nice to make this a little more customizable.

For instance, i'm using NotifyMyAndroid thru Python (PyNMA module). I'm not very keen on hacking all the current SH scripts to insert my "/root/nma_zfs.py [subject] [message]" commands. Maybe something like a /etc/zfs/notifications.d/ directory structure with an entry point for each event type. So the user can symlink something like:

/etc/zfs/notifications.d/scrub-finished -> /etc/zfs/providers.d/notify_my_android.py

What would be the correct way to do this properly? If some of you can form a list of requirements i'm happy to take a shot at the rework.

EDIT: I see the scripts currently already are symlinks, my point is that i don't want to touch the already present scripting for replacing any device, i just want to be notified on a specific channel.

To clarify: i would like both scripts to be executed.

behlendorf commented 8 years ago

@FireDrunk I believe this is already supported. From zed(8):

       ZEDLETs  are  named  after  the  zevent  class for which they should be
       invoked.  In particular, a ZEDLET will be invoked for a given zevent if
       either its class or subclass string is a prefix of its filename (and is
       followed by a non-alphabetic character).  As a special case, the prefix
       "all" matches all zevents.  Multiple ZEDLETs may be invoked for a given
       zevent.

You may register as many ZEDLETs as you like for a specific notification. To do this the class or subclass string must match the prefix of its filename.

As for additional notification methods right now email and pushbullet are supported. However, if you'd like to add another option like NotifyMyAndroid you're welcome too. Take a look at the zed_notify function in zed-functions.sh. @dun might have some thoughts about this as well.

dun commented 8 years ago

Ditto what @behlendorf said; I don't have anything to add.

rlaager commented 8 years ago

I think @FireDrunk has a reasonable request. We shouldn't need to put every possible notification system into the core. For example, maybe I want zed to open tickets in my internal ticketing system; surely that doesn't belong in ZoL.