riemann-tools 0.2.5 → 0.2.6
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.
- data/bin/riemann-aws-rds-status +48 -0
- data/bin/riemann-dir-files-count +2 -2
- data/bin/riemann-dir-space +2 -2
- data/bin/riemann-net +8 -0
- data/bin/riemann-ntp +38 -0
- data/bin/riemann-proc +4 -3
- data/bin/riemann-rabbitmq +3 -3
- data/bin/riemann-varnish +20 -2
- metadata +6 -2
@@ -0,0 +1,48 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'rubygems'
|
3
|
+
require 'fog'
|
4
|
+
require 'date'
|
5
|
+
require 'time'
|
6
|
+
require 'json'
|
7
|
+
|
8
|
+
require File.expand_path('../../lib/riemann/tools', __FILE__)
|
9
|
+
|
10
|
+
$0 = __FILE__ # Let's not expose our AWS keys in the process list
|
11
|
+
|
12
|
+
class Riemann::Tools::AWS
|
13
|
+
include Riemann::Tools
|
14
|
+
|
15
|
+
opt :access_key, "AWS access key", :type => String
|
16
|
+
opt :secret_key, "Secret access key", :type => String
|
17
|
+
opt :region, "AWS region", :type => String, :default => 'eu-west-1'
|
18
|
+
opt :dbinstance_identifier, "DBInstanceIdentifier", :type => String
|
19
|
+
def initialize
|
20
|
+
abort "FATAL: specify a DB instance name, see --help for usage" unless opts[:dbinstance_identifier]
|
21
|
+
@cloudwatch = Fog::AWS::CloudWatch.new(:aws_access_key_id => opts[:access_key],
|
22
|
+
:aws_secret_access_key => opts[:secret_key],
|
23
|
+
:region => opts[:region])
|
24
|
+
end
|
25
|
+
|
26
|
+
def tick
|
27
|
+
time = Time.new
|
28
|
+
['DatabaseConnections', 'FreeableMemory', 'FreeStorageSpace', 'NetworkReceiveThroughput', 'NetworkTransmitThroughput', 'ReadThroughput', 'CPUUtilization'].each do |metric|
|
29
|
+
result = @cloudwatch.get_metric_statistics({"Namespace" => 'AWS/RDS', "MetricName" => "#{metric}", "Statistics" => 'Average', "Dimensions" => [{"Name" => "DBInstanceIdentifier", "Value" => "#{opts[:dbinstance_identifier]}"}], "StartTime" => (time-120).to_time.iso8601, "EndTime" => time.to_time.iso8601, "Period" => 60})
|
30
|
+
metricsResult = result.data[:body]['GetMetricStatisticsResult']
|
31
|
+
puts JSON.dump(metricsResult)
|
32
|
+
if (metricsResult['Datapoints'].length>0)
|
33
|
+
datapoint = metricsResult['Datapoints'][0]
|
34
|
+
ev = {:metric => datapoint['Average'],
|
35
|
+
:service => "#{opts[:dbinstance_identifier]}.#{metric} (#{datapoint['Unit']})",
|
36
|
+
:description => JSON.dump(metricsResult),
|
37
|
+
:state => "ok",
|
38
|
+
:ttl => 300}
|
39
|
+
|
40
|
+
|
41
|
+
report ev
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
Riemann::Tools::AWS.run
|
data/bin/riemann-dir-files-count
CHANGED
@@ -9,8 +9,8 @@ class Riemann::Tools::DirFilesCount
|
|
9
9
|
|
10
10
|
opt :directory, "", :default => '/var/log'
|
11
11
|
opt :service_prefix, "The first part of the service name, before the directory path", :default => "dir-files-count"
|
12
|
-
opt :warning, "Dir files number warning threshold"
|
13
|
-
opt :critical, "Dir files number critical threshold"
|
12
|
+
opt :warning, "Dir files number warning threshold", :type => Integer
|
13
|
+
opt :critical, "Dir files number critical threshold", :type => Integer
|
14
14
|
opt :alert_on_missing, "Send a critical metric if the directory is missing?", :default => true
|
15
15
|
|
16
16
|
def initialize
|
data/bin/riemann-dir-space
CHANGED
@@ -9,8 +9,8 @@ class Riemann::Tools::DirSpace
|
|
9
9
|
|
10
10
|
opt :directory, "", :default => '/var/log'
|
11
11
|
opt :service_prefix, "The first part of the service name, before the directory path", :default => "dir-space"
|
12
|
-
opt :warning, "Dir space warning threshold (in bytes)"
|
13
|
-
opt :critical, "Dir space critical threshold (in bytes)"
|
12
|
+
opt :warning, "Dir space warning threshold (in bytes)", :type => Integer
|
13
|
+
opt :critical, "Dir space critical threshold (in bytes)", :type => Integer
|
14
14
|
opt :alert_on_missing, "Send a critical metric if the directory is missing?", :default => true
|
15
15
|
|
16
16
|
def initialize
|
data/bin/riemann-net
CHANGED
@@ -67,7 +67,15 @@ class Riemann::Tools::Net
|
|
67
67
|
state = self.state
|
68
68
|
|
69
69
|
if @old_state
|
70
|
+
# Report services from `@old_state` that don't exist in `state` as expired
|
71
|
+
@old_state.reject { |k| state.has_key?(k) }.each do |service, metric|
|
72
|
+
report(:service => service.dup, :state => 'expired')
|
73
|
+
end
|
74
|
+
|
75
|
+
# Report delta for services that have values in both `@old_state` and `state`
|
70
76
|
state.each do |service, metric|
|
77
|
+
next unless @old_state.has_key?(service)
|
78
|
+
|
71
79
|
delta = metric - @old_state[service]
|
72
80
|
svc_state = case service
|
73
81
|
when /drop$/
|
data/bin/riemann-ntp
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# Reports NTP stats to Riemann.
|
4
|
+
|
5
|
+
require File.expand_path('../../lib/riemann/tools', __FILE__)
|
6
|
+
|
7
|
+
class Riemann::Tools::Ntp
|
8
|
+
include Riemann::Tools
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
@hostname = `hostname`.chomp
|
12
|
+
end
|
13
|
+
|
14
|
+
def tick
|
15
|
+
stats = `ntpq -p -n`
|
16
|
+
stats.each_line do |stat|
|
17
|
+
m = stat.split()
|
18
|
+
next if m.grep(/^===/).any? || m.grep(/^remote/).any?
|
19
|
+
@ntp_host = m[0].gsub("*","").gsub("-","").gsub("+","")
|
20
|
+
send("delay",m[7])
|
21
|
+
send("offset",m[8])
|
22
|
+
send("jitter",m[9])
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def send(type,metric)
|
27
|
+
report(
|
28
|
+
:host => @hostname,
|
29
|
+
:service => "ntp peer #{@ntp_host} #{type}",
|
30
|
+
:metric => metric.to_f,
|
31
|
+
:state => "ok",
|
32
|
+
:description => "ntp peer #{@ntp_host} #{type}",
|
33
|
+
:tags => ["ntp"]
|
34
|
+
)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
Riemann::Tools::Ntp.run
|
data/bin/riemann-proc
CHANGED
@@ -32,11 +32,12 @@ class Riemann::Tools::Proc
|
|
32
32
|
|
33
33
|
def linux_proc
|
34
34
|
process = opts[:proc_regex]
|
35
|
-
|
35
|
+
found = `ps axo args | grep '#{process}' | grep -v grep | grep -v riemann-proc`
|
36
|
+
running = found.count("\n")
|
36
37
|
if running > @limits[:critical][:max] or running < @limits[:critical][:min]
|
37
|
-
alert "proc #{process}", :critical, running, "process #{process} is running #{running} instances"
|
38
|
+
alert "proc #{process}", :critical, running, "process #{process} is running #{running} instances:\n" + found
|
38
39
|
else
|
39
|
-
alert "proc #{process}", :ok, running, "process #{process} is running #{running} instances"
|
40
|
+
alert "proc #{process}", :ok, running, "process #{process} is running #{running} instances:\n" + found
|
40
41
|
end
|
41
42
|
end
|
42
43
|
|
data/bin/riemann-rabbitmq
CHANGED
@@ -107,11 +107,11 @@ class Riemann::Tools::Rabbitmq
|
|
107
107
|
svc = "rabbitmq.queue.#{queue['vhost']}.#{queue['name']}"
|
108
108
|
errs = []
|
109
109
|
|
110
|
-
if queue['messages_ready'] > 0 and queue['consumers'] == 0
|
110
|
+
if queue['messages_ready']!=nil and queue['messages_ready'] > 0 and queue['consumers'] == 0
|
111
111
|
errs << "Queue has jobs but no consumers"
|
112
112
|
end
|
113
113
|
|
114
|
-
if (max_size_check_filter.nil? or queue['name'] !~ max_size_check_filter) and queue['messages_ready'] > options[:max_queue_size]
|
114
|
+
if (max_size_check_filter.nil? or queue['name'] !~ max_size_check_filter) and queue['messages_ready']!=nil and queue['messages_ready'] > options[:max_queue_size]
|
115
115
|
errs << "Queue has #{queue['messages_ready']} jobs"
|
116
116
|
end
|
117
117
|
|
@@ -142,7 +142,7 @@ class Riemann::Tools::Rabbitmq
|
|
142
142
|
|
143
143
|
stats.each_pair do |k,v|
|
144
144
|
service = "#{svc}.#{k}"
|
145
|
-
if k =~ /details$/
|
145
|
+
if k =~ /details$/ and v!=nil
|
146
146
|
metric = v['rate']
|
147
147
|
else
|
148
148
|
metric = v
|
data/bin/riemann-varnish
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
# Reports varnish stats to Riemann.
|
4
4
|
|
5
|
+
require 'open3'
|
5
6
|
require File.expand_path('../../lib/riemann/tools', __FILE__)
|
6
7
|
|
7
8
|
class Riemann::Tools::Varnish
|
@@ -10,15 +11,32 @@ class Riemann::Tools::Varnish
|
|
10
11
|
opt :varnish_host, "Varnish hostname", :default => `hostname`.chomp
|
11
12
|
|
12
13
|
def initialize
|
13
|
-
|
14
|
+
cmd = 'varnishstat -V'
|
15
|
+
Open3.popen3(cmd) do |stdin, stdout, stderr, wait_thr|
|
16
|
+
@ver = /varnishstat \(varnish-(\d+)/.match(stderr.read)[1].to_i
|
17
|
+
end
|
18
|
+
|
19
|
+
if @ver >= 4
|
20
|
+
@vstats = [ "MAIN.sess_conn",
|
21
|
+
"MAIN.sess_drop ",
|
22
|
+
"MAIN.client_req",
|
23
|
+
"MAIN.cache_hit",
|
24
|
+
"MAIN.cache_miss" ]
|
25
|
+
else
|
26
|
+
@vstats = [ "client_conn",
|
14
27
|
"client_drop",
|
15
28
|
"client_req",
|
16
29
|
"cache_hit",
|
17
30
|
"cache_miss" ]
|
31
|
+
end
|
18
32
|
end
|
19
33
|
|
20
34
|
def tick
|
21
|
-
|
35
|
+
if @ver >= 4
|
36
|
+
stats = `varnishstat -1 -f #{@vstats.join(" -f ")}`
|
37
|
+
else
|
38
|
+
stats = `varnishstat -1 -f #{@vstats.join(",")}`
|
39
|
+
end
|
22
40
|
stats.each_line do |stat|
|
23
41
|
m = stat.split()
|
24
42
|
report(
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: riemann-tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-04-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: riemann-client
|
@@ -132,6 +132,7 @@ executables:
|
|
132
132
|
- riemann-zookeeper
|
133
133
|
- riemann-resmon
|
134
134
|
- riemann-bench
|
135
|
+
- riemann-aws-rds-status
|
135
136
|
- riemann-proc
|
136
137
|
- riemann-freeswitch
|
137
138
|
- riemann-aws-billing
|
@@ -150,6 +151,7 @@ executables:
|
|
150
151
|
- riemann-cloudant
|
151
152
|
- riemann-nginx-status
|
152
153
|
- riemann-rabbitmq
|
154
|
+
- riemann-ntp
|
153
155
|
- riemann-kvminstance
|
154
156
|
- riemann-net
|
155
157
|
- riemann-apache-status
|
@@ -159,6 +161,7 @@ files:
|
|
159
161
|
- lib/riemann/tools.rb
|
160
162
|
- bin/riemann-apache-status
|
161
163
|
- bin/riemann-aws-billing
|
164
|
+
- bin/riemann-aws-rds-status
|
162
165
|
- bin/riemann-aws-status
|
163
166
|
- bin/riemann-bench
|
164
167
|
- bin/riemann-cloudant
|
@@ -176,6 +179,7 @@ files:
|
|
176
179
|
- bin/riemann-munin
|
177
180
|
- bin/riemann-net
|
178
181
|
- bin/riemann-nginx-status
|
182
|
+
- bin/riemann-ntp
|
179
183
|
- bin/riemann-proc
|
180
184
|
- bin/riemann-rabbitmq
|
181
185
|
- bin/riemann-resmon
|