newrelic_pivpn_agent 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,7 +11,7 @@ require "newrelic_plugin"
11
11
  module NewRelicOpenvpnAgent
12
12
  class Agent < NewRelic::Plugin::Agent::Base
13
13
  agent_guid "home.secretnet.secretlab.pivpn"
14
- agent_version "0.0.2"
14
+ agent_version "0.0.5"
15
15
  agent_config_options :openvpn_status_path
16
16
  agent_human_labels("piVPN Agent") { ident }
17
17
 
@@ -34,13 +34,23 @@ module NewRelicOpenvpnAgent
34
34
  end
35
35
 
36
36
  def metric(_type)
37
- metrics = {
38
- :total_users => ["Total/Users", "Users", lambda{get_columns(ovpn_cmd, 1) }],
39
- :total_bytes_received => ["Total/Bytes/Received", "bytes", lambda{ get_columns(ovpn_cmd, 4, false, false).inject(0){|_t, _b| (_t + _b.to_i) } }],
40
- :total_bytes_sent => ["Total/Bytes/Sent", "bytes", lambda{ get_columns(ovpn_cmd, 5, false, false).inject(0){|_t, _b| (_t + _b.to_i) } }],
41
- :average_bytes_received => ["Average/Bytes/Received", "bytes", lambda{ x = get_columns(ovpn_cmd, 4, false, false); x.inject(0){|_t, _b| (_t + _b.to_i) } / x.length }],
42
- :average_bytes_sent => ["Average/Bytes/Sent", "bytes", lambda{ x = get_columns(ovpn_cmd, 5, false, false); x.inject(0){|_t, _b| (_t + _b.to_i) } / x.length }]
43
- }
37
+ if get_columns(ovpn_cmd, 1) > 0
38
+ metrics = {
39
+ :total_users => ["Total/Users", "Users", lambda{get_columns(ovpn_cmd, 1) }],
40
+ :total_bytes_received => ["Total/Bytes/Received", "bytes", lambda{ get_columns(ovpn_cmd, 4, false, false).inject(0){|_t, _b| (_t + _b.to_i) } }],
41
+ :total_bytes_sent => ["Total/Bytes/Sent", "bytes", lambda{ get_columns(ovpn_cmd, 5, false, false).inject(0){|_t, _b| (_t + _b.to_i) } }],
42
+ :average_bytes_received => ["Average/Bytes/Received", "bytes", lambda{ x = get_columns(ovpn_cmd, 4, false, false); x.inject(0){|_t, _b| (_t + _b.to_i) } / x.length }],
43
+ :average_bytes_sent => ["Average/Bytes/Sent", "bytes", lambda{ x = get_columns(ovpn_cmd, 5, false, false); x.inject(0){|_t, _b| (_t + _b.to_i) } / x.length }]
44
+ }
45
+ else
46
+ metrics = {
47
+ :total_users => ["Total/Users", "Users", lambda{0}],
48
+ :total_bytes_received => ["Total/Bytes/Received", "bytes", lambda{0}],
49
+ :total_bytes_sent => ["Total/Bytes/Sent", "bytes", lambda{0}],
50
+ :average_bytes_received => ["Average/Bytes/Received", "bytes", lambda{0}],
51
+ :average_bytes_sent => ["Average/Bytes/Sent", "bytes", lambda{0}]
52
+ }
53
+ end
44
54
  metrics[_type]
45
55
  end
46
56
 
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
13
13
  ## If your rubyforge_project name is different, then edit it and comment out
14
14
  ## the sub! line in the Rakefile
15
15
  s.name = 'newrelic_pivpn_agent'
16
- s.version = '0.0.4'
17
- s.date = '2017-11-14'
16
+ s.version = '0.0.5'
17
+ s.date = '2018-01-11'
18
18
  # s.rubyforge_project = 'newrelic_pivpn_agent'
19
19
 
20
20
  ## Make sure your summary is short. The description may be as long
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: newrelic_pivpn_agent
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-11-14 00:00:00.000000000 Z
12
+ date: 2018-01-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler