remove newmail; move ok/warn/crit colours to the main conf

Signed-off-by: fbt <fbt@fleshless.org>
This commit is contained in:
Jack L. Frost 2019-05-15 16:04:27 +03:00
parent 44394a963a
commit 3e16af4ec3
5 changed files with 15 additions and 67 deletions

View File

@ -8,14 +8,14 @@ class LoadAverage < Worker
file.close
if la_m.to_i > @my_config['crit_value']
fg_colour = @my_config['crit_colour']
fg_colour = "crit_colour"
elsif la_m.to_i > @my_config['warn_value']
fg_colour = @my_config['warn_colour']
fg_colour = "warn_colour"
else
fg_colour = @my_config['ok_colour']
fg_colour = "ok_colour"
end
self.write "%{F#{fg_colour}}#{la_m}%{F-}"
self.write "%{FC{#{fg_colour}}}#{la_m}%{F-}"
sleep(5)
end
end

View File

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

View File

@ -20,14 +20,14 @@ class Network < Worker
hosts_up = hosts.count - hosts_down
if hosts_down == 0
fg_colour = @my_config['ok_colour']
fg_colour = "ok_colour"
elsif hosts_down == hosts.count
fg_colour = @my_config['crit_colour']
fg_colour = "crit_colour"
else
fg_colour = @my_config['warn_colour']
fg_colour = "warn_colour"
end
@rstr = "%%{F%s}%s/%s%%{F-}" % [ fg_colour, hosts_up, hosts.count ]
@rstr = "%%{FC{%s}}%s/%s%%{F-}" % [ fg_colour, hosts_up, hosts.count ]
end
return @rstr

View File

@ -1,27 +0,0 @@
# vim: ft=ruby
class NewMail < Worker
def mainloop()
while true do
if unread_mail?
self.write "%{F#{@my_config['crit_colour']}}#{@my_config['crit_message']}%{F-}"
else
self.write "%{F#{@my_config['ok_colour']}}#{@my_config['ok_message']}%{F-}"
end
sleep(3)
end
end
def unread_mail?
@my_config['maildirs'].each do |dir|
if not (Dir.entries(dir + "/new") - [ '.', '..' ]).empty?
return true
end
end
return false
end
end
Modules.add("newmail", "NewMail")

View File

@ -22,6 +22,9 @@ colours:
bg: '#001f1f1f'
bg_focused: '#467EC2'
mon_focused: '#46C252'
ok_colour: "#00FF00"
warn_colour: "#FFFF00"
crit_colour: "#FF0000"
# Module settings
mod:
@ -42,44 +45,16 @@ mod:
la:
warn_value: 3
crit_value: 4
ok_colour: "#00FF00"
warn_colour: "#FFFF00"
crit_colour: "#FF0000"
www:
hosts:
- de-ber-as20647.anchors.atlas.ripe.net
- nl-ams-as1101.anchors.atlas.ripe.net
- ru-mow-as15835.anchors.atlas.ripe.net
ok_colour: "#00FF00"
warn_colour: "#FFFF00"
crit_colour: "#FF0000"
warp:
hosts:
- malganis.priv
- spike.priv
- builder.virt
ok_colour: "#00FF00"
warn_colour: "#FFFF00"
crit_colour: "#FF0000"
xnt:
hosts:
- emerald.zorg.sh
- brilliant.zorg.sh
- ui-server17.prod.zorg.sh
ok_colour: "#00FF00"
warn_colour: "#FFFF00"
crit_colour: "#FF0000"
newmail:
ok_message: "*"
ok_colour: "#00FF00"
crit_message: "***"
crit_colour: "#FF0000"
maildirs:
- /home/fbt/sync/maildir/.ops
- /home/fbt/sync/maildir/.inbox
memory:
ok_colour: "#00FF00"
warn_colour: "#FFFF00"
crit_colour: "#FF0000"
warn_value: 75
crit_value: 90