Files
zabbix-mining/rebootasic
T

34 lines
1.1 KiB
Python
Raw Normal View History

2019-05-22 15:21:44 +08:00
#!/usr/bin/env python
2020-06-06 11:18:56 +08:00
import socket, httplib, httplib2
2019-05-22 15:21:44 +08:00
import sys
URL = "http://"+sys.argv[1]+"/cgi-bin/reboot.cgi"
2020-06-02 00:25:07 +08:00
USER = sys.argv[2]
2020-11-14 09:42:56 +08:00
USER_DEFAULT = "root"
2020-06-02 00:25:07 +08:00
PASS = sys.argv[3]
2020-11-14 09:42:56 +08:00
PASS_DEFAULT = "root"
2019-05-22 15:21:44 +08:00
2020-06-16 10:48:08 +08:00
h = httplib2.Http(cache=None, timeout=0.5)
2019-05-22 15:21:44 +08:00
h.add_credentials(USER, PASS)
2020-06-06 10:58:08 +08:00
2019-05-22 15:21:44 +08:00
try:
2020-06-06 10:58:08 +08:00
response, content = h.request(URL, "GET", headers={'cache-control':'no-cache'})
if response.status==401:
2020-11-14 09:42:56 +08:00
retry = httplib2.Http(cache=None, timeout=0.5)
retry.add_credentials(USER_DEFAULT, PASS_DEFAULT)
res, con = retry.request(URL, "GET", headers={'cache-control':'no-cache'})
if res.status==500:
print "Change pass, Installed default password"
print "OK"
elif res.status==401:
print "Unauthorized, Wrong PASSWORD"
if response.status==500:
print "OK"
2020-06-06 10:58:08 +08:00
elif response.status==404:
URL = "http://"+sys.argv[1]+"/api/reboot"
response, content = h.request(URL, "GET", headers={'cache-control':'no-cache'})
2020-06-06 10:58:08 +08:00
except httplib2.ServerNotFoundError:
2020-06-06 11:18:56 +08:00
print "HOST is Down"
except (socket.timeout, socket.error, httplib2.HttpLib2Error, httplib.ResponseNotReady):
print "ERROR"