metrix 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/metrix/cli.rb +3 -1
- data/lib/metrix/process.rb +2 -2
- data/lib/metrix/version.rb +1 -1
- data/spec/lib/metrix/graphite_spec.rb +1 -1
- data/spec/lib/metrix/opentsdb_spec.rb +1 -1
- data/spec/lib/metrix/process_spec.rb +2 -2
- metadata +1 -1
data/lib/metrix/cli.rb
CHANGED
@@ -38,9 +38,11 @@ module Metrix
|
|
38
38
|
if File.exists?(pid_path)
|
39
39
|
logger.debug "#{pid_path} exists"
|
40
40
|
puts "STATUS: running with pid #{File.read(pid_path).strip}"
|
41
|
+
exit 0
|
41
42
|
else
|
42
43
|
logger.debug "#{pid_path} does not exist"
|
43
44
|
puts "STATUS: not running"
|
45
|
+
exit 1
|
44
46
|
end
|
45
47
|
when "stop"
|
46
48
|
abort "not running!" if !running?
|
@@ -111,7 +113,7 @@ module Metrix
|
|
111
113
|
|
112
114
|
if processes?
|
113
115
|
fetch_metrix :processes do
|
114
|
-
Metrix::
|
116
|
+
Metrix::ProcessMetric.all.each do |m|
|
115
117
|
reporter << m
|
116
118
|
end
|
117
119
|
end
|
data/lib/metrix/process.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require "metrix/base"
|
2
2
|
|
3
3
|
module Metrix
|
4
|
-
class
|
4
|
+
class ProcessMetric < Base
|
5
5
|
attr_reader :time
|
6
6
|
|
7
7
|
class << self
|
@@ -9,7 +9,7 @@ module Metrix
|
|
9
9
|
Dir.glob("/proc/*").select do |path|
|
10
10
|
File.directory?(path) && File.basename(path)[/^\d+$/]
|
11
11
|
end.map do |path|
|
12
|
-
Metrix::
|
12
|
+
Metrix::ProcessMetric.new(File.read(path + "/stat"))
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
data/lib/metrix/version.rb
CHANGED
@@ -3,7 +3,7 @@ require "metrix/graphite"
|
|
3
3
|
|
4
4
|
describe "Metrix::Graphite" do
|
5
5
|
let(:data) { FIXTURES_PATH.join("proc.26928.txt").read }
|
6
|
-
let(:metric) { Metrix::
|
6
|
+
let(:metric) { Metrix::ProcessMetric.new(data, Time.at(1370091027)) }
|
7
7
|
subject(:client) { Metrix::Graphite.new("128.0.0.1") }
|
8
8
|
|
9
9
|
it { should_not be_nil }
|
@@ -4,7 +4,7 @@ require "metrix/opentsdb"
|
|
4
4
|
describe "Metrix::OpenTSDB" do
|
5
5
|
let(:data) { FIXTURES_PATH.join("proc.26928.txt").read }
|
6
6
|
subject(:client) { Metrix::OpenTSDB.new("127.0.0.1", 1234) }
|
7
|
-
let(:metric) { Metrix::
|
7
|
+
let(:metric) { Metrix::ProcessMetric.new(data) }
|
8
8
|
|
9
9
|
it { should_not be_nil }
|
10
10
|
|
@@ -1,9 +1,9 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
require "metrix/process"
|
3
3
|
|
4
|
-
describe "Metrix::
|
4
|
+
describe "Metrix::ProcessMetric" do
|
5
5
|
let(:data) { FIXTURES_PATH.join("proc.26928.txt").read }
|
6
|
-
subject(:process) { Metrix::
|
6
|
+
subject(:process) { Metrix::ProcessMetric.new(data) }
|
7
7
|
|
8
8
|
it { should_not be_nil }
|
9
9
|
it { subject.time.should be_kind_of(Time) }
|