riemann-tools 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0ce8422ca7b04d401460ff2850f94c32626e796a
4
- data.tar.gz: a65e55e277a680dbef2860716fc2c36eb2545e93
3
+ metadata.gz: 5b58978e25c07331c031e4575ffb46b7a04c3db5
4
+ data.tar.gz: 50649c44cd74a42dd1b7d9b82e27cbdfdb16341d
5
5
  SHA512:
6
- metadata.gz: 090cd5f4c835323168fe37b660238646c56d678d05e89b4484b201ba13e2620144c31b9ab27b49a91a230f49d612d44512fcca02aeaf254c0b47202adece4592
7
- data.tar.gz: cc2bef99a2932aa9ee3ce3a8c20022d0814b6f185df81e6ed4596341c46ef35000f79037d99f0a1e2bf21f30231b5d749e57e0b8404199334717058566fcedf8
6
+ metadata.gz: 2d2a3f364ed87b7d79252eafc11fb5d05c5ef000cc029460c08b1b1bd4457800329e3cf69dda990458e2fb91900b02413ebcb28c677ab696bb88a46790f14ef1
7
+ data.tar.gz: 491e357bbf23baac6fbee6172a6f8ecb81fb004280c4135bfe67d00945785bbc190531b97a93ff06fbcd248bb5e178243a2effc92ddb5f31ad198c342fc4d39a
@@ -14,7 +14,7 @@ class Riemann::Tools::AWSBilling
14
14
 
15
15
  opt :access_key, "AWS access key", :type => String
16
16
  opt :secret_key, "Secret access key", :type => String
17
- opt :services, "AWS services: AmazonEC2 AmazonS3 AWSDataTransfer", :type => strings, :multi => true, :default => ["AmazonEC2", "AmazonS3", "AWSDataTransfer"]
17
+ opt :services, "AWS services: AmazonEC2 AmazonS3 AWSDataTransfer", :type => :strings, :multi => true, :default => ["AmazonEC2", "AmazonS3", "AWSDataTransfer"]
18
18
 
19
19
  opt :time_start, "Start time in seconds of the metrics period (2hrs ago default)", :type => Integer, :default => 7200
20
20
  opt :time_end, "End time in seconds of the metrics period ", :type => Integer, :default => 60
@@ -7,6 +7,7 @@ class Riemann::Tools::Elasticsearch
7
7
 
8
8
  require 'faraday'
9
9
  require 'json'
10
+ require 'uri'
10
11
 
11
12
  opt :read_timeout, 'Faraday read timeout', type: :int, default: 2
12
13
  opt :open_timeout, 'Faraday open timeout', type: :int, default: 1
data/bin/riemann-health CHANGED
@@ -237,8 +237,10 @@ class Riemann::Tools::Health
237
237
  def disk
238
238
  `df -P`.split(/\n/).each do |r|
239
239
  f = r.split(/\s+/)
240
- next unless f[0] =~ /^\//
241
- next if f[0] == 'Filesystem'
240
+ next if f[0] == 'Filesystem'
241
+ next unless f[0] =~ /\// # Needs at least one slash in the mount path
242
+
243
+ # Calculate capacity
242
244
  x = f[4].to_f/100
243
245
 
244
246
  if x > @limits[:disk][:critical]
data/bin/riemann-proc CHANGED
@@ -32,7 +32,7 @@ class Riemann::Tools::Proc
32
32
 
33
33
  def linux_proc
34
34
  process = opts[:proc_regex]
35
- running = Integer(`ps axo args | grep #{process} | grep -v grep | grep -v riemann-proc | wc -l`)
35
+ running = Integer(`ps axo args | grep '#{process}' | grep -v grep | grep -v riemann-proc | wc -l`)
36
36
  if running > @limits[:critical][:max] or running < @limits[:critical][:min]
37
37
  alert "proc #{process}", :critical, running, "process #{process} is running #{running} instances"
38
38
  else
data/lib/riemann/tools.rb CHANGED
@@ -1,9 +1,7 @@
1
1
  module Riemann
2
2
  module Tools
3
- require 'rubygems'
4
3
  require 'trollop'
5
4
  require 'riemann/client'
6
- require 'timeout'
7
5
 
8
6
  def self.included(base)
9
7
  base.instance_eval do
@@ -68,19 +66,14 @@ module Riemann
68
66
 
69
67
  event = event.merge(attributes)
70
68
 
71
- begin
72
- Timeout::timeout(options[:timeout]) do
73
- riemann << event
74
- end
75
- rescue Timeout::Error
76
- riemann.connect
77
- end
69
+ riemann << event
78
70
  end
79
71
 
80
72
  def new_riemann_client
81
73
  r = Riemann::Client.new(
82
- :host => options[:host],
83
- :port => options[:port]
74
+ :host => options[:host],
75
+ :port => options[:port],
76
+ :timeout => options[:timeout]
84
77
  )
85
78
  if options[:tcp]
86
79
  r.tcp
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: riemann-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kyle Kingsbury
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-26 00:00:00.000000000 Z
11
+ date: 2014-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: riemann-client
@@ -66,20 +66,6 @@ dependencies:
66
66
  - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: 1.1.0
69
- - !ruby/object:Gem::Dependency
70
- name: redis
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - '>='
74
- - !ruby/object:Gem::Version
75
- version: 3.0.2
76
- type: :runtime
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - '>='
81
- - !ruby/object:Gem::Version
82
- version: 3.0.2
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: fog
85
71
  requirement: !ruby/object:Gem::Requirement
@@ -143,13 +129,11 @@ executables:
143
129
  - riemann-munin
144
130
  - riemann-aws-billing
145
131
  - riemann-riak
146
- - riemann-redis-slowlog
147
132
  - riemann-varnish
148
133
  - riemann-haproxy
149
134
  - riemann-freeswitch
150
135
  - riemann-aws-status
151
136
  - riemann-nginx-status
152
- - riemann-redis
153
137
  - riemann-diskstats
154
138
  - riemann-health
155
139
  extensions: []
@@ -175,8 +159,6 @@ files:
175
159
  - bin/riemann-nginx-status
176
160
  - bin/riemann-proc
177
161
  - bin/riemann-rabbitmq
178
- - bin/riemann-redis
179
- - bin/riemann-redis-slowlog
180
162
  - bin/riemann-resmon
181
163
  - bin/riemann-riak
182
164
  - bin/riemann-riak-keys
data/bin/riemann-redis DELETED
@@ -1,71 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- # Gathers redis INFO statistics and submits them to Riemann.
4
-
5
- require File.expand_path('../../lib/riemann/tools', __FILE__)
6
-
7
- class Riemann::Tools::Redis
8
- include Riemann::Tools
9
- require 'redis'
10
-
11
- opt :redis_host, "Redis hostname", :default => 'localhost'
12
- opt :redis_port, "Redis port", :default => 6379
13
- opt :redis_password, "Redis password", :default => ''
14
- opt :redis_url, "Redis URL", :default => ''
15
- opt :redis_socket, "Redis socket", :default => ''
16
- opt :redis_section, "Redis INFO section", :default => 'default'
17
-
18
- STRING_VALUES = %w{ redis_version redis_git_sha1 redis_mode os
19
- multiplexing_api gcc_version run_id used_memory_human
20
- used_memory_peak_human mem_allocator
21
- rdb_last_bgsave_status aof_last_bgrewrite_status role }
22
-
23
- def initialize
24
- options = if opts[:redis_url] != ''
25
- { :url => opts[:redis_url] }
26
- elsif opts[:redis_socket] != ''
27
- { :path => opts[:redis_socket] }
28
- else
29
- { :host => opts[:redis_host], :port => opts[:redis_port] }
30
- end
31
- @redis = ::Redis.new(options)
32
- @redis.auth(opts[:redis_password]) unless opts[:redis_password] == ''
33
- @section = opts[:redis_section]
34
- end
35
-
36
- def tick
37
- begin
38
- @redis.info(@section).each do |property, value|
39
- data = {
40
- :host => opts[:redis_host].dup,
41
- :service => "redis #{property}",
42
- :metric => value.to_f,
43
- :state => value.to_s,
44
- :tags => ['redis']
45
- }
46
-
47
- if STRING_VALUES.include?(property) || property.match(/^db\d+/)
48
- if %w{ rdb_last_bgsave_status aof_last_bgrewrite_status }.include?(property)
49
- data[:state] = value
50
- else
51
- data[:description] = value
52
- end
53
- end
54
-
55
- if property == "run_id"
56
- data[:metric] = 0
57
- end
58
-
59
- report(data)
60
- end
61
- rescue ::Redis::CommandError => e
62
- if e.message == "ERR operation not permitted"
63
- @redis.auth(opts[:redis_password]) unless opts[:redis_password] == ''
64
- end
65
- end
66
-
67
- end
68
-
69
- end
70
-
71
- Riemann::Tools::Redis.run
@@ -1,44 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- # Gathers Redis SLOWLOG statistics and submits them to Riemann.
4
-
5
- require File.expand_path('../../lib/riemann/tools', __FILE__)
6
-
7
- class Riemann::Tools::RedisSlowlog
8
- include Riemann::Tools
9
- require 'redis'
10
-
11
- opt :redis_url, "Redis URL", :default => 'redis://127.0.0.1:6379/'
12
- opt :redis_password, "Redis password", :default => ''
13
- opt :slowlog_len, "Number of SLOWLOG entries to get", :default => 10
14
- opt :slowlog_reset, "Reset SLOWLOG after querying it", :default => false
15
-
16
- def initialize
17
- @redis = ::Redis.new(url: opts[:redis_url])
18
-
19
- @slowlog_len = opts[:slowlog_len]
20
- @slowlog_reset = opts[:slowlog_reset]
21
-
22
- @redis.auth(opts[:redis_password]) unless opts[:redis_password] == ''
23
- end
24
-
25
- def tick
26
- @redis.slowlog("GET", @slowlog_len).each do |id, timestamp, us, cmd|
27
- data = {
28
- :host => @redis.client.host,
29
- :service => "redis",
30
- :time => timestamp,
31
- :metric => us.to_f,
32
- :state => 'warning',
33
- :tags => ['redis', 'slowlog'],
34
- :description => cmd.inspect
35
- }
36
- report(data)
37
- end
38
-
39
- @redis.slowlog("RESET") if @slowlog_reset
40
- end
41
-
42
- end
43
-
44
- Riemann::Tools::RedisSlowlog.run