app_perf_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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 220f24bbd58f26a076d4c659c5c76417eb4c6b37
4
- data.tar.gz: eebd2505664b85ce4d0a663d6528c1d412b67955
3
+ metadata.gz: 83eb4bae490dab766b51af3f82645f1a90d44c05
4
+ data.tar.gz: 478855eaba7d663a4cd1b342b404b3e0c338d49c
5
5
  SHA512:
6
- metadata.gz: 6aea2e835dfca15bcb47adbd684ec9dafe639e70973c28d7762cd3717d29c74de9c1ad7a28c82f1634407a4e0623561ee5e0b4cf258e39f716e5fa804533408d
7
- data.tar.gz: 9e183668cdffeee13f55445223a145421ed7579e9b239972c93897e5a00e6ead1bdc0b41cda922b996bbb3d61ee20f9d0da4f562b3e9920baf8d26bfbffef770
6
+ metadata.gz: f9624d53a397bbd174839114216e37bcc0ce8596a913d903fd22628fb9d2f61053259cd3782f9ac5521709cfba52603beca2764dbd4cb04cc482f5e6eac7499b
7
+ data.tar.gz: 4a9651936e40ad4cd5b0aca19460af45f1cc6204222f26de51eef9d4e29521ddf791992e322d4c87cc9ea208c5cf8c86e33dddb13e2efc5096508010d55b03c0
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "app_perf_agent"
7
- s.version = "0.0.4"
7
+ s.version = "0.0.5"
8
8
  s.date = "2017-07-24"
9
9
  s.summary = "AppPerf Agent"
10
10
  s.description = "Agent for the AppPerf app."
@@ -1,4 +1,3 @@
1
- require_relative "app_perf_agent/types"
2
1
  require_relative "app_perf_agent/logger"
3
2
  require_relative "app_perf_agent/plugin"
4
3
  require_relative "app_perf_agent/dispatcher"
@@ -16,8 +16,8 @@ module AppPerfAgent
16
16
 
17
17
  def plugins
18
18
  @plugins ||= ::AppPerfAgent::Plugin::Base
19
- .descendants
20
- .map(&:new)
19
+ .descendants
20
+ .map(&:new)
21
21
  end
22
22
  end
23
23
  end
@@ -5,36 +5,26 @@ module AppPerfAgent
5
5
  module Plugin
6
6
  module System
7
7
  class Cpu < AppPerfAgent::Plugin::Base
8
+ attr_accessor :last
9
+
10
+ def initialize
11
+ self.last = Vmstat.snapshot.cpus
12
+ super
13
+ end
14
+
8
15
  def call
9
16
  cpus = Vmstat.snapshot.cpus
10
- cpus.flat_map {|cpu|
17
+ metrics = cpus.each_with_index.flat_map {|cpu, index|
18
+ total = (cpu.idle + cpu.nice + cpu.system + cpu.user) - (last[index].idle + last[index].nice + last[index].system + last[index].user)
11
19
  [
12
- [
13
- AppPerfAgent::Types::CPU,
14
- "system.cpu.idle",
15
- "CPU ##{cpu.num} (Idle)",
16
- cpu.idle
17
- ],
18
- [
19
- AppPerfAgent::Types::CPU,
20
- "system.cpu.nice",
21
- "CPU ##{cpu.num} (Nice)",
22
- cpu.nice
23
- ],
24
- [
25
- AppPerfAgent::Types::CPU,
26
- "system.cpu.system",
27
- "CPU ##{cpu.num} (System)",
28
- cpu.system
29
- ],
30
- [
31
- AppPerfAgent::Types::CPU,
32
- "system.cpu.user",
33
- "CPU ##{cpu.num} (User)",
34
- cpu.user
35
- ]
20
+ ["system.cpu.idle", (cpu.idle - last[index].idle).to_f / total.to_f * 100.to_f, { "num" => cpu.num }],
21
+ ["system.cpu.nice", (cpu.nice - last[index].nice).to_f / total.to_f * 100.to_f, { "num" => cpu.num }],
22
+ ["system.cpu.system", (cpu.system - last[index].system).to_f / total.to_f * 100.to_f, { "num" => cpu.num }],
23
+ ["system.cpu.user", (cpu.user - last[index].user).to_f / total.to_f * 100.to_f, { "num" => cpu.num }]
36
24
  ]
37
25
  }
26
+ self.last = cpus
27
+ metrics
38
28
  end
39
29
  end
40
30
  end
@@ -9,30 +9,10 @@ module AppPerfAgent
9
9
  disks = Vmstat.snapshot.disks
10
10
  disks.flat_map {|disk|
11
11
  [
12
- [
13
- AppPerfAgent::Types::DISK,
14
- "system.disk.used_bytes",
15
- "#{disk.origin} - #{disk.type} (#{disk.mount})",
16
- disk.used_bytes
17
- ],
18
- [
19
- AppPerfAgent::Types::DISK,
20
- "system.disk.free_bytes",
21
- "#{disk.origin} - #{disk.type} (#{disk.mount})",
22
- disk.free_bytes
23
- ],
24
- [
25
- AppPerfAgent::Types::DISK,
26
- "system.disk.available_bytes",
27
- "#{disk.origin} - #{disk.type} (#{disk.mount})",
28
- disk.available_bytes
29
- ],
30
- [
31
- AppPerfAgent::Types::DISK,
32
- "system.disk.total_bytes",
33
- "#{disk.origin} - #{disk.type} (#{disk.mount})",
34
- disk.total_bytes
35
- ]
12
+ ["system.disk.used_bytes", disk.used_bytes, { "origin" => disk.origin, "type" => disk.type, "mount" => disk.mount }],
13
+ ["system.disk.free_bytes", disk.free_bytes, { "origin" => disk.origin, "type" => disk.type, "mount" => disk.mount }],
14
+ ["system.disk.available_bytes", disk.available_bytes, { "origin" => disk.origin, "type" => disk.type, "mount" => disk.mount }],
15
+ ["system.disk.total_bytes", disk.total_bytes, { "origin" => disk.origin, "type" => disk.type, "mount" => disk.mount }]
36
16
  ]
37
17
  }
38
18
  end
@@ -8,24 +8,9 @@ module AppPerfAgent
8
8
  def call
9
9
  loads = Vmstat.load_average
10
10
  [
11
- [
12
- AppPerfAgent::Types::LOAD,
13
- "system.load.one_minute",
14
- "Load - One Minute",
15
- loads.one_minute
16
- ],
17
- [
18
- AppPerfAgent::Types::LOAD,
19
- "system.load.five_minute",
20
- "Load - Five Minute",
21
- loads.five_minutes
22
- ],
23
- [
24
- AppPerfAgent::Types::LOAD,
25
- "system.load.fifteen_minute",
26
- "Load - Fifteen Minute",
27
- loads.fifteen_minutes
28
- ]
11
+ ["system.load.one_minute", loads.one_minute],
12
+ ["system.load.five_minute", loads.five_minutes],
13
+ ["system.load.fifteen_minute", loads.fifteen_minutes]
29
14
  ]
30
15
  end
31
16
  end
@@ -8,36 +8,11 @@ module AppPerfAgent
8
8
  def call
9
9
  memory = Vmstat.memory
10
10
  [
11
- [
12
- AppPerfAgent::Types::MEMORY,
13
- "system.memory.free_bytes",
14
- "Memory (Free)",
15
- memory.free_bytes
16
- ],
17
- [
18
- AppPerfAgent::Types::MEMORY,
19
- "system.memory.inactive_bytes",
20
- "Memory (Inactive)",
21
- memory.inactive_bytes
22
- ],
23
- [
24
- AppPerfAgent::Types::MEMORY,
25
- "system.memory.active_bytes",
26
- "Memory (Active)",
27
- memory.active_bytes
28
- ],
29
- [
30
- AppPerfAgent::Types::MEMORY,
31
- "system.memory.wired_bytes",
32
- "Memory (Wired)",
33
- memory.wired_bytes
34
- ],
35
- [
36
- AppPerfAgent::Types::MEMORY,
37
- "system.memory.total_bytes",
38
- "Memory (Total)",
39
- memory.total_bytes
40
- ]
11
+ ["system.memory.free_bytes", memory.free_bytes],
12
+ ["system.memory.inactive_bytes", memory.inactive_bytes],
13
+ ["system.memory.active_bytes", memory.active_bytes],
14
+ ["system.memory.wired_bytes", memory.wired_bytes],
15
+ ["system.memory.total_bytes", memory.total_bytes]
41
16
  ]
42
17
  end
43
18
  end
@@ -9,18 +9,8 @@ module AppPerfAgent
9
9
  inets = Vmstat.ethernet_devices
10
10
  inets.flat_map {|inet|
11
11
  [
12
- [
13
- AppPerfAgent::Types::NETWORK,
14
- "system.network.in_bytes",
15
- inet.name.to_s,
16
- inet.in_bytes
17
- ],
18
- [
19
- AppPerfAgent::Types::NETWORK,
20
- "system.network.out_bytes",
21
- inet.name.to_s,
22
- inet.out_bytes
23
- ]
12
+ ["system.network.in_bytes", inet.in_bytes, { "name" => inet.name.to_s }],
13
+ ["system.network.out_bytes", inet.out_bytes, { "name" => inet.name.to_s }]
24
14
  ]
25
15
  }
26
16
  end
@@ -36,13 +36,9 @@ module AppPerfAgent
36
36
  items = plugin.call
37
37
  items.map {|i| AppPerfAgent.logger.debug i }
38
38
  Array(items).each do |item|
39
- type, name, label, value = item
40
- dispatcher.add_event(["metric", Time.now.to_f, {
41
- "type" => type,
42
- "name" => name,
43
- "label" => label,
44
- "value" => value
45
- }])
39
+ key, value, tags = item
40
+ metric = ["metric", Time.now.to_f, key, value, tags || {}]
41
+ dispatcher.add_event(metric)
46
42
  end
47
43
  end
48
44
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: app_perf_agent
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Randy Girard
@@ -121,7 +121,6 @@ files:
121
121
  - lib/app_perf_agent/plugin/system/load.rb
122
122
  - lib/app_perf_agent/plugin/system/memory.rb
123
123
  - lib/app_perf_agent/plugin/system/network.rb
124
- - lib/app_perf_agent/types.rb
125
124
  - lib/app_perf_agent/worker.rb
126
125
  homepage: https://www.github.com/randy-girard/app_perf_agent
127
126
  licenses:
@@ -1,10 +0,0 @@
1
- module AppPerfAgent
2
- module Types
3
- CUSTOM = 'custom'.freeze
4
- DISK = 'disk'.freeze
5
- CPU = 'cpu'.freeze
6
- NETWORK = 'network'.freeze
7
- MEMORY = 'memory'.freeze
8
- LOAD = 'load'.freeze
9
- end
10
- end