Skip to content

Commit 0a23439

Browse files
committed
add xentop text collector script
Signed-off-by: Clemens Hopfer <[email protected]>
1 parent 414fb44 commit 0a23439

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

xentop

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/usr/bin/awk -f
2+
# xentop -i 1 -f -b | ./xentop
3+
4+
function export_metric(metric) {
5+
printf("\n# HELP %s%s %s from xentop\n", namespace, metric, metric_fields[metric]);
6+
printf("# TYPE %s%s gauge\n", namespace, metric);
7+
for (i=0; i < dom_count; i++) {
8+
printf("%s%s{name=\"%s\"} %f\n", namespace, metric, metrics["name," i], metrics[metric "," i]);
9+
}
10+
}
11+
12+
# Fields are Bar separated, with space padding.
13+
BEGIN {
14+
FPAT = "([^ ]+)|(no limit)" # handle "no limit" value corner case
15+
namespace = "node_xentop_";
16+
17+
# map metric names to header, also used for HELP.
18+
metric_fields["cpu_secs"] = "CPU(sec)"
19+
metric_fields["mem_kbytes"] = "MEM(k)"
20+
metric_fields["mem_percent"] = "MEM(%)"
21+
metric_fields["mem_max_kbytes"] = "MAXMEM(k)"
22+
metric_fields["maxmem_percent"] = "MAXMEM(%)"
23+
metric_fields["vcpus"] = "VCPUS"
24+
metric_fields["nets"] = "NETS"
25+
metric_fields["network_tx_kbytes"] = "NETTX(k)"
26+
metric_fields["network_rx_kbytes"] = "NETRX(k)"
27+
metric_fields["vbds"] = "VBDS"
28+
metric_fields["vbd_oo"] = "VBD_OO"
29+
metric_fields["vbd_rd"] = "VBD_RD"
30+
metric_fields["vbd_wr"] = "VBD_WR"
31+
metric_fields["vbd_rsect"] = "VBD_RSECT"
32+
metric_fields["vbd_wsect"] = "VBD_WSECT"
33+
metric_fields["ssid"] = "SSID"
34+
metric_fields["name"] = "NAME" # used as label
35+
36+
dom_count = 0;
37+
}
38+
39+
{
40+
if (NR == 1) {
41+
# load header field positions
42+
for(i=1; i<=NF; i++) {
43+
for (name in metric_fields) {
44+
if ($i == metric_fields[name] ) { columns[name] = i; }
45+
}
46+
}
47+
} else {
48+
for(metric in columns) {
49+
metrics[metric "," dom_count] = $(columns[metric]);
50+
}
51+
dom_count++;
52+
}
53+
}
54+
55+
END {
56+
for (name in metric_fields) {
57+
if ( name == "name" ) { continue; }
58+
export_metric(name);
59+
}
60+
}

0 commit comments

Comments
 (0)