PROGRAM /etc/mdadm/mdadm_events.sh
#!/bin/bash
event=$1
device=$2
function sendtlg {
TLGAPI="161995xxxxxxxxVnU-KbpNISYxxxxxxxxWuCt-tdxxxxxxCU"
TLGID="18xxxxxxx"
curl -s -d "chat_id=$TLGID&disable_web_page_preview=1&text=$MESSAGE" https://api.telegram.org/bot$TLGAPI/sendMessage > /dev/null
}
if [ $event == "Fail" ];then
MESSAGE="$(date +"%Y-%m-%d %H:%M:%S"): A failure has been detected on device $device!" sendtlg unset MESSAGE
elif [ $event == "FailSpare" ]; then
MESSAGE="$(date +"%Y-%m-%d %H:%M:%S"): A failure has been detected on spare device $device!" sendtlg unset MESSAGE
elif [ $event == "DegradedArray" ]; then
MESSAGE="$(date +"%Y-%m-%d %H:%M:%S"): A Degraded Array has been detected on device $device!" sendtlg unset MESSAGE
elif [ $event == "TestMessage" ]; then
MESSAGE="$(date +"%Y-%m-%d %H:%M:%S"): A Test Message has been generated on device $device" sendtlg unset MESSAGE
else
MESSAGE="$(date +"%Y-%m-%d %H:%M:%S"): Device $device. Unknown events..." sendtlg unset MESSAGE
fi