diff --git a/mod/load_average b/mod/load_average index 1214d1b..13c180e 100644 --- a/mod/load_average +++ b/mod/load_average @@ -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 diff --git a/mod/memory b/mod/memory index 1a42527..e6c96ab 100644 --- a/mod/memory +++ b/mod/memory @@ -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 diff --git a/mod/network b/mod/network index d98cfbc..de502b6 100644 --- a/mod/network +++ b/mod/network @@ -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 diff --git a/mod/newmail b/mod/newmail deleted file mode 100644 index 971f7ba..0000000 --- a/mod/newmail +++ /dev/null @@ -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") diff --git a/rc.yaml.example b/rc.yaml.example index 225233e..9d1974f 100644 --- a/rc.yaml.example +++ b/rc.yaml.example @@ -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