Synology + Telegram Уведомление
Привет всем, тема довольно старая но все равно хотел написать). 1 дня разбирался по поводу темы..
Смысл в том что Уведомление Приходящий от Системы приходил от Телеграмм БОтА, вроде убодно. но я живу в России тут Телегу забронировали, но делал ради интереса. добавил VPN на сервер (NAS) как основной шлюз (мой провайдер блокирует Telegram) и так начнем.. (оговорю с я не мастер писать правильно)
Создадим Telegram БОта
Находим папу ботов) @BotFather
Отлично мы получили token to access the HTTP API:
Далее просто добавляем его в диалоги чтоб сохранить бота DSM_NASbot
Теперь нам нужно перейти к нашему веб-браузеру.
https://api.telegram.org/bot<<<$TOKEN>>>/getUpdates в адресную строку. <<<$TOKEN>>>- ваш token to access the HTTP API
примерно должно получится так.
вставляем в строчку делаем запрос.
У меня так получилось, все верно ВАШ провайдер блокирует телеграм, но я использовал VPN (загуглите. как сделать). должно получиться. так.
Synology DSM 6.x: Telegram Bot Alerts
If you are like me, and have your entire life on Telegram, whether it be for work or for personal uses, you’d want to have your NAS alerts all in Telegram too!
After some digging, I realized that there are three alert systems, Email, SMS and Push Service. The former two alert systems can be configured to be sent through a custom provider, and thus both can be used to alert your Telegram account of any changes!
This has been tested on my Synology DS918+ with DSM ver. 6.2.2, but should practically work on any version as long as you have these settings in Control Panel -> Notifications -> Email, SMS, Push Service
You will also have to ensure your notifications are enabled for both Email and SMS in the Advanced tab, then click Apply!
Setting up your Bot
Firstly, you’ll have to talk to BotFather on Telegram and commence with /start .
Type /newbot , then name the Bot however you like. You will then have to create a username for the Bot.
After the Bot has been created, you will get a token on the Bot for HTTP API access. Keep this handy.
Click on the link that will open a chat with your Bot, click Start and then spam the chat a bit. Then open this in your browser (after replacing it with your token):
Following the instructions, click on that link and look for your ID where you’d like to send updates. Usually we do it on our own chats, but you can do it on a channel or a group. An easier way is to figure out what your ID is on Telegram by talking to Rose, my friend’s bot, and typing /id to get your chat ID.
Now that you have both chat ID and the bot token, you have all you need to continue on this guide!
Setting up SMS to Telegram notifications
Navigate to Control Panel -> Notifications -> SMS and Enable SMS Notifications.
Click on Add SMS service provider with the provider name of Telegram .
Other than the bracketed variables, do not change anything else.
HTTP Method we will keep as GET, then Press Next, then Next again (to skip Edit HTTP request Header)
Finally, click Apply.
If everything was done correctly, upon clicking Send a test SMS Message will send it directly to your Telegram inbox!
Setting up Email to Telegram notifications
Navigate to Control Panel -> Notifications -> Email and Enable Email Notifications.
For recipient, just type in any email.
For Service provider, click Custom SMTP Server and then SMTP server as 172.17.0.2 with Server Port 2525 .
(OPTIONAL) 172.17.0.2 is the default server port if you have one Docker container (setting it up for the first time). If you have more than one Docker container, you MAY have to find the IP of the Container using this command in an SSH terminal on your NAS after finishing this guide:
We will now have to install Docker, from the Package Center.
Open Docker, then on the left tabs, click Image.
Click on Add -> Add from URL then type this in:
After it finishes loading, you should see something like this:
Double click it to begin configuring the container we will be creating.
You want this Docker container to start whenever you restart your NAS. So, ensure you have Enable auto-restart checked. You can rename your container to whatever you want, I picked telegram_notifier .
Click on the Environment tab.
Add these variables into your Environment window:
You can now run the Docker container to automatically forward emails sent above to your Telegram! Test this by going back to Control Panel -> Notifications -> Email and clicking Send a test email.
If successful, this would be what you will see:
Setting up Download Station to Telegram Notifications
This may be a bit trivial, but it worked for me. You will have to click the Person icon in the status bar, and then click Personal.
You will then have to navigate the Email Account tab and click Add. Choose Customize and then press Next. Fill in the window with this information:
You should now be able to go back to Download Station -> Settings -> Notification and Enable email notifications by selecting your created profile. Clicking Send a test message will also work too!
Congratulations! You’ve got both Email and SMS notifications set for your NAS!
One thing to note, I have set up both SMS and Email as when the NAS boots up, it will still send me a notification that it is connected to my UPS. The Docker container needs time to boot, this is where the SMS notification shines.
Уведомления Telegram от Synology NAS
Я проверил этот способ на DSM 6.1.7-15284, установленном на моем Intel Nuc. Но все будет работать и на оригинальном оборудовании от Synology.
Инструкция подразумевает, что у вас уже есть бот, созданный через @BotFather и вы уже пользуетесь уведомлениями Телеграм от Domoticz или Home Assistant. Или из других систем. Если нет, то я писал о создании бота в этой статье:
В Synology DSM заходим в Панель Управления > Уведомления
В открывшемся окне ставим галочку на Включить уведомления по SMS
Жмем кнопку Добавить провайдера службы SMS и заполняем поля.
Произвольное Имя провайдера, например Telegram и URL SMS вида:
где 123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11 это токен нашего бота, а -1234567890123 это id вашего чата, куда нужно отправлять уведомления.
Мой чат с — перед цифрами, так как это чат группы.
Жмем Далее и приводим значения к следующему виду:
chat_id=-1234567890123 в положение Другое
text=Hello+World в положение Содержимое сообщения
user=User в положение Имя пользователя
password=Password в положение Пароль
to=12345678 в положение Номер телефона
И жмем Применить
Теперь заполняем остальные графы:
Имя пользователя: User
Пароль: Password
Подтвердите пароль: Password
Основной номер телефона: 555 — 5555555
И жмем Применить
Прокси настраивается в Панель Управления > Сеть
Проверяем работоспособность кнопкой Отправить тестовое сообщение SMS