Used memory as the reverse of available

Signed-off-by: fbt <fbt@fleshless.org>
This commit is contained in:
Jack L. Frost 2018-12-08 12:11:45 +03:00
parent 86982a2f32
commit 62fd3e51db

View File

@ -9,17 +9,17 @@ class ModMemory < Worker
mem[k] = v.to_i
end
avail_part = mem["MemAvailable:"]/(mem["MemTotal:"]/100)
used_part = 100 - (mem["MemAvailable:"]/(mem["MemTotal:"]/100))
if avail_part < @my_config['crit_value']
if used_part < @my_config['crit_value']
fg_colour = @my_config['crit_colour']
elsif avail_part < @my_config['warn_value']
elsif used_part < @my_config['warn_value']
fg_colour = @my_config['warn_colour']
else
fg_colour = @my_config['ok_colour']
end
self.write "%%{F%s}%s%%{F-}" % [ fg_colour, avail_part.to_s ]
self.write "%%{F%s}%s%%{F-}" % [ fg_colour, used_part.to_s ]
sleep(1)
end