From 16a7d6eaa426b843c6d9e66b422b4e8cdc2bfe75 Mon Sep 17 00:00:00 2001 From: John Pickup Date: Mon, 26 Jun 2023 19:46:50 +0100 Subject: [PATCH] watcher --- kiln-controller.py | 7 +++++-- watcher.py | 6 ++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/kiln-controller.py b/kiln-controller.py index e8911c7..0c68f1e 100755 --- a/kiln-controller.py +++ b/kiln-controller.py @@ -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'] diff --git a/watcher.py b/watcher.py index 513ca85..1aac04f 100755 --- a/watcher.py +++ b/watcher.py @@ -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 )