-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcanhbao_tel.py
38 lines (37 loc) · 867 Bytes
/
canhbao_tel.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
# -*- coding: utf-8 -*-
import requests
# import os
import config
import json
import time
import schedule
from bs4 import BeautifulSoup
import telegram_module
def check_port(host, port):
import socket
host=str(host)
port=int(port)
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.settimeout(10)
result = sock.connect_ex((host,port))
if result == 0:
mess="Ket noi toi "+host+":"+str(port)+" thanh cong"
print(mess)
return [1, mess]
else:
mess="Ket noi toi "+host+":"+str(port)+" that bai"
telegram_module.telegram_send_to(config.chat_canhbao,str(mess),config.api_canhbao)
print(mess)
return [0, mess]
a = "pycon.vn"
b = 443
check_port(a, b)
#schedule.every(10).minutes.do(check_port(a, b))
if __name__ == '__main__':
while True:
try:
check_port(a, b)
#time.sleep(5)
except Exception as value:
print(value)
pass