From 47fe0058895d5450e3d0db861fe998bab295dd06 Mon Sep 17 00:00:00 2001 From: Cyber MacGeddon Date: Sun, 29 Sep 2024 23:48:07 +0100 Subject: [PATCH] New script, gets processor state using prometheus --- scripts/tg-processor-state | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 scripts/tg-processor-state diff --git a/scripts/tg-processor-state b/scripts/tg-processor-state new file mode 100755 index 00000000..f9945aac --- /dev/null +++ b/scripts/tg-processor-state @@ -0,0 +1,24 @@ +#!/usr/bin/env python3 + +import requests +import tabulate + +url = 'http://localhost:9090/api/v1/query?query=processor_state%7Bprocessor_state%3D%22running%22%7D' + +resp = requests.get(url) + +obj = resp.json() + +tbl = [ + [ + m["metric"]["instance"], + "running" if int(m["value"][1]) > 0 else "down" + ] + for m in obj["data"]["result"] +] + +print(tabulate.tabulate( + tbl, tablefmt="pretty", headers=["processor", "state"], + stralign="left" +)) +