arbi 1.0.8.1 → 1.0.8.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -30,10 +30,10 @@ class Config < Hash
30
30
  self.parse
31
31
  end
32
32
 
33
- def parse(file = '/etc/arbi.conf')
34
- config = YAML.load_file(file)
35
- rescue
36
- Arbi.debug "Config: Error in parsing"
33
+ def parse(file = '/etc/arbi.yaml')
34
+ config = ::YAML.load_file(file)
35
+ rescue Exception => e
36
+ Arbi.debug "Config: #{e}"
37
37
  ensure
38
38
  config ||= {}
39
39
  config[:server] ||= {}
@@ -31,7 +31,7 @@ class Net < Arbi::Modules::Module
31
31
  @prev = {:up => {}, :down => {}}
32
32
  @datas = []
33
33
 
34
- every 2, :timeout => 10, &self.method(:update)
34
+ every 1, :timeout => 10, &self.method(:update)
35
35
  end
36
36
 
37
37
  def valid?
@@ -53,6 +53,7 @@ class Net < Arbi::Modules::Module
53
53
  })
54
54
  end
55
55
 
56
+ protected
56
57
  def update
57
58
  stats = {}
58
59
  File.read('/proc/net/dev').gsub(/^.*\|.*?\n/m, '').each_line {|line|
@@ -63,8 +64,8 @@ class Net < Arbi::Modules::Module
63
64
  @prev[:up][name] = @prev[:down][name] = 0 if !@prev[:up].include?(name) and !@prev[:down].include?(name)
64
65
 
65
66
  stats[name] = {
66
- up: "%.1fkB" % [( up - @prev[ :up ][name]).to_f / 1024],
67
- down: "%.1fkB" % [(down - @prev[:down][name]).to_f / 1024],
67
+ up: "%.1f kB/s" % [( up - @prev[ :up ][name]).to_f / 1024],
68
+ down: "%.1f kB/s" % [(down - @prev[:down][name]).to_f / 1024],
68
69
  state: (File.read('/proc/net/route') =~ /#{Regexp.escape(name)}/ ? true : false),
69
70
  quality: nil,
70
71
  essid: nil
@@ -72,11 +73,7 @@ class Net < Arbi::Modules::Module
72
73
 
73
74
  if stats[name][:state]
74
75
  stats[name][:quality] = quality(name)
75
- begin
76
- stats[name][ :essid ] = essid(name) if stats[name][:quality]
77
- rescue Exception => e
78
- Arbi.debug("ESSID: #{e}")
79
- end
76
+ stats[name][ :essid ] = essid(name) if stats[name][:quality]
80
77
  end
81
78
 
82
79
  @prev[ :up ][name] = up
@@ -88,7 +85,6 @@ class Net < Arbi::Modules::Module
88
85
  Arbi.debug(e.to_s)
89
86
  end
90
87
 
91
- protected
92
88
  def quality(interface)
93
89
  File.read('/proc/net/wireless').match(/^\s*#{Regexp.escape(interface)}:.*$/)[0].strip.split(/:?\s+/)[2].gsub('.', '') + "%"
94
90
  rescue
@@ -19,5 +19,5 @@
19
19
 
20
20
 
21
21
  module Arbi
22
- VERSION = '1.0.8.1'
22
+ VERSION = '1.0.8.2'
23
23
  end
metadata CHANGED
@@ -6,8 +6,8 @@ version: !ruby/object:Gem::Version
6
6
  - 1
7
7
  - 0
8
8
  - 8
9
- - 1
10
- version: 1.0.8.1
9
+ - 2
10
+ version: 1.0.8.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - shura