monus 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/monus/backends/influxdb.rb +7 -3
- data/lib/monus/built_in_metrics/em_threadpool.rb +29 -0
- data/lib/monus/built_in_metrics/em_ticks.rb +22 -0
- data/lib/monus.rb +6 -2
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 482f21054f845318dd5dc32a57521df44f666d20
|
4
|
+
data.tar.gz: 2fc3c3bbe40cde0970cff470a60b7a3054b12eea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e151e3e6a55b9d44026b8abd76ed793dcc8a7db59205b805fe332e2de7d93f575465ae70ba0b15fff7a838cbc0bda24baf0cc8c3a1a16965c9b411949e6a621c
|
7
|
+
data.tar.gz: d2bba43dfe9c57d401696df8583266392e61bf2bf67bacdb9acb11a0b4c83d64ec590d903ac502786505d30b41bef5dbfa450a14b09a5c9b221626064e00059f
|
@@ -35,9 +35,13 @@ module Monus::Backend::InfluxDB
|
|
35
35
|
@global_tags = Monus.options.dig(:influxdb_options, :global_tags)&.map { |key, value| ",#{key}=#{value}" }&.join
|
36
36
|
end
|
37
37
|
|
38
|
-
def write(
|
39
|
-
|
40
|
-
|
38
|
+
def write(fields, tags = nil)
|
39
|
+
fields = fields.map { |key, value| "#{key}=#{value.inspect}" }.join(',')
|
40
|
+
|
41
|
+
tags = tags&.map { |key, value| ",#{key}=#{value}" }&.join
|
42
|
+
|
43
|
+
message = "#{@measurement}#{@global_tags}#{tags} #{fields}"
|
44
|
+
|
41
45
|
case @mode
|
42
46
|
when :udp
|
43
47
|
Monus.engine.send_udp_datagram message, @host, @udp_port
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Monus::BuiltInMetric::EmThreadpool
|
2
|
+
def activate
|
3
|
+
@interval = Monus.options.dig(:em_threadpool_metric_options, :interval) || 1
|
4
|
+
|
5
|
+
threadpool = nil
|
6
|
+
|
7
|
+
Monus.engine.every @interval do
|
8
|
+
threadpool ||= EM.send(:instance_variable_get, :@threadpool)
|
9
|
+
|
10
|
+
if threadpool
|
11
|
+
by_status = threadpool.group_by(&:status).transform_values(&:size)
|
12
|
+
|
13
|
+
total = threadpool.size
|
14
|
+
run = by_status['run']
|
15
|
+
load_percent = run.to_f / total
|
16
|
+
broken = total - run - by_status['sleep']
|
17
|
+
|
18
|
+
Monus.write em_threadpool_load: load_percent,
|
19
|
+
em_threadpool_run: run,
|
20
|
+
em_threadpool_total: total,
|
21
|
+
em_threadpool_broken: broken
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
extend self
|
27
|
+
|
28
|
+
Monus::BuiltInMetric.register :em_threadpool, self
|
29
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Monus::BuiltInMetric::EmTicks
|
2
|
+
def activate
|
3
|
+
@interval = Monus.options.dig(:em_ticks_metric_options, :interval) || 1
|
4
|
+
|
5
|
+
counter, time = 0, Time.now
|
6
|
+
|
7
|
+
EM.tick_loop do
|
8
|
+
counter += 1
|
9
|
+
delta = Time.now - time
|
10
|
+
if delta > @interval
|
11
|
+
ticks = (counter.to_f / delta).round
|
12
|
+
Monus.set :em_ticks, ticks
|
13
|
+
counter = 0
|
14
|
+
time = Time.now
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
extend self
|
20
|
+
|
21
|
+
Monus::BuiltInMetric.register :em_ticks, self
|
22
|
+
end
|
data/lib/monus.rb
CHANGED
@@ -49,8 +49,12 @@ module Monus
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
-
def self.
|
53
|
-
backend.write
|
52
|
+
def self.write(fields, context = nil)
|
53
|
+
backend.write(fields, context)
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.set(field, value, context = nil)
|
57
|
+
write({field => value}, context)
|
54
58
|
end
|
55
59
|
|
56
60
|
def self.accept(field)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: monus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Xanders
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Monus is an in-process monitoring library for several backends and engines
|
14
14
|
email: necropolis@inbox.ru
|
@@ -22,6 +22,8 @@ files:
|
|
22
22
|
- lib/monus/backend.rb
|
23
23
|
- lib/monus/backends/influxdb.rb
|
24
24
|
- lib/monus/built_in_metric.rb
|
25
|
+
- lib/monus/built_in_metrics/em_threadpool.rb
|
26
|
+
- lib/monus/built_in_metrics/em_ticks.rb
|
25
27
|
- lib/monus/built_in_metrics/works.rb
|
26
28
|
- lib/monus/engine.rb
|
27
29
|
- lib/monus/engines/pure.rb
|