riemann-tools 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/riemann-aws-billing +79 -0
- data/bin/riemann-diskstats +1 -1
- data/bin/riemann-health +1 -1
- data/bin/riemann-varnish +36 -0
- data/bin/riemann-zookeeper +41 -0
- metadata +9 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ce8422ca7b04d401460ff2850f94c32626e796a
|
4
|
+
data.tar.gz: a65e55e277a680dbef2860716fc2c36eb2545e93
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 090cd5f4c835323168fe37b660238646c56d678d05e89b4484b201ba13e2620144c31b9ab27b49a91a230f49d612d44512fcca02aeaf254c0b47202adece4592
|
7
|
+
data.tar.gz: cc2bef99a2932aa9ee3ce3a8c20022d0814b6f185df81e6ed4596341c46ef35000f79037d99f0a1e2bf21f30231b5d749e57e0b8404199334717058566fcedf8
|
@@ -0,0 +1,79 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'fog'
|
3
|
+
|
4
|
+
|
5
|
+
require File.expand_path('../../lib/riemann/tools', __FILE__)
|
6
|
+
|
7
|
+
$0 = __FILE__
|
8
|
+
|
9
|
+
class Riemann::Tools::AWSBilling
|
10
|
+
include Riemann::Tools
|
11
|
+
|
12
|
+
opt :fog_credentials_file, "Fog credentials file", :type => String
|
13
|
+
opt :fog_credential, "Fog credentials to use", :type => String
|
14
|
+
|
15
|
+
opt :access_key, "AWS access key", :type => String
|
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"]
|
18
|
+
|
19
|
+
opt :time_start, "Start time in seconds of the metrics period (2hrs ago default)", :type => Integer, :default => 7200
|
20
|
+
opt :time_end, "End time in seconds of the metrics period ", :type => Integer, :default => 60
|
21
|
+
|
22
|
+
|
23
|
+
def initialize
|
24
|
+
if options[:fog_credentials_file]
|
25
|
+
Fog.credentials_path = opts[:fog_credentials_file]
|
26
|
+
Fog.credential = opts[:fog_credential].to_sym
|
27
|
+
@cloudwatch = Fog::AWS::CloudWatch.new
|
28
|
+
else
|
29
|
+
@cloudwatch = Fog::AWS::CloudWatch.new(:aws_secret_access_key => opts[:secret_key], :aws_access_key_id => opts[:access_key])
|
30
|
+
@start_time = (Time.now.utc - opts[:time_start]).iso8601
|
31
|
+
@end_time = (Time.now.utc - opts[:time_end]).iso8601
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def tick
|
36
|
+
opts[:services].each do |service|
|
37
|
+
data = @cloudwatch.get_metric_statistics({
|
38
|
+
'Statistics' => ["Maximum"],
|
39
|
+
'StartTime' => @start_time,
|
40
|
+
'EndTime' => @end_time,
|
41
|
+
'Period' => 3600,
|
42
|
+
'Unit' => "None",
|
43
|
+
'MetricName' => "EstimatedCharges",
|
44
|
+
'Namespace' => "AWS/Billing",
|
45
|
+
'Dimensions' => [
|
46
|
+
{
|
47
|
+
'Name' => "ServiceName",
|
48
|
+
'Value' => service
|
49
|
+
},
|
50
|
+
{
|
51
|
+
'Name' => "Currency",
|
52
|
+
'Value' => "USD"
|
53
|
+
}
|
54
|
+
]
|
55
|
+
}).body['GetMetricStatisticsResult']['Datapoints']
|
56
|
+
|
57
|
+
|
58
|
+
data.each do |metrics|
|
59
|
+
name = "AWScloudwatch.Billing." + service
|
60
|
+
value = metrics["Maximum"]
|
61
|
+
timestamp = metrics["Timestamp"].to_i
|
62
|
+
|
63
|
+
event = {
|
64
|
+
host: nil,
|
65
|
+
service: name,
|
66
|
+
time: timestamp,
|
67
|
+
description: "AWS Estimate Charges for #{service}",
|
68
|
+
tags: ["aws_billing"],
|
69
|
+
state: "ok",
|
70
|
+
metric: value
|
71
|
+
}
|
72
|
+
|
73
|
+
report event
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
Riemann::Tools::AWSBilling.run
|
data/bin/riemann-diskstats
CHANGED
@@ -16,7 +16,7 @@ class Riemann::Tools::Diskstats
|
|
16
16
|
def state
|
17
17
|
f = File.read('/proc/diskstats')
|
18
18
|
state = f.split("\n").reject { |d| d =~ /(ram|loop)/ }.inject({}) do |s, line|
|
19
|
-
if line =~ /^(?:\s+\d+){2}\s+([\w\d]+) (.*)$/
|
19
|
+
if line =~ /^(?:\s+\d+){2}\s+([\w\d\-]+) (.*)$/
|
20
20
|
dev = $1
|
21
21
|
|
22
22
|
['reads reqs',
|
data/bin/riemann-health
CHANGED
@@ -163,7 +163,7 @@ class Riemann::Tools::Health
|
|
163
163
|
end
|
164
164
|
|
165
165
|
def freebsd_load
|
166
|
-
m = `uptime`.split[
|
166
|
+
m = `uptime`.split(':')[-1].chomp.gsub(/\s+/,'').split(',')
|
167
167
|
load = m[0].to_f / @cores
|
168
168
|
if load > @limits[:load][:critical]
|
169
169
|
alert "load", :critical, load, "1-minute load average/core is #{load}"
|
data/bin/riemann-varnish
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# Reports varnish stats to Riemann.
|
4
|
+
|
5
|
+
require File.expand_path('../../lib/riemann/tools', __FILE__)
|
6
|
+
|
7
|
+
class Riemann::Tools::Varnish
|
8
|
+
include Riemann::Tools
|
9
|
+
|
10
|
+
opt :varnish_host, "Varnish hostname", :default => `hostname`.chomp
|
11
|
+
|
12
|
+
def initialize
|
13
|
+
@vstats = [ "client_conn",
|
14
|
+
"client_drop",
|
15
|
+
"client_req",
|
16
|
+
"cache_hit",
|
17
|
+
"cache_miss" ]
|
18
|
+
end
|
19
|
+
|
20
|
+
def tick
|
21
|
+
stats = `varnishstat -1 -f #{@vstats.join(",")}`
|
22
|
+
stats.each_line do |stat|
|
23
|
+
m = stat.split()
|
24
|
+
report(
|
25
|
+
:host => opts[:varnish_host].dup,
|
26
|
+
:service => "varnish #{m[0]}",
|
27
|
+
:metric => m[1].to_f,
|
28
|
+
:state => "ok",
|
29
|
+
:description => "#{m[3..-1].join(' ')}",
|
30
|
+
:tags => ["varnish"]
|
31
|
+
)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
Riemann::Tools::Varnish.run
|
@@ -0,0 +1,41 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# Gathers zookeeper STATS and submits them to Riemann.
|
4
|
+
|
5
|
+
require File.expand_path('../../lib/riemann/tools', __FILE__)
|
6
|
+
|
7
|
+
class Riemann::Tools::Zookeeper
|
8
|
+
include Riemann::Tools
|
9
|
+
require 'socket'
|
10
|
+
|
11
|
+
opt :zookeeper_host, "Zookeeper hostname", :default => 'localhost'
|
12
|
+
opt :zookeeper_port, "Zookeeper port", :default => 2181
|
13
|
+
|
14
|
+
def tick
|
15
|
+
sock = TCPSocket.new(opts[:zookeeper_host], opts[:zookeeper_port])
|
16
|
+
sock.sync = true
|
17
|
+
sock.print("mntr")
|
18
|
+
sock.flush
|
19
|
+
|
20
|
+
|
21
|
+
data = {}
|
22
|
+
while true
|
23
|
+
stats = sock.gets
|
24
|
+
|
25
|
+
break if stats.nil?
|
26
|
+
|
27
|
+
m = stats.match /^(\w+)\t+(.*)/
|
28
|
+
|
29
|
+
report(
|
30
|
+
:host => opts[ :zookeeper_host].dup,
|
31
|
+
:service => "zookeeper #{m[1]}",
|
32
|
+
:metric => m[2].to_f,
|
33
|
+
:state => 'ok',
|
34
|
+
:tags => ['zookeeper']
|
35
|
+
)
|
36
|
+
end
|
37
|
+
sock.close
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
Riemann::Tools::Zookeeper.run
|
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.
|
4
|
+
version: 0.2.1
|
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-
|
11
|
+
date: 2014-03-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: riemann-client
|
@@ -133,6 +133,7 @@ executables:
|
|
133
133
|
- riemann-bench
|
134
134
|
- riemann-proc
|
135
135
|
- riemann-fd
|
136
|
+
- riemann-zookeeper
|
136
137
|
- riemann-apache-status
|
137
138
|
- riemann-cloudant
|
138
139
|
- riemann-resmon
|
@@ -140,8 +141,10 @@ executables:
|
|
140
141
|
- riemann-kvminstance
|
141
142
|
- riemann-rabbitmq
|
142
143
|
- riemann-munin
|
144
|
+
- riemann-aws-billing
|
143
145
|
- riemann-riak
|
144
146
|
- riemann-redis-slowlog
|
147
|
+
- riemann-varnish
|
145
148
|
- riemann-haproxy
|
146
149
|
- riemann-freeswitch
|
147
150
|
- riemann-aws-status
|
@@ -154,6 +157,7 @@ extra_rdoc_files: []
|
|
154
157
|
files:
|
155
158
|
- lib/riemann/tools.rb
|
156
159
|
- bin/riemann-apache-status
|
160
|
+
- bin/riemann-aws-billing
|
157
161
|
- bin/riemann-aws-status
|
158
162
|
- bin/riemann-bench
|
159
163
|
- bin/riemann-cloudant
|
@@ -177,6 +181,8 @@ files:
|
|
177
181
|
- bin/riemann-riak
|
178
182
|
- bin/riemann-riak-keys
|
179
183
|
- bin/riemann-riak-ring
|
184
|
+
- bin/riemann-varnish
|
185
|
+
- bin/riemann-zookeeper
|
180
186
|
- LICENSE
|
181
187
|
- README.markdown
|
182
188
|
homepage: https://github.com/aphyr/riemann-tools
|
@@ -199,7 +205,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
199
205
|
version: '0'
|
200
206
|
requirements: []
|
201
207
|
rubyforge_project: riemann-tools
|
202
|
-
rubygems_version: 2.
|
208
|
+
rubygems_version: 2.0.14
|
203
209
|
signing_key:
|
204
210
|
specification_version: 4
|
205
211
|
summary: Utilities which submit events to Riemann.
|