aboutsummaryrefslogtreecommitdiff
path: root/utils/prometheus-node-exporter-ucode/files/base/meminfo.uc
blob: 3cecb124dcd87a96f5263913b94088d5c8d1050f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
let f = fs.open("/proc/meminfo");

if (!f)
	return false;

let line;
while (line = nextline(f)) {
	const x = wsplit(line);

	if (length(x) < 2)
		continue;

	if (substr(x[0], -1) != ":")
		continue;

	let name;
	if (substr(x[0], -2) == "):")
		name = replace(substr(x[0], 0, -2), "(", "_");
	else
		name = substr(x[0], 0, -1);

	gauge(`node_memory_${name}_bytes`)
		(null, x[2] == "kB" ? x[1] * 1024 : x[1]);
}