nephelae 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,61 @@
1
+ module Nephelae
2
+
3
+ class MemUsage
4
+
5
+ def initialize(params = {})
6
+ end
7
+
8
+ def command
9
+ "cat /proc/meminfo"
10
+ end
11
+
12
+ def get_metrics
13
+ metrics = Metrics.new('System/Linux')
14
+ output = `#{command}`
15
+
16
+ if $?.success?
17
+ stats = parse_status(output)
18
+ metrics.append_metric('MemoryTotal', stats[:mem_total], {unit: 'Kilobytes'})
19
+
20
+ mem_free = stats[:mem_free] + stats[:buffers] + stats[:cached]
21
+ metrics.append_metric('MemoryFree', mem_free, {unit: 'Kilobytes'})
22
+
23
+ mem_used = stats[:mem_total] - mem_free
24
+ metrics.append_metric('MemoryUsed', mem_used, {unit: 'Kilobytes'})
25
+
26
+ unless mem_total == 0
27
+ mem_used_percent = (mem_used.to_f / mem_total.to_f * 100).to_i
28
+ metrics.append_metric('MemoryUsedPercentage', mem_used_percent, {unit: 'Percent'})
29
+ end
30
+
31
+ metrics.append_metric('SwapTotal', stats[:swap_total], {unit: 'Kilobytes'})
32
+ metrics.append_metric('SwapFree', stats[:swap_free], {unit: 'Kilobytes'})
33
+ swap_used = stats[:swap_total] - stats[:swap_free]
34
+
35
+ metrics.append_metric('SwapUsed', stats[:swap_used], {unit: 'Kilobytes'})
36
+
37
+ unless stats[:swap_total] == 0
38
+ swap_used_percent = (stats[:swap_used].to_f / stats[:swap_total].to_f * 100).to_i
39
+ metrics.append_metric('SwapUsedPercentage', swap_used_percent, {unit: 'Percent'})
40
+ end
41
+ end
42
+
43
+ return metrics
44
+
45
+ end
46
+
47
+
48
+ private
49
+ def parse_status(body)
50
+ { :mem_total => body.match(/MemTotal:\s+(\d+)\s/)[1],
51
+ :mem_free => body.match(/MemFree:\s+(\d+)\s/)[1],
52
+ :buffers => body.match(/Buffers:\s+(\d+)\s/)[1],
53
+ :cached => body.match(/Cached:\s+(\d+)\s/)[1],
54
+ :swap_total => body.match(/SwapTotal:\s+(\d+)\s/)[1],
55
+ :swap_free => body.match(/SwapFree:\s+(\d+)\s/)[1]
56
+ }
57
+ end
58
+
59
+ end
60
+
61
+ end
@@ -0,0 +1,20 @@
1
+ module Nephelae
2
+
3
+ class NephelaeProcess
4
+
5
+ def initialize(params = {})
6
+ end
7
+
8
+ def get_metrics
9
+ metrics = Metrics.new('Process/Nephelae')
10
+
11
+ #if we are doing this we are up
12
+ metrics.append_metric('Up', 1)
13
+
14
+ return metrics
15
+
16
+ end
17
+
18
+ end
19
+
20
+ end
@@ -0,0 +1,42 @@
1
+ module Nephelae
2
+
3
+ class PassengerStatus
4
+
5
+ def initialize(params = {})
6
+ end
7
+
8
+ def command
9
+ "passenger-status 2>&1"
10
+ end
11
+
12
+ def get_metrics
13
+ metrics = Metrics.new('Linux/Passenger')
14
+ output = `#{command}`
15
+
16
+ if $?.success?
17
+ stats = parse_status(output)
18
+ metrics.append_metric('MaxInstances', stats[:max])
19
+ metrics.append_metric('CountInstances', stats[:count])
20
+ metrics.append_metric('ActiveInstances', stats[:active])
21
+ metrics.append_metric('InactiveInstances', stats[:inactive])
22
+ metrics.append_metric('WaitingOnGlobalQueue', stats[:waiting_on_global_queue])
23
+
24
+ end
25
+
26
+ return metrics
27
+
28
+ end
29
+
30
+ private
31
+ def parse_status(body)
32
+ { :max => body.match(/max\s+=\s+(\d+)/)[1],
33
+ :count => body.match(/count\s+=\s+(\d+)/)[1],
34
+ :active => body.match(/active\s+=\s+(\d+)/)[1],
35
+ :inactive => body.match(/inactive\s+=\s+(\d+)/)[1],
36
+ :waiting_on_global_queue => body.match(/waiting on global queue\:\s+(\d+)/i)[1]
37
+ }
38
+ end
39
+
40
+ end
41
+
42
+ end
@@ -1,3 +1,3 @@
1
1
  module Nephelae
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nephelae
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -111,6 +111,9 @@ files:
111
111
  - lib/nephelae/cloud_watch/metrics.rb
112
112
  - lib/nephelae/cloud_watch/simple_aws.rb
113
113
  - lib/nephelae/plugins/disk_space.rb
114
+ - lib/nephelae/plugins/mem_usage.rb
115
+ - lib/nephelae/plugins/nephelae_process.rb
116
+ - lib/nephelae/plugins/passenger_status.rb
114
117
  - lib/nephelae/runner.rb
115
118
  - lib/nephelae/version.rb
116
119
  - nephelae.gemspec