anselal / antminer-monitor

Cryptocurrency ASIC mining hardware monitor using a simple web interface
GNU General Public License v3.0
228 stars 145 forks source link

Telegram alert #101

Closed imar4ik closed 1 year ago

imar4ik commented 6 years ago

If you nedd alert on telegram

pip install telegram-send

in antminer.py 19# import telegram_send

128# if max(temps) >=90:
                    telegram_send.send(["Temp! ")])
anselal commented 6 years ago

Thanks but this needs a lot of configuration on the client.

anselal commented 6 years ago

Could you provide a more detailed example of how to use this module, eg. how to define the recipient ?

Do you need a KEY to send messages to telegram ?

shotaatosh commented 6 years ago

this will save so many time and solve so many issues at once would be nice to hear some details

anselal commented 6 years ago

@imar4ik anything ???

imar4ik commented 6 years ago

you need cread telegram bot @BotFather /newbot "name_bot"

you get

Use this token to access the HTTP API: 442932741:AAGIBZeHev3I5d0S_cWszEWDDSAFA8Ft9uac

pip install telegram-send
telegram-send --configure
Talk with the BotFather on Telegram (https://telegram.me/BotFather), create a bot and insert the token
[35m>442932741:AAGIBZeHev3I5d0S_cWszEWDDSAFA8Ft9uac

Please add "name_bot" on Telegram (https://telegram.me/name_bot) and send it the password: 43165

go https://telegram.me/name_bot

START 43165

imar4ik commented 6 years ago

Sorry for the delay :-(

anselal commented 6 years ago

Will check it out.

thnx

shadowmatrix369 commented 6 years ago

I love the idea but I can't get the line 128 addition without the software crashing. Can someone please give a detailed step by step on how to get this running or how to get these error messages sent to an email address? Thank you Anselal for giving us this great software to help us with our mining needs.

anselal commented 6 years ago

@shadowmatrix369 You are very welcome. If you find a way to make this work I would appreciate a code snippet here or a pull request ;)

velikovmartin commented 6 years ago

you need cread telegram bot @Botfather /newbot "name_bot"

you get

Use this token to access the HTTP API: 442932741:AAGIBZeHev3I5d0S_cWszEWDDSAFA8Ft9uac

pip install telegram-send
telegram-send --configure
Talk with the BotFather on Telegram (https://telegram.me/BotFather), create a bot and insert the token
[35m>442932741:AAGIBZeHev3I5d0S_cWszEWDDSAFA8Ft9uac

Please add "name_bot" on Telegram (https://telegram.me/name_bot) and send it the password: 43165

go https://telegram.me/name_bot

START 43165

It is working. 1) download and register telegram client (https://telegram.org) 2) send a message to botfather (https://telegram.me/botfather) with text /newbot and after that you follow the instructions and create your bot (ex.: antminer-moitor_bot) and this will give you a token like in the @imar4ik post. 3) you have to find your bot from telegram search and text it with /start 4) then open your antminer-monitor application and in console pip install telegram-send 5) then telegram-send --configure and here it will show you a code (in my case 5 digit) to send it to the bot in telegram. 6) you will receive such kind of message 🎊 Congratulations User! 🎊 telegram-send is now ready for use! 7) in antminer.py, in the beginning of the file where the other imports take place you should put this code: import telegram_send 8) and finally you can use it in the antminer.py if cases. an examle: if Xs > 0: telegram_send.send(["Xs > 0"])

shadowmatrix369 commented 6 years ago

Thank you for your help and response. I will give this a try tomorrow.

On Wed, Sep 26, 2018, 5:44 AM blindman notifications@github.com wrote:

you need cread telegram bot @Botfather https://github.com/Botfather /newbot "name_bot"

you get

Use this token to access the HTTP API: 442932741:AAGIBZeHev3I5d0S_cWszEWDDSAFA8Ft9uac

pip install telegram-send telegram-send --configure

Talk with the BotFather on Telegram (https://telegram.me/BotFather), create a bot and insert the token [35m>442932741:AAGIBZeHev3I5d0S_cWszEWDDSAFA8Ft9uac

Please add "name_bot" on Telegram (https://telegram.me/name_bot) and send it the password: 43165

go https://telegram.me/name_bot

START 43165

It is working.

  1. download and register telegram client (https://telegram.org)
  2. send a message to botfather (https://telegram.me/botfather) with text /newbot and after that you follow the instructions and create your bot (ex.: antminer-moitor_bot) and this will give you a token like in the @imar4ik https://github.com/imar4ik post.
  3. you have to find your bot from telegram search and text it with /start
  4. then pip install telegram-send
  5. the telegram-send --configure and here it will show you a code (in my case 5 digit) to send it to the bot in telegram.
  6. you will receive such kind of message 🎊 Congratulations User! 🎊 telegram-send is now ready for use!
  7. in antminer.py, in the beginning of the file where the other imports take place you should put this code: import telegram_send
  8. and finally you can use it in the antminer.py if cases. an examle: if Xs > 0: telegram_send.send(["Xs > 0"])

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/anselal/antminer-monitor/issues/101#issuecomment-424701100, or mute the thread https://github.com/notifications/unsubscribe-auth/AlKMCLvtkWpeKzdB3255xIoZaSBnFGrdks5ue3aVgaJpZM4T3ANh .

shadowmatrix369 commented 6 years ago

This works flawlessly thank you for the help. I am reworking the error flash messaging to direct the if statements about temperatures, chip failures to the bot and so far have the bot producing ip address for each unit in the monitor that is having an issue. This gives access to whomever is allowed to communicate with the bot a message that links each unit with issues as well as shows anyone checking the bot that there is an issue.

anselal commented 6 years ago

Another sample at https://www.marcodena.it/blog/telegram-logging-handler-for-python-java-bash/

smwbev commented 1 year ago

It is working.

PS C:\monitor> telegram-send --configure
Traceback (most recent call last):
  File "c:\users\owl_dv\appdata\local\programs\python\python38\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\users\owl_dv\appdata\local\programs\python\python38\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\owl_dv\AppData\Local\Programs\Python\Python38\Scripts\telegram-send.exe\__main__.py", line 4, in <module>
  File "c:\users\owl_dv\appdata\local\programs\python\python38\lib\site-packages\telegram_send\__init__.py", line 2, in <module>
    from .telegram_send import configure, send
  File "c:\users\owl_dv\appdata\local\programs\python\python38\lib\site-packages\telegram_send\telegram_send.py", line 33, in <module>
    from telegram.constants import MAX_MESSAGE_LENGTH
ImportError: cannot import name 'MAX_MESSAGE_LENGTH' from 'telegram.constants' (c:\users\owl_dv\appdata\local\programs\python\python38\lib\site-packages\telegram\constants.py)
PS C:\monitor>
anselal commented 1 year ago

Antminer-Monitor does not officially support telegram notifications. Also this seems to be a problem with the telegram library and not with this software

smwbev commented 1 year ago

Antminer-Monitor does not officially support telegram notifications. Also this seems to be a problem with the telegram library and not with this software

Yes, I understand that. That's why I turn to the professionals in the community.

I would like some kind of notification. In the mail or by telegram. But in telegram, of course, it is preferable and more timely notification.

anselal commented 1 year ago

Antminer-Monitor does not officially support telegram notifications. Also this seems to be a problem with the telegram library and not with this software

Yes, I understand that. That's why I turn to the professionals in the community.

I would like some kind of notification. In the mail or by telegram. But in telegram, of course, it is preferable and more timely notification.

I will see what I can do. Which version of the library are you using?

smwbev commented 1 year ago

I will see what I can do. Which version of the library are you using?

Thank you so much.

PS C:\monitor> pip install telegram-send Requirement already satisfied: telegram-send in c:\users\owl_dv\appdata\local\programs\python\python38\lib\site-packages (0.34) Requirement already satisfied: colorama in c:\users\owl_dv\appdata\local\programs\python\python38\lib\site-packages (from telegram-send) (0.4.6) Requirement already satisfied: appdirs in c:\users\owl_dv\appdata\local\programs\python\python38\lib\site-packages (from telegram-send) (1.4.4) Requirement already satisfied: python-telegram-bot>=13.0 in c:\users\owl_dv\appdata\local\programs\python\python38\lib\site-packages (from telegram-send) (20.1) Requirement already satisfied: httpx[http2]~=0.23.3 in c:\users\owl_dv\appdata\local\programs\python\python38\lib\site-packages (from python-telegram-bot>=13.0->telegram-send) (0.23.3) Requirement already satisfied: certifi in c:\users\owl_dv\appdata\local\programs\python\python38\lib\site-packages (from httpx[http2]~=0.23.3->python-telegram-bot>=13.0->telegram-send) (2022.12.7) Requirement already satisfied: rfc3986[idna2008]<2,>=1.3 in c:\users\owl_dv\appdata\local\programs\python\python38\lib\site-packages (from httpx[http2]~=0.23.3->python-telegram-bot>=13.0->telegram-send) (1.5.0) Requirement already satisfied: sniffio in c:\users\owl_dv\appdata\local\programs\python\python38\lib\site-packages (from httpx[http2]~=0.23.3->python-telegram-bot>=13.0->telegram-send) (1.3.0) Requirement already satisfied: httpcore<0.17.0,>=0.15.0 in c:\users\owl_dv\appdata\local\programs\python\python38\lib\site-packages (from httpx[http2]~=0.23.3->python-telegram-bot>=13.0->telegram-send) (0.16.3) Requirement already satisfied: h2<5,>=3 in c:\users\owl_dv\appdata\local\programs\python\python38\lib\site-packages (from httpx[http2]~=0.23.3->python-telegram-bot>=13.0->telegram-send) (4.1.0) Requirement already satisfied: hpack<5,>=4.0 in c:\users\owl_dv\appdata\local\programs\python\python38\lib\site-packages (from h2<5,>=3->httpx[http2]~=0.23.3->python-telegram-bot>=13.0->telegram-send) (4.0.0) Requirement already satisfied: hyperframe<7,>=6.0 in c:\users\owl_dv\appdata\local\programs\python\python38\lib\site-packages (from h2<5,>=3->httpx[http2]~=0.23.3->python-telegram-bot>=13.0->telegram-send) (6.0.1) Requirement already satisfied: h11<0.15,>=0.13 in c:\users\owl_dv\appdata\local\programs\python\python38\lib\site-packages (from httpcore<0.17.0,>=0.15.0->httpx[http2]~=0.23.3->python-telegram-bot>=13.0->telegram-send) (0.14.0) Requirement already satisfied: anyio<5.0,>=3.0 in c:\users\owl_dv\appdata\local\programs\python\python38\lib\site-packages (from httpcore<0.17.0,>=0.15.0->httpx[http2]~=0.23.3->python-telegram-bot>=13.0->telegram-send) (3.6.2) Requirement already satisfied: idna>=2.8 in c:\users\owl_dv\appdata\local\programs\python\python38\lib\site-packages (from anyio<5.0,>=3.0->httpcore<0.17.0,>=0.15.0->httpx[http2]~=0.23.3->python-telegram-bot>=13.0->telegram-send) (3.4)

anselal commented 1 year ago

This is how you do it with the requests library

pip install requests
import requests
payload = {"chat_id": <YOUR_CHAT_ID>, "text": "This is a test message sent via requests"}
token = "<YOUR_BOT_TOKEN>"
requests.post(url=f"https://api.telegram.org/bot{token}/sendMessage", data=payload)

To find your chat id you can search for @myidbot in telegram, then send /start and /getid

smwbev commented 1 year ago

This is how you do it with the requests library

Thank you very much. 🙏 This option works. You work wonders. This should definitely be added to the repository. It's a super option.

Now where should I add these alarms ?🙀

import requests payload = {"chat_id": , "text": "Attention !!! Temperature on Miner IP + TEMP_INFO } token = ""

if max(temps) >=75: requests.post(url=f "https://api.telegram.org/bot{token}/sendMessage", data=payload)

And

import requests payload = {"chat_id": , "text": "Attention !!! MINER_IP Offline} token = ""

if miner(online) =off: requests.post(url=f "https://api.telegram.org/bot{token}/sendMessage", data=payload)

Thank you so much again for all your help.

smwbev commented 1 year ago

This is how you do it with the requests library

image

anselal commented 1 year ago

This is how you do it with the requests library

image

Glad it worked out. I don't have access to any miners anymore thus I cannot test the software for bugs and/or new features

smwbev commented 1 year ago

Glad it worked out. I don't have access to any miners anymore thus I cannot test the software for bugs and/or new features

Can you please tell me where in your code can add triggers that I wrote above. I want to be notified if the temperature is high or if the miner is offline. 🙏 I will test everything and report back ))))

anselal commented 1 year ago

@tehnoconductor I pushed added telegram notifications in my latest commit. I will document it in the next release. Can you check it out and let me know if those work ? You need to add your bot token and chat id to config/settings

anselal commented 1 year ago

@tehnoconductor did you manage to test the latest push ?