riemann-tools 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/riemann-dir-files-count +55 -0
- data/bin/riemann-dir-space +55 -0
- metadata +59 -39
- checksums.yaml +0 -7
@@ -0,0 +1,55 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# Gets the number of files present on a directory and submits it to riemann
|
4
|
+
|
5
|
+
require File.expand_path('../../lib/riemann/tools', __FILE__)
|
6
|
+
|
7
|
+
class Riemann::Tools::DirFilesCount
|
8
|
+
include Riemann::Tools
|
9
|
+
|
10
|
+
opt :directory, "", :default => '/var/log'
|
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"
|
14
|
+
opt :alert_on_missing, "Send a critical metric if the directory is missing?", :default => true
|
15
|
+
|
16
|
+
def initialize
|
17
|
+
@dir = opts.fetch(:directory)
|
18
|
+
@service_prefix = opts.fetch(:service_prefix)
|
19
|
+
@warning = opts.fetch(:warning, nil)
|
20
|
+
@critical = opts.fetch(:critical, nil)
|
21
|
+
@alert_on_missing = opts.fetch(:alert_on_missing)
|
22
|
+
end
|
23
|
+
|
24
|
+
def tick
|
25
|
+
if Dir.exists?(@dir)
|
26
|
+
metric = Dir.entries(@dir).size - 2
|
27
|
+
report(
|
28
|
+
:service => "#{@service_prefix} #{@dir}",
|
29
|
+
:metric => metric,
|
30
|
+
:state => state(metric),
|
31
|
+
:tags => ['dir_files_count']
|
32
|
+
)
|
33
|
+
elsif @alert_on_missing
|
34
|
+
report(
|
35
|
+
:service => "#{@service_prefix} #{@dir} missing",
|
36
|
+
:description => "#{@service_prefix} #{@dir} does not exist",
|
37
|
+
:metric => metric,
|
38
|
+
:state => 'critical',
|
39
|
+
:tags => ['dir_files_count']
|
40
|
+
)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def state(metric)
|
45
|
+
if @critical && metric > @critical
|
46
|
+
'critical'
|
47
|
+
elsif @warning && metric > @warning
|
48
|
+
'warning'
|
49
|
+
else
|
50
|
+
'ok'
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
Riemann::Tools::DirFilesCount.run
|
@@ -0,0 +1,55 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# Gathers the space used by a directory and submits it to riemann
|
4
|
+
|
5
|
+
require File.expand_path('../../lib/riemann/tools', __FILE__)
|
6
|
+
|
7
|
+
class Riemann::Tools::DirSpace
|
8
|
+
include Riemann::Tools
|
9
|
+
|
10
|
+
opt :directory, "", :default => '/var/log'
|
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)"
|
14
|
+
opt :alert_on_missing, "Send a critical metric if the directory is missing?", :default => true
|
15
|
+
|
16
|
+
def initialize
|
17
|
+
@dir = opts.fetch(:directory)
|
18
|
+
@service_prefix = opts.fetch(:service_prefix)
|
19
|
+
@warning = opts.fetch(:warning, nil)
|
20
|
+
@critical = opts.fetch(:critical, nil)
|
21
|
+
@alert_on_missing = opts.fetch(:alert_on_missing)
|
22
|
+
end
|
23
|
+
|
24
|
+
def tick
|
25
|
+
if Dir.exists?(@dir)
|
26
|
+
metric = `du '#{@dir}'`.lines.to_a.last.split("\t")[0].to_i
|
27
|
+
report(
|
28
|
+
:service => "#{@service_prefix} #{@dir}",
|
29
|
+
:metric => metric,
|
30
|
+
:state => state(metric),
|
31
|
+
:tags => ['dir_space']
|
32
|
+
)
|
33
|
+
elsif @alert_on_missing
|
34
|
+
report(
|
35
|
+
:service => "#{@service_prefix} #{@dir} missing",
|
36
|
+
:description => "#{@service_prefix} #{@dir} does not exist",
|
37
|
+
:metric => metric,
|
38
|
+
:state => 'critical',
|
39
|
+
:tags => ['dir_space']
|
40
|
+
)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def state(metric)
|
45
|
+
if @critical && metric > @critical
|
46
|
+
'critical'
|
47
|
+
elsif @warning && metric > @warning
|
48
|
+
'warning'
|
49
|
+
else
|
50
|
+
'ok'
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
Riemann::Tools::DirSpace.run
|
metadata
CHANGED
@@ -1,141 +1,158 @@
|
|
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.4
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Kyle Kingsbury
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
12
|
+
date: 2015-01-26 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: riemann-client
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
16
18
|
requirements:
|
17
|
-
- - '>='
|
19
|
+
- - ! '>='
|
18
20
|
- !ruby/object:Gem::Version
|
19
21
|
version: 0.2.2
|
20
22
|
type: :runtime
|
21
23
|
prerelease: false
|
22
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
23
26
|
requirements:
|
24
|
-
- - '>='
|
27
|
+
- - ! '>='
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: 0.2.2
|
27
30
|
- !ruby/object:Gem::Dependency
|
28
31
|
name: trollop
|
29
32
|
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
30
34
|
requirements:
|
31
|
-
- - '>='
|
35
|
+
- - ! '>='
|
32
36
|
- !ruby/object:Gem::Version
|
33
37
|
version: 1.16.2
|
34
38
|
type: :runtime
|
35
39
|
prerelease: false
|
36
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
37
42
|
requirements:
|
38
|
-
- - '>='
|
43
|
+
- - ! '>='
|
39
44
|
- !ruby/object:Gem::Version
|
40
45
|
version: 1.16.2
|
41
46
|
- !ruby/object:Gem::Dependency
|
42
47
|
name: munin-ruby
|
43
48
|
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
44
50
|
requirements:
|
45
|
-
- - '>='
|
51
|
+
- - ! '>='
|
46
52
|
- !ruby/object:Gem::Version
|
47
53
|
version: 0.2.1
|
48
54
|
type: :runtime
|
49
55
|
prerelease: false
|
50
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
51
58
|
requirements:
|
52
|
-
- - '>='
|
59
|
+
- - ! '>='
|
53
60
|
- !ruby/object:Gem::Version
|
54
61
|
version: 0.2.1
|
55
62
|
- !ruby/object:Gem::Dependency
|
56
63
|
name: yajl-ruby
|
57
64
|
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
58
66
|
requirements:
|
59
|
-
- - '>='
|
67
|
+
- - ! '>='
|
60
68
|
- !ruby/object:Gem::Version
|
61
69
|
version: 1.1.0
|
62
70
|
type: :runtime
|
63
71
|
prerelease: false
|
64
72
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
65
74
|
requirements:
|
66
|
-
- - '>='
|
75
|
+
- - ! '>='
|
67
76
|
- !ruby/object:Gem::Version
|
68
77
|
version: 1.1.0
|
69
78
|
- !ruby/object:Gem::Dependency
|
70
79
|
name: fog
|
71
80
|
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
72
82
|
requirements:
|
73
|
-
- - '>='
|
83
|
+
- - ! '>='
|
74
84
|
- !ruby/object:Gem::Version
|
75
85
|
version: 1.4.0
|
76
86
|
type: :runtime
|
77
87
|
prerelease: false
|
78
88
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
79
90
|
requirements:
|
80
|
-
- - '>='
|
91
|
+
- - ! '>='
|
81
92
|
- !ruby/object:Gem::Version
|
82
93
|
version: 1.4.0
|
83
94
|
- !ruby/object:Gem::Dependency
|
84
95
|
name: faraday
|
85
96
|
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
86
98
|
requirements:
|
87
|
-
- - '>='
|
99
|
+
- - ! '>='
|
88
100
|
- !ruby/object:Gem::Version
|
89
101
|
version: 0.8.5
|
90
102
|
type: :runtime
|
91
103
|
prerelease: false
|
92
104
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
93
106
|
requirements:
|
94
|
-
- - '>='
|
107
|
+
- - ! '>='
|
95
108
|
- !ruby/object:Gem::Version
|
96
109
|
version: 0.8.5
|
97
110
|
- !ruby/object:Gem::Dependency
|
98
111
|
name: nokogiri
|
99
112
|
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
100
114
|
requirements:
|
101
|
-
- - '>='
|
115
|
+
- - ! '>='
|
102
116
|
- !ruby/object:Gem::Version
|
103
117
|
version: 1.5.6
|
104
118
|
type: :runtime
|
105
119
|
prerelease: false
|
106
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
107
122
|
requirements:
|
108
|
-
- - '>='
|
123
|
+
- - ! '>='
|
109
124
|
- !ruby/object:Gem::Version
|
110
125
|
version: 1.5.6
|
111
126
|
description: Utilities which submit events to Riemann.
|
112
127
|
email: aphyr@aphyr.com
|
113
128
|
executables:
|
114
|
-
- riemann-
|
115
|
-
- riemann-
|
116
|
-
- riemann-
|
117
|
-
- riemann-elb-metrics
|
118
|
-
- riemann-net
|
119
|
-
- riemann-bench
|
120
|
-
- riemann-proc
|
121
|
-
- riemann-fd
|
129
|
+
- riemann-aws-status
|
130
|
+
- riemann-munin
|
131
|
+
- riemann-dir-space
|
122
132
|
- riemann-zookeeper
|
123
|
-
- riemann-apache-status
|
124
|
-
- riemann-cloudant
|
125
133
|
- riemann-resmon
|
126
|
-
- riemann-
|
127
|
-
- riemann-
|
128
|
-
- riemann-
|
129
|
-
- riemann-munin
|
134
|
+
- riemann-bench
|
135
|
+
- riemann-proc
|
136
|
+
- riemann-freeswitch
|
130
137
|
- riemann-aws-billing
|
138
|
+
- riemann-elb-metrics
|
131
139
|
- riemann-riak
|
140
|
+
- riemann-health
|
141
|
+
- riemann-dir-files-count
|
132
142
|
- riemann-varnish
|
143
|
+
- riemann-memcached
|
133
144
|
- riemann-haproxy
|
134
|
-
- riemann-
|
135
|
-
- riemann-
|
136
|
-
- riemann-nginx-status
|
145
|
+
- riemann-elasticsearch
|
146
|
+
- riemann-riak-keys
|
137
147
|
- riemann-diskstats
|
138
|
-
- riemann-
|
148
|
+
- riemann-fd
|
149
|
+
- riemann-riak-ring
|
150
|
+
- riemann-cloudant
|
151
|
+
- riemann-nginx-status
|
152
|
+
- riemann-rabbitmq
|
153
|
+
- riemann-kvminstance
|
154
|
+
- riemann-net
|
155
|
+
- riemann-apache-status
|
139
156
|
extensions: []
|
140
157
|
extra_rdoc_files: []
|
141
158
|
files:
|
@@ -145,6 +162,8 @@ files:
|
|
145
162
|
- bin/riemann-aws-status
|
146
163
|
- bin/riemann-bench
|
147
164
|
- bin/riemann-cloudant
|
165
|
+
- bin/riemann-dir-files-count
|
166
|
+
- bin/riemann-dir-space
|
148
167
|
- bin/riemann-diskstats
|
149
168
|
- bin/riemann-elasticsearch
|
150
169
|
- bin/riemann-elb-metrics
|
@@ -170,25 +189,26 @@ files:
|
|
170
189
|
homepage: https://github.com/aphyr/riemann-tools
|
171
190
|
licenses:
|
172
191
|
- MIT
|
173
|
-
metadata: {}
|
174
192
|
post_install_message:
|
175
193
|
rdoc_options: []
|
176
194
|
require_paths:
|
177
195
|
- lib
|
178
196
|
required_ruby_version: !ruby/object:Gem::Requirement
|
197
|
+
none: false
|
179
198
|
requirements:
|
180
|
-
- - '>='
|
199
|
+
- - ! '>='
|
181
200
|
- !ruby/object:Gem::Version
|
182
201
|
version: 1.8.7
|
183
202
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
203
|
+
none: false
|
184
204
|
requirements:
|
185
|
-
- - '>='
|
205
|
+
- - ! '>='
|
186
206
|
- !ruby/object:Gem::Version
|
187
207
|
version: '0'
|
188
208
|
requirements: []
|
189
209
|
rubyforge_project: riemann-tools
|
190
|
-
rubygems_version:
|
210
|
+
rubygems_version: 1.8.25
|
191
211
|
signing_key:
|
192
|
-
specification_version:
|
212
|
+
specification_version: 3
|
193
213
|
summary: Utilities which submit events to Riemann.
|
194
214
|
test_files: []
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: db9b835831c44292e608818f39aded205bc4f0f9
|
4
|
-
data.tar.gz: 0049cb2ffc88932a2f7b9528b1760a1e571fc99c
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: 67c75f0cdba4c515c26e0d097b8b6675c2572341dbc5cb21256f512abcbe89ec4ecf28a3e9bd43d97702923e5a119016fd02dc0706e8f95a381ba95ef4b9fa43
|
7
|
-
data.tar.gz: 471dbf8c04d0f35fb396e900ae4d64dc6de2e4c6cc16f92a4d3b5f76870d34577cc58b6b4ac306b85cb9a576b55db2a861d76cdc0bacd4502285a9036a00a820
|