G
G
gremlintv22019-12-31 18:07:38
Hard disks
gremlintv2, 2019-12-31 18:07:38

How to configure smartd to send to telegram on centos7?

Please tell me how to configure smartd to send to telegram on centos7
There are a lot of examples on the net, but they are all for ubuntu. For centos, not only are the paths drastically different, it's also not clear how to adapt the tutorials, since the custom scripts for sending notifications are different:

/etc/sysconfig/smartmontools
start_smartd=yes
smartd_opts="--interval=1800"
/etc/smartmontools/smartd.conf
DEVICESCAN -H -m root -M test -M exec /usr/libexec/smartmontools/smartdnotify -n standby,10,q

I left untouched only "-M test" added so that the notification comes at the first start.
I'm stuck on a script:
/usr/libexec/smartmontools/smartdnotify
#! /bin/sh

# Send mail
echo "$SMARTD_MESSAGE" | mail -s "$SMARTD_FAILTYPE" "$SMARTD_ADDRESS"

# Notify desktop user
MESSAGE="SMART Disk monitor:"
case "$SMARTD_FAILTYPE" in
    "EmailTest"|"Health"|"Temperature"|"Usage")
        ;;
    *)
#       "CurrentPendingSector",       // 10
#       "OfflineUncorrectableSector", // 11
#       "FailedReadSmartErrorLog",    // 7
#       "ErrorCount",                 // 4
#       "FailedReadSmartData",        // 6
#       "FailedHealthCheck",          // 5
#       "FailedOpenDevice",           // 9
#       "SelfTest",                   // 3
#       "FailedReadSmartSelfTestLog", // 8
      exit 0
esac

# direct write to terminals, do not use 'wall', because we don't want its ugly header
for t in $(who | awk '{ print $2; }' | grep -e '^tty' -e '^pts/')
do
  echo "$MESSAGE
$SMARTD_MESSAGE" >/dev/$t 2>/dev/null ||:
done

I don’t understand where it takes all these variables from and how can I modify it to send a message to telegram
To execute custom scripts on Ubuntu, the file is:
/usr/share/smartmontools/smartd-runner

and a folder for the custom scripts themselves:
/etc/smartmontools/run.d/

On centos I found a similar folder:
/etc/smartmontools/smartd_warning.d/

and script
/etc/smartmontools/smartd_warning.sh

in which, it is also not clear how to use custom scripts from smartd_warning.d
Please help if you had experience with this. I can figure it out but it will take more time).
With the very sending to telegrams, everything is clear
But how to use your custom script from /etc/smartmontools/smartd_warning.d/ is not quite
Happy New Year everyone!
;)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question