Synology-Forum.nl
Firmware => Synology DSM algemeen => Topic gestart door: webbaets op 18 juni 2020, 13:39:01
-
ik vond ergens dat je het commando synodsmnotify kan gebruiken voor het verzenden van notificaties, deze notificaties worden enkel getoond als melding binnen DSM.
Wat is het commando om te verzenden met SMS of MAIL?
Command: synodsmnotify ADMuser "Title" "Your text here."
-
Als ik zoek op welke beschikbare commands 'syno' en 'notif' bevatten d.m.v. de volgende code
compgen -c | grep syno | grep notif
dan krijg ik onderstaande resultaten
- synotifyd
- synodsmnotify
- synonotify
- synotifydutil
- synoappnotify
Zelf heb ik hier nog nooit van gehoord, misschien dat je er wat aan hebt
-
Je zou een test SMS kunnen versturen via DSM en tegelijker via SSH de process list met 'top' in de gaten kunnen houden. Als je niet knippert met je ogen kun je wellicht zien welk commanda wordt gebruikt hiervoor.
-
Gevonden :)
Met de hulp van https://www.beatificabytes.be/send-custom-notifications-from-scripts-running-on-a-synology-new/
Korte uitleg:
- Kopieer /usr/syno/synoman/webman/texts/nld/mails naar een eigen locatie ! /nl/ is de taal van je NAS !
- Stel in 'mails' zelf je bericht en kopieer terug
- Herstart je NAS
- In je config bij melding vind je nu jouw bericht
- In je bash script gebruik volgend commando >> /usr/syno/bin/synonotify tag_event
Wens je gebruik te maken van variablen dan is het
>> /usr/syno/bin/synonotify tag_event "{\"%YOUR_VAR%\":\"$VAR\"}"
-
Sinds DSM 7.0 werkt dit niet meer. De oplossing is om Telegram in je bash-script te plaatsen.
Voorbeeld:
#!/bin/sh
# Read current IP from file
ipfile="/volume1/backup/Syno_Scripting/ip.txt"
read -d $'\x04' ip_current < "$ipfile"
# Telegram Cred's
API_KEY=123456:123456
CHAT_ID=987654
# Grab IP
ip=`curl -silent -L http://checkip.amazonaws.com|tail -n 1`
# Log runtimes
currentDATE=$(date '+%d/%m/%Y %H:%M:%S')
echo "$currentDATE - IP is $ip" >> /volume1/backup/Syno_Scripting/ip_log.txt
# Compare IP
if [ "$ip" != "$ip_current" ]; then
# Notify new IP
curl -s "https://api.telegram.org/bot$API_KEY/sendMessage?chat_id=$CHAT_ID&text=SynoName+-+New+external+IP-address+$ip"
# Set as current IP
echo "$ip" > $ipfile
fi