arborist-snmp 0.6.2 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/arborist/monitor/snmp/disk.rb +45 -31
- data/lib/arborist/snmp.rb +2 -1
- metadata +20 -25
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1249bdfdca3585ad83e5257085356af249e49ddd5691d1e5b8cd77f792c81c9a
|
4
|
+
data.tar.gz: 3b85bd63b62caa5554ee76f3737556b07e970999cc7ddf0153fd51169e4b7e54
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61a8a588eb87e99848c41c312b3eaa690a4c65ffb13d565266f89bdb850790822d5ea26132e69e26133f5bfae1eb5ed4e57c7bbd0f06c52d9d0dacc034c1d115
|
7
|
+
data.tar.gz: bfd1b4c4b1d7feb5c6b1726f4c73748d0e357a27983f69c8441a5882495d9d725dc04bab7550da22827fd1a7fe3316f703dc75e409fef7d048f5a9847aa243c3
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
@@ -17,9 +17,10 @@ class Arborist::Monitor::SNMP::Disk
|
|
17
17
|
# OIDS required to pull disk information from net-snmp.
|
18
18
|
#
|
19
19
|
STORAGE_NET_SNMP = {
|
20
|
-
path:
|
20
|
+
path: '1.3.6.1.4.1.2021.9.1.2',
|
21
21
|
percent: '1.3.6.1.4.1.2021.9.1.9',
|
22
|
-
type:
|
22
|
+
type: '1.3.6.1.2.1.25.3.8.1.4',
|
23
|
+
access: '1.3.6.1.2.1.25.3.8.1.5'
|
23
24
|
}
|
24
25
|
|
25
26
|
# The OID that matches a local windows hard disk.
|
@@ -32,15 +33,21 @@ class Arborist::Monitor::SNMP::Disk
|
|
32
33
|
# OIDS required to pull disk information from Windows.
|
33
34
|
#
|
34
35
|
STORAGE_WINDOWS = {
|
35
|
-
type:
|
36
|
-
path:
|
36
|
+
type: '1.3.6.1.2.1.25.2.3.1.2',
|
37
|
+
path: '1.3.6.1.2.1.25.2.3.1.3',
|
37
38
|
total: '1.3.6.1.2.1.25.2.3.1.5',
|
38
|
-
used:
|
39
|
+
used: '1.3.6.1.2.1.25.2.3.1.6'
|
39
40
|
}
|
40
41
|
|
41
42
|
# The fallback warning capacity.
|
42
43
|
WARN_AT = 90
|
43
44
|
|
45
|
+
# Don't alert if a mount is readonly by default.
|
46
|
+
ALERT_READONLY = false
|
47
|
+
|
48
|
+
# Access mode meanings
|
49
|
+
ACCESS_READWRITE = 1
|
50
|
+
ACCESS_READONLY = 2
|
44
51
|
|
45
52
|
# Configurability API
|
46
53
|
#
|
@@ -48,6 +55,9 @@ class Arborist::Monitor::SNMP::Disk
|
|
48
55
|
# What percentage qualifies as a warning
|
49
56
|
setting :warn_at, default: WARN_AT
|
50
57
|
|
58
|
+
# Set down if the mounts are readonly?
|
59
|
+
setting :alert_readonly, default: ALERT_READONLY
|
60
|
+
|
51
61
|
# If non-empty, only these paths are included in checks.
|
52
62
|
#
|
53
63
|
setting :include do |val|
|
@@ -103,35 +113,42 @@ class Arborist::Monitor::SNMP::Disk
|
|
103
113
|
current_mounts = self.system =~ /windows\s+/i ? self.windows_disks( snmp ) : self.unix_disks( snmp )
|
104
114
|
config = self.identifiers[ host ].last['config'] || {}
|
105
115
|
warn_at = config[ 'warn_at' ] || self.class.warn_at
|
116
|
+
alert_readonly = config[ 'alert_readonly' ] || self.class.alert_readonly
|
106
117
|
|
107
|
-
self.log.
|
118
|
+
self.log.debug self.identifiers[ host ]
|
108
119
|
|
109
120
|
includes = self.format_mounts( config, 'include' ) || self.class.include
|
110
121
|
excludes = self.format_mounts( config, 'exclude' ) || self.class.exclude
|
111
122
|
|
112
|
-
current_mounts.reject! do |path,
|
123
|
+
current_mounts.reject! do |path, data|
|
113
124
|
path = path.to_s
|
114
125
|
excludes.match( path ) || ( includes && ! includes.match( path ) )
|
115
126
|
end
|
116
127
|
|
117
128
|
errors = []
|
118
129
|
warnings = []
|
119
|
-
current_mounts.each_pair do |path,
|
130
|
+
current_mounts.each_pair do |path, data|
|
120
131
|
warn = if warn_at.is_a?( Hash )
|
121
|
-
warn_at[ path ] ||
|
132
|
+
warn_at[ path ] || self.class.warn_at
|
122
133
|
else
|
123
134
|
warn_at
|
124
135
|
end
|
125
136
|
|
126
|
-
|
137
|
+
readonly = alert_readonly.is_a?( Hash ) ? alert_readonly[ path ] : alert_readonly
|
127
138
|
|
128
|
-
|
129
|
-
|
130
|
-
|
139
|
+
self.log.debug "%s:%s -> %p, warn at %d" % [ host, path, data, warn ]
|
140
|
+
|
141
|
+
if data[ :capacity ] >= warn.to_i
|
142
|
+
if data[ :capacity ] >= 100
|
143
|
+
errors << "%s at %d%% capacity" % [ path, data[ :capacity ] ]
|
131
144
|
else
|
132
|
-
warnings << "%s at %d%% capacity" % [ path,
|
145
|
+
warnings << "%s at %d%% capacity" % [ path, data[ :capacity ] ]
|
133
146
|
end
|
134
147
|
end
|
148
|
+
|
149
|
+
if readonly && data[ :accessmode ] == ACCESS_READONLY
|
150
|
+
errors << "%s is mounted read-only." % [ path ]
|
151
|
+
end
|
135
152
|
end
|
136
153
|
|
137
154
|
# Remove any past mounts that configuration exclusions should
|
@@ -160,23 +177,16 @@ class Arborist::Monitor::SNMP::Disk
|
|
160
177
|
### Fetch information for Windows systems.
|
161
178
|
###
|
162
179
|
def windows_disks( snmp )
|
163
|
-
|
164
|
-
STORAGE_WINDOWS[:path],
|
165
|
-
STORAGE_WINDOWS[:type],
|
166
|
-
STORAGE_WINDOWS[:total],
|
167
|
-
STORAGE_WINDOWS[:used]
|
168
|
-
]
|
169
|
-
|
170
|
-
paths = snmp.walk( oid: oids[0] ).each_with_object( [] ) do |(_, value), acc|
|
180
|
+
paths = snmp.walk( oid: STORAGE_WINDOWS[:path] ).each_with_object( [] ) do |(_, value), acc|
|
171
181
|
acc << value
|
172
182
|
end
|
173
|
-
types = snmp.walk( oid:
|
183
|
+
types = snmp.walk( oid: STORAGE_WINDOWS[:type] ).each_with_object( [] ) do |(_, value), acc|
|
174
184
|
acc << WINDOWS_DEVICES.include?( value )
|
175
185
|
end
|
176
|
-
totals = snmp.walk( oid:
|
186
|
+
totals = snmp.walk( oid: STORAGE_WINDOWS[:total] ).each_with_object( [] ) do |(_, value), acc|
|
177
187
|
acc << value
|
178
188
|
end
|
179
|
-
used = snmp.walk( oid:
|
189
|
+
used = snmp.walk( oid: STORAGE_WINDOWS[:used] ).each_with_object( [] ) do |(_, value), acc|
|
180
190
|
acc << value
|
181
191
|
end
|
182
192
|
|
@@ -185,7 +195,7 @@ class Arborist::Monitor::SNMP::Disk
|
|
185
195
|
next if totals[ idx ].zero?
|
186
196
|
next unless types[ idx ]
|
187
197
|
disks[ path ] ||= {}
|
188
|
-
disks[ path ] = (( used[idx].to_f / totals[idx] ) * 100).round( 1 )
|
198
|
+
disks[ path ][ :capacity ] = (( used[idx].to_f / totals[idx] ) * 100).round( 1 )
|
189
199
|
end
|
190
200
|
|
191
201
|
return disks
|
@@ -195,16 +205,20 @@ class Arborist::Monitor::SNMP::Disk
|
|
195
205
|
### Fetch information for Unix/MacOS systems.
|
196
206
|
###
|
197
207
|
def unix_disks( snmp )
|
198
|
-
|
199
|
-
|
208
|
+
paths = snmp.walk( oid: STORAGE_NET_SNMP[:path] ).each_with_object( [] ) do |(_, value), acc|
|
209
|
+
acc << value
|
210
|
+
end
|
211
|
+
capacities = snmp.walk( oid: STORAGE_NET_SNMP[:percent] ).each_with_object( [] ) do |(_, value), acc|
|
200
212
|
acc << value
|
201
213
|
end
|
202
|
-
|
214
|
+
accessmodes = snmp.walk( oid: STORAGE_NET_SNMP[:access] ).each_with_object( [] ) do |(_, value), acc|
|
203
215
|
acc << value
|
204
216
|
end
|
205
217
|
|
206
|
-
pairs = paths.
|
207
|
-
|
218
|
+
pairs = paths.each_with_object( {} ).with_index do |(p, acc), idx|
|
219
|
+
acc[p] = { capacity: capacities[idx], accessmode: accessmodes[idx] }
|
220
|
+
end
|
221
|
+
return pairs
|
208
222
|
end
|
209
223
|
|
210
224
|
end # class Arborist::Monitor::SNMP::Disk
|
data/lib/arborist/snmp.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# -*- ruby -*-
|
2
2
|
#encoding: utf-8
|
3
|
+
# vim: set noet nosta sw=4 ts=4 :
|
3
4
|
|
4
5
|
require 'loggability'
|
5
6
|
require 'arborist'
|
@@ -14,7 +15,7 @@ module Arborist::SNMP
|
|
14
15
|
|
15
16
|
|
16
17
|
# Package version
|
17
|
-
VERSION = '0.
|
18
|
+
VERSION = '0.7.0'
|
18
19
|
|
19
20
|
# Version control revision
|
20
21
|
REVISION = %q$Revision$
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arborist-snmp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mahlon E. Smith <mahlon@martini.nu>
|
@@ -11,31 +11,26 @@ bindir: bin
|
|
11
11
|
cert_chain:
|
12
12
|
- |
|
13
13
|
-----BEGIN CERTIFICATE-----
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
Mu2osihEB0GE0pOZJNpI6ow+0emwN/XvBKHpN9D2bjbvKetyQSrm0OniaZBXIGzW
|
33
|
-
Bg0JmajxUaGYWnz+QFADT+HLPmekxF3mB4+0ymZCHKPC+04h6RDjvkEOji6Jm+VB
|
34
|
-
JHjnceUEejS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
|
+
FoBVuDoVdlJf8ae11G8IPXnEHCT8S5b+MBSYd55V3aGQm4bKoZA3GmmD8Y0a+oxt
|
27
|
+
l2kkTvE0r1bBb/qYQI97AjnqzHByseBRoaHtJ12JtrDEdi8y4jd5AJt4aW+G/roD
|
28
|
+
I2/ymUodKw9Cteom0RdJNzBUJ+Bq+qFOy7mVKNIfhXRRFYEy11y1712FsJXqUEku
|
29
|
+
qr3lnAEvEy9hQila4NoJT2+aQEKsjVON9D3a727naKDFUcKDg6P4KqS+yOKgR+QH
|
30
|
+
D8llK3JPaqKXuJkbd8jKchDk0Q+fA8Klan5SSnm7pMD51QM1mPsVPm5bEw5ib0bn
|
31
|
+
oR3hTQ==
|
37
32
|
-----END CERTIFICATE-----
|
38
|
-
date: 2020-
|
33
|
+
date: 2020-08-01 00:00:00.000000000 Z
|
39
34
|
dependencies:
|
40
35
|
- !ruby/object:Gem::Dependency
|
41
36
|
name: arborist
|
metadata.gz.sig
CHANGED
Binary file
|