modules are local
Signed-off-by: fbt <fbt@fleshless.org>
This commit is contained in:
parent
db0fe073b8
commit
a19db08791
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -3,3 +3,4 @@ homedir/.vim/syntax
|
||||||
homedir/.bashrc.d/99-local
|
homedir/.bashrc.d/99-local
|
||||||
homedir/.config/zsh.d/modules/local
|
homedir/.config/zsh.d/modules/local
|
||||||
homedir/.ncmpcpp/error.log
|
homedir/.ncmpcpp/error.log
|
||||||
|
homedir/.config/moltenbar/mod
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
/home/fbt/git/moltenbar/mod/bspwm_pager
|
|
|
@ -1 +0,0 @@
|
||||||
/home/fbt/git/moltenbar/mod/bspwm_taskbar
|
|
|
@ -1 +0,0 @@
|
||||||
/home/fbt/git/moltenbar/mod/date
|
|
|
@ -1 +0,0 @@
|
||||||
/home/fbt/git/moltenbar/mod/load_average
|
|
|
@ -1 +0,0 @@
|
||||||
/home/fbt/git/moltenbar/mod/memory
|
|
|
@ -1,39 +0,0 @@
|
||||||
# vim: ft=ruby
|
|
||||||
|
|
||||||
class Network < Worker
|
|
||||||
require 'open3'
|
|
||||||
|
|
||||||
def mainloop()
|
|
||||||
self.write "checking..."
|
|
||||||
|
|
||||||
while true do
|
|
||||||
self.write network_status
|
|
||||||
sleep(10)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def network_status
|
|
||||||
hosts = @my_config['hosts']
|
|
||||||
|
|
||||||
net_fail = 0
|
|
||||||
Open3.popen2("fping", "-u", *hosts) do |i,o,t|
|
|
||||||
hosts_down = o.each_line.count
|
|
||||||
hosts_up = hosts.count - hosts_down
|
|
||||||
|
|
||||||
if hosts_down == 0
|
|
||||||
fg_colour = @my_config['ok_colour']
|
|
||||||
elsif hosts_down == hosts.count
|
|
||||||
fg_colour = @my_config['crit_colour']
|
|
||||||
else
|
|
||||||
fg_colour = @my_config['warn_colour']
|
|
||||||
end
|
|
||||||
|
|
||||||
@rstr = "%%{F%s}%s/%s%%{F-}" % [ fg_colour, hosts_up, hosts.count ]
|
|
||||||
end
|
|
||||||
|
|
||||||
return @rstr
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
Modules.add("network", "Network")
|
|
||||||
Modules.add("warp", "Network")
|
|
Loading…
Reference in New Issue
Block a user