watcher
This commit is contained in:
parent
43f23e6569
commit
16a7d6eaa4
@ -58,14 +58,17 @@ def handle_api():
|
|||||||
log.info("/api/stats command received")
|
log.info("/api/stats command received")
|
||||||
if hasattr(oven,'pid'):
|
if hasattr(oven,'pid'):
|
||||||
if hasattr(oven.pid,'pidstats'):
|
if hasattr(oven.pid,'pidstats'):
|
||||||
|
log.info(oven.pid)
|
||||||
return json.dumps(oven.pid.pidstats)
|
return json.dumps(oven.pid.pidstats)
|
||||||
|
else:
|
||||||
|
return "No pidstats"
|
||||||
|
else:
|
||||||
|
return "No pid"
|
||||||
|
|
||||||
|
|
||||||
@app.post('/api')
|
@app.post('/api')
|
||||||
def handle_api():
|
def handle_api():
|
||||||
log.info("/api is alive")
|
log.info("/api is alive")
|
||||||
|
|
||||||
|
|
||||||
# run a kiln schedule
|
# run a kiln schedule
|
||||||
if bottle.request.json['cmd'] == 'run':
|
if bottle.request.json['cmd'] == 'run':
|
||||||
wanted = bottle.request.json['profile']
|
wanted = bottle.request.json['profile']
|
||||||
|
|||||||
@ -27,6 +27,7 @@ class Watcher(object):
|
|||||||
def get_stats(self):
|
def get_stats(self):
|
||||||
try:
|
try:
|
||||||
r = requests.get(self.kiln_url,timeout=1)
|
r = requests.get(self.kiln_url,timeout=1)
|
||||||
|
log.info(r.json())
|
||||||
return r.json()
|
return r.json()
|
||||||
except requests.exceptions.Timeout:
|
except requests.exceptions.Timeout:
|
||||||
log.error("network timeout. check kiln_url and port.")
|
log.error("network timeout. check kiln_url and port.")
|
||||||
@ -35,6 +36,7 @@ class Watcher(object):
|
|||||||
log.error("network connection error. check kiln_url and port.")
|
log.error("network connection error. check kiln_url and port.")
|
||||||
return {}
|
return {}
|
||||||
except:
|
except:
|
||||||
|
log.error("Unknown error")
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
def send_alert(self,msg):
|
def send_alert(self,msg):
|
||||||
@ -76,8 +78,8 @@ class Watcher(object):
|
|||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
||||||
watcher = Watcher(
|
watcher = Watcher(
|
||||||
kiln_url = "http://192.168.1.84:8081/api/stats",
|
kiln_url = "http://192.168.1.176:8081/api/stats",
|
||||||
slack_hook_url = "you must add this",
|
slack_hook_url = "https://hooks.slack.com/services/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",
|
||||||
bad_check_limit = 6,
|
bad_check_limit = 6,
|
||||||
temp_error_limit = 10,
|
temp_error_limit = 10,
|
||||||
sleepfor = 10 )
|
sleepfor = 10 )
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user