mirror of
https://github.com/ClusterCockpit/cc-metric-collector.git
synced 2024-11-10 04:27:25 +01:00
d98076c792
* DiskstatCollector: cast part_max_used metric to int * Add uint types to GangliaSink and LibgangliaSink * Use new sink instances to allow multiple of same sink type * Update sink README and SampleSink * Use new receiver instances to allow multiple of same receiver type * Fix metric scope in likwid configuration script * Mention likwid config script in LikwidCollector README * Refactor: Embed Init() into New() function * Refactor: Embed Init() into New() function * Fix: MetricReceiver uses uninitialized values, when initialization fails * Use Ganglia configuration (#44) * Copy all metric configurations from original Ganglia code * Use metric configurations from Ganglia for some metrics * Format value string also for known metrics * Numa-aware memstat collector (#45) * Add samples for collectors, sinks and receivers * Ping InfluxDB server after connecting to recognize faulty connections * Add sink for Prometheus monitoring system (#46) * Add sink for Prometheus monitoring system * Add prometheus sink to README * Add scraper for Prometheus clients (#47) Co-authored-by: Holger Obermaier <holgerob@gmx.de> Co-authored-by: Holger Obermaier <40787752+ho-ob@users.noreply.github.com>
84 lines
2.4 KiB
Python
Executable File
84 lines
2.4 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import os, os.path, sys, getopt, re, json
|
|
|
|
def which(cmd):
|
|
ospath = os.environ.get("PATH", "")
|
|
for p in ospath.split(":"):
|
|
testcmd = os.path.join(p, cmd)
|
|
if os.access(testcmd, os.X_OK):
|
|
return testcmd
|
|
return None
|
|
|
|
def group_to_json(groupfile):
|
|
gdata = []
|
|
with open(groupfile, "r") as fp:
|
|
gdata = fp.read().strip().split("\n")
|
|
events = {}
|
|
metrics = []
|
|
parse_events = False
|
|
parse_metrics = False
|
|
for line in gdata:
|
|
if line == "EVENTSET":
|
|
parse_events = True
|
|
parse_metrics = False
|
|
continue
|
|
if line == "METRICS":
|
|
parse_events = False
|
|
parse_metrics = True
|
|
continue
|
|
if len(line) == 0 or line.startswith("SHORT") or line == "LONG":
|
|
parse_events = False
|
|
parse_metrics = False
|
|
continue
|
|
if parse_events:
|
|
m = re.match("([\w\d]+)\s+([\w\d_]+)", line)
|
|
if m:
|
|
events[m.group(1)] = m.group(2)
|
|
if parse_metrics:
|
|
llist = re.split("\s+", line)
|
|
calc = llist[-1]
|
|
metric = " ".join(llist[:-1])
|
|
scope = "cpu"
|
|
if "BOX" in calc:
|
|
scope = "socket"
|
|
if "PWR" in calc:
|
|
scope = "socket"
|
|
|
|
m = {"name" : metric, "calc": calc, "scope" : scope, "publish" : True}
|
|
metrics.append(m)
|
|
return {"events" : events, "metrics" : metrics}
|
|
|
|
if len(sys.argv) != 3:
|
|
print("Usage: $0 <likwid-arch> <group-name>")
|
|
sys.exit(1)
|
|
|
|
|
|
arch = sys.argv[1]
|
|
group = sys.argv[2]
|
|
|
|
ltopo = which("likwid-topology")
|
|
if not ltopo:
|
|
print("Cannot find LIKWID installation. Please add LIKWID bin folder to your PATH.")
|
|
sys.exit(1)
|
|
|
|
bindir = os.path.dirname(ltopo)
|
|
|
|
groupdir = os.path.normpath(os.path.join(bindir, "../share/likwid/perfgroups"))
|
|
if not os.path.exists(groupdir):
|
|
print("Cannot find LIKWID performance groups in default install location")
|
|
sys.exit(1)
|
|
|
|
archdir = os.path.join(groupdir, arch)
|
|
if not os.path.exists(archdir):
|
|
print("Cannot find LIKWID performance groups for architecture {}".format(arch))
|
|
sys.exit(1)
|
|
|
|
groupfile = os.path.join(archdir, "{}.txt".format(group))
|
|
if not os.path.exists(groupfile):
|
|
print("Cannot find LIKWID performance group {} for architecture {}".format(group, arch))
|
|
sys.exit(1)
|
|
|
|
gdata = group_to_json(groupfile)
|
|
print(json.dumps(gdata, sort_keys=True, indent=2))
|