-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathminer_v2.py
54 lines (45 loc) · 1.44 KB
/
miner_v2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import requests
import datetime
import json
from discord_hooks import Webhook
from twilio.rest import Client
from time import sleep
import os
def tempCheck(temp):
num = '1231231234'
twilioNum = '123456456454'
client = Client("ID", "ID")
client.api.account.messages.create(
to=num,
from_=twilioNum,
body="MINER IS OVER {}DEGREES, CALL {} TO ALERT ME".format(temp,num))
def start_bot():
degree_sign= u'\N{DEGREE SIGN}'
url = 'https://discordapp.com/api/webhooks/123453/12345654'
link = "http://192.xxx.x.xxx:42000/getstat"
r = requests.get(url=link)
data = json.loads(r.text)
uptime = str(datetime.datetime.now()- datetime.datetime.fromtimestamp(int(data['start_time'])))[:-7]
gpuTxt = ""
totalSpeed = 0
totalWatt = 0
for gpu in data['result']:
gpuTxt += "\t{} : {}{}C {}W {}Sol/s\n".format(str(gpu['gpuid']),str(gpu['temperature']),degree_sign,str(gpu['gpu_power_usage']),str(gpu['speed_sps']))
totalSpeed += gpu['gpu_power_usage']
totalWatt += gpu['speed_sps']
if gpu['temperature'] >= 90:
tempCheck(gpu['temperature'])
msgTxt = "```css\n{}Sol/s {}W\n--------------\nServer: {}\nUptime: {}\nGPU's:\n{}\n```".format(str(totalWatt),str(totalSpeed),data['current_server'],str(uptime),gpuTxt)
msg = Webhook(url,msg=msgTxt)
msg.post()
def main():
print("STARTING BOT....")
try:
while True:
start_bot()
sleep(900)
except:
print("ENDING BOT...")
os.system('killall -9 python3')
if __name__ == '__main__':
main()