mirror of
https://github.com/scylladb/scylladb.git
synced 2026-06-03 05:26:58 +00:00
tools/scyllatop/prometheus.py:3:1: F401 'sys' imported but unused tools/scyllatop/prometheus.py:7:1: E302 expected 2 blank lines, found 1 tools/scyllatop/prometheus.py:12:5: E301 expected 1 blank line, found 0 tools/scyllatop/prometheus.py:17:1: W293 blank line contains whitespace tools/scyllatop/prometheus.py:22:82: E225 missing whitespace around operator Signed-off-by: Alexys Jacob <ultrabug@gentoo.org> Message-Id: <20180914110847.1862-1-ultrabug@gentoo.org>
27 lines
792 B
Python
Executable File
27 lines
792 B
Python
Executable File
#! /usr/bin/python
|
|
|
|
import urllib2
|
|
import re
|
|
|
|
|
|
class Prometheus(object):
|
|
_FIRST_LINE_PATTERN = re.compile('^(?P<lines>\d+)')
|
|
_METRIC_INFO_PATTERN = re.compile('^(?P<key>.+) (?P<value>[^ ]+)[ ]*$')
|
|
_METRIC_DISCOVER_PATTERN = re.compile('^(?P<metric>[^#].+) (?P<value>[^ ]+)[ ]*$')
|
|
_METRIC_DISCOVER_PATTERN_WITH_HELP = re.compile('^# HELP (?P<metric>[^ ]+)(?P<help>.*)$')
|
|
|
|
def __init__(self, host):
|
|
self._host = host
|
|
|
|
def read_metrics(self):
|
|
return urllib2.urlopen(self._host).readlines()
|
|
|
|
def get_metrics(self):
|
|
return self.read_metrics()
|
|
|
|
def query_val(self, val):
|
|
return [l for l in self.get_metrics() if (not l.startswith('#')) and (val == "" or re.match(val, l))]
|
|
|
|
def query_list(self):
|
|
return self.get_metrics()
|