Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions connect.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import paramiko, sys


def connect_device():


host = "10.16.50.61"
port = 22
username = "root"
password = "ya_lublu_delat_karasa_311"

command = "tail -n 10 /userdata/log/ace_device.log"

print()

ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(host, port, username, password)

with open('filename.txt', 'w') as f:
sys.stdout = f
stdin, stdout, stderr = ssh.exec_command(command)
lines = stdout.readlines()
print(lines)

if __name__ == "__main__":
connect_device()
1 change: 1 addition & 0 deletions filename.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
['2021-05-26 09:40:05.932 DEBUG [10614] [BestShotObserver::estimateFrame@70] RGB Frame id: 329941, Track id: 35, size: 384x640\n', '2021-05-26 09:40:05.945 DEBUG [10614] [FaceSizeEstimator::estimate@32] Frame id: 329941, face size: 34 >= 80, FAIL\n', '2021-05-26 09:40:05.993 DEBUG [10614] [BestShotObserver::bestShot@42] BestShotObserver::bestShot Track id: 35, Frame id:329942, bbox: {x:160,y:359,w:34,h:47}\n', '2021-05-26 09:40:05.994 DEBUG [10614] [BestShotObserver::estimateFrame@70] RGB Frame id: 329942, Track id: 35, size: 384x640\n', '2021-05-26 09:40:06.009 DEBUG [10614] [FaceSizeEstimator::estimate@32] Frame id: 329942, face size: 34 >= 80, FAIL\n', '2021-05-26 09:40:06.009 DEBUG [10614] [BestShotObserver::bestShot@42] BestShotObserver::bestShot Track id: 35, Frame id:329943, bbox: {x:160,y:359,w:34,h:46}\n', '2021-05-26 09:40:06.009 DEBUG [10614] [BestShotObserver::estimateFrame@70] RGB Frame id: 329943, Track id: 35, size: 384x640\n', '2021-05-26 09:40:06.029 DEBUG [10614] [FaceSizeEstimator::estimate@32] Frame id: 329943, face size: 34 >= 80, FAIL\n', '2021-05-26 09:40:06.029 DEBUG [10614] [BestShotObserver::bestShot@42] BestShotObserver::bestShot Track id: 35, Frame id:329944, bbox: {x:160,y:361,w:34,h:44}\n', '2021-05-26 09:40:06.030 DEBUG [10614] [BestShotObserver::estimateFrame@70] RGB Frame id: 329944, Track id: 35, size: 384x640\n']
27 changes: 15 additions & 12 deletions get_json.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import requests, json, time

from connect import connect_device

def check_status():
while True:
try:
content = requests.get("https://10.16.8.90/monitoring/", verify=False, timeout=10)
content = requests.get("https://10.16.8.87/monitoring/", verify=False, timeout=20)
except:
telegram_bot_sendtext('server not resolve')

Expand All @@ -19,24 +19,27 @@ def check_status():
service_name = service_status[0]
srv_status = service_status[1]['status']


if srv_status != 1:
telegram_bot_sendtext('Service Down - {0}'.format(service_name))

telegram_bot_sendtext('Service Core Down - {0}'.format(service_name))

for device in devices_list.items():
dvc_name = device[0]
#print(dvc_name)
dvc_status = device[1]['status']
dvc_services = device[1]['subservices']
print(device[1]['status'])
dvc_services = json.dumps(device[1]['subservices']).replace("_", "")
print(dvc_services)

#тут изменить обратно на правильный статус 2
if dvc_status == 1:
#save log to file
connect_device()
print(telegram_bot_sendtext('Device services has Problem - {0} {1}'.format(dvc_name, dvc_services)))

if dvc_status == 2:
telegram_bot_sendtext('Device services has Problem - {0}-{1}'.format(dvc_name, dvc_services))
elif dvc_status == 0:
telegram_bot_sendtext('Device Down - {0}'.format(dvc_name))
telegram_bot_sendtext('Device Down - {0}'.format(dvc_name))

else:
pass
pass
time.sleep(10)


Expand All @@ -52,4 +55,4 @@ def telegram_bot_sendtext(bot_message):


if __name__ == "__main__":
check_status()
check_status()
14 changes: 14 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import telegram

def send_msg(text):
token = '1400084494:AAGJX-WtbA6eJy0PAwe7u2Jtsnzp7bpSuXU'
chat_id = '-381749129'
bot = telegram.Bot(token=token)
for i in text:
bot.sendMessage(chat_id=chat_id, text=i)

new_list = []
with open("filename.txt", 'r', encoding="utf-8") as file:
new_list = file.read()
for i in new_list:
send_msg(i)