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