image.png
import os
import time
import requests
PING_RESULT = 0
NETWORK_RESULT = 0
def DisableNetwork():
result = os.system(u"netsh interface set interface 以太网 disable")
if result == 1:
print("disable network card failed")
else:
print("disable network card successfully")
def make_message(msg):
return f'https://sc.ftqq.com/SCU23486T20f48c74769f0c6b72a918fe892307655ab14c6616304.send?text=庞銮先生你好!~&desp={msg}'
def ping():
ip = ['ping 192.168.2.1','ping 192.168.2.2','ping 192.168.2.3',
'ping 192.168.2.4','ping 192.168.2.5']
for i in ip:
result = os.system(i)
# result = os.system(u"ping www.baidu.com -n 3")
if result == 0:
print(i+"网络正常")
else:
requests.post(make_message(i+'出现了网络故障'))
print(i+"网络故障")
return result
if __name__ == '__main__':
while True:
PING_RESULT = ping()
if PING_RESULT == 0:
time.sleep(20)
else:
time.sleep(10)
网友评论