smartware 0.4.6 → 0.4.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -18,15 +18,22 @@ module Smartware
18
18
 
19
19
  Logging.logger.debug "pppd: #{line}"
20
20
 
21
- if line =~ /^Sent ([0-9]+) bytes, received ([0-9]+) bytes.$/
21
+ case line
22
+ when /authentication succeeded$/
23
+ @started = Time.now.to_i
24
+
25
+ when /^Sent ([0-9]+) bytes, received ([0-9]+) bytes.$/
22
26
  @sent = $1.to_i
23
27
  @received = $2.to_i
24
- elsif line =~ /^Connect time ([0-9.]+) minutes.$/
28
+
29
+ when /^Connect time ([0-9.]+) minutes.$/
25
30
  @time = ($1.to_f * 60).round
26
- elsif line == "Connection terminated."
31
+
32
+ when "Connection terminated."
27
33
  begin
28
- @device.account.call @sent, @received, @time
34
+ @device.account.call @started, @sent, @received, @time
29
35
  ensure
36
+ @started = nil
30
37
  @sent = nil
31
38
  @received = nil
32
39
  @time = nil
@@ -41,10 +41,10 @@ module Smartware
41
41
  end
42
42
  end
43
43
 
44
- def account(sent, received, time)
44
+ def account(started, sent, received, time)
45
45
  Smartware::Logging.logger.debug "recording session: #{sent} upstream #{received} downstream, #{time} seconds"
46
46
 
47
- publish_reliable_event 'accounting', sent, received, time
47
+ publish_reliable_event 'accounting', started, sent, received, time
48
48
  end
49
49
  end
50
50
  end
@@ -1,3 +1,3 @@
1
1
  module Smartware
2
- VERSION = "0.4.6"
2
+ VERSION = "0.4.7"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smartware
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.6
4
+ version: 0.4.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: