linux:zfs

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
linux:zfs [2025/02/05 12:46] – [ZFS - notification] adminlinux:zfs [2025/02/05 12:49] (current) – [ZFS - notification] admin
Line 66: Line 66:
  
 ===== ZFS - notification ===== ===== ZFS - notification =====
-++++ notification zfs|+++++ telegram notification zfs|
 <code BASH> <code BASH>
-# https://github.com/leovp/telegram_notifications+ # https://github.com/leovp/telegram_notifications 
 +nano /etc/zfs/zed.d/zed-telegram.sh 
 + 
 +#!/bin/bash 
 +TELEGRAM_BOT_TOKEN="righttoken" # put your token here 
 +TELEGRAM_CHAT_ID="chatid" # your chat_id for sending notification 
 + 
 +subject="$1" 
 +details="$2" 
 + 
 +MESSAGE="🚨 ZFS Alert on $(hostname) 🚨 
 +Event: $subject 
 +Details: 
 +$details" 
 + 
 +curl -s -X POST "https://api.telegram.org/bot$TELEGRAM_BOT_TOKEN/sendMessage"
 +     -d "chat_id=$TELEGRAM_CHAT_ID"
 +     -d "text=$MESSAGE" 
 + 
 +chmod +x /etc/zfs/zed.d/zed-telegram.sh 
 + 
 +# zed-functions.sh Modified zed_notify function 
 +zed_notify() 
 +
 +    zed_notify_email "${subject}" "${pathname}"; rv=$? 
 +    [ "${rv}" -eq 0 ] && num_success=$((num_success + 1)) 
 +    [ "${rv}" -eq 1 ] && num_failure=$((num_failure + 1)) 
 + 
 +    # Execute external Telegram script if it exists 
 +    if [ -x "/etc/zfs/zed.d/zed-telegram.sh" ]; then 
 +        /etc/zfs/zed.d/zed-telegram.sh "${subject}" "$(cat "${pathname}")"; rv=$? 
 +        [ "${rv}" -eq 0 ] && num_success=$((num_success + 1)) 
 +        [ "${rv}" -eq 1 ] && num_failure=$((num_failure + 1)) 
 +    fi 
 +}
 </code> </code>
 ++++ ++++
  • linux/zfs.1738759587.txt.gz
  • Last modified: 2025/02/05 12:46
  • by admin