7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/tnw/metrics/parsers/proc_meminfo.rb', line 7
def self.parse(output)
values = output.each_line.to_h do |line|
key, value = line.split(":", 2)
[ key, value.to_s.split.first ]
end
total = kibibytes(values, "MemTotal")
available = kibibytes(values, "MemAvailable")
raise ParseError, "/proc/meminfo reports available memory above total memory" if available > total
{
total_bytes: total,
used_bytes: total - available,
available_bytes: available
}
end
|