Add 'local checks/livestatusstats.py'

monitor some livestsatus stats, not sure it is completely right ..
This commit is contained in:
Marius Pana 2023-09-16 06:53:17 +00:00
parent bb424f90fe
commit 44aa214b85

View File

@ -0,0 +1,17 @@
#!/usr/bin/env python
with open("/opt/omd/sites/<SITENAME>/var/log/liveproxyd.state") as f:
out = {}
for line in f:
if line.strip().startswith('['):
sitename = line
if line.strip().startswith('Channels'):
tmp = []
for line in f:
if line.strip().startswith("Clients"):
out[sitename] = tmp
break
tmp.append(line)
for k,v in out.items():
print("0 lp-{s} total={t};;|ready={r};;|busy={b};;|heartbeat={h};; {s} site livestatus channel states").format(s=k.strip()[1:-1],r=sum('ready' in s for s in v),b=sum('busy' in s for s in v),h=sum('heartbeat' in s for s in v),t=len(v))