that was weird
Signed-off-by: fbt <fbt@fleshless.org>
This commit is contained in:
parent
cdc42088b9
commit
86982a2f32
11
mod/memory
11
mod/memory
|
@ -4,21 +4,22 @@ class ModMemory < Worker
|
|||
def mainloop()
|
||||
while true do
|
||||
mem = {}
|
||||
data = File.read("/proc/meminfo").scan(/(.+):\s+([0-9]+)/).map do |k, v|
|
||||
File.read("/proc/meminfo").each_line do |line|
|
||||
k, v = line.split[0..1]
|
||||
mem[k] = v.to_i
|
||||
end
|
||||
|
||||
mem["avail_part"] = mem["MemAvailable"]/(mem["MemTotal"]/100)
|
||||
avail_part = mem["MemAvailable:"]/(mem["MemTotal:"]/100)
|
||||
|
||||
if mem["avail_part"] < @my_config['crit_value']
|
||||
if avail_part < @my_config['crit_value']
|
||||
fg_colour = @my_config['crit_colour']
|
||||
elsif mem["avail_part"] < @my_config['warn_value']
|
||||
elsif avail_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, mem["avail_part"].to_s ]
|
||||
self.write "%%{F%s}%s%%{F-}" % [ fg_colour, avail_part.to_s ]
|
||||
|
||||
sleep(1)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user