From 16f575502f8fce2141f024418265f992c563831c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rub=C3=A9n=20Bustos?=
Date: Tue, 27 Aug 2024 15:27:13 +0200
Subject: [PATCH] Update tinyproxy_exporter to parse tinyproxy 1.11.2 stats'
---
tinyproxy_exporter | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/tinyproxy_exporter b/tinyproxy_exporter
index 5016553..c0292e9 100755
--- a/tinyproxy_exporter
+++ b/tinyproxy_exporter
@@ -19,22 +19,26 @@ class TinyproxyCollector(object):
handler = urllib.request.ProxyHandler({'http': self.tinyproxy})
opener = urllib.request.build_opener(handler)
urllib.request.install_opener(opener)
- response = urllib.request.urlopen('http://{0}'.format(self.stathost))
+ response = urllib.request.urlopen(f'http://{self.stathost}')
+ content = response.read().decode('utf-8')
+
+ # Update regex to match the new HTML structure
values = [
- float(x) for x in re.findall(
- b'(?:| |: )(\d+)(?: | |
|\n
)', response.read())
+ int(x) for x in re.findall(
+ r'(\d+) | ', content)
]
+
yield GaugeMetricFamily('tinyproxy_connections_open',
'Number of open connections', values[0])
- yield CounterMetricFamily('tinyproxy_requests_total',
- 'Number of requests', values[1])
yield CounterMetricFamily('tinyproxy_connections_bad_total',
- 'Number of bad connections', values[2])
+ 'Number of bad connections', values[1])
yield CounterMetricFamily('tinyproxy_connections_denied_total',
- 'Number of denied connections', values[3])
+ 'Number of denied connections', values[2])
yield CounterMetricFamily(
'tinyproxy_connections_refused_total',
- 'Number of refused connections due to high load', values[4])
+ 'Number of refused connections due to high load', values[3])
+ yield CounterMetricFamily('tinyproxy_requests_total',
+ 'Number of requests', values[4])
def parse_args():