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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4228ee82fe30505164e68c53d64f067c0ff3a2cff6fc1f9b58b573eea6b6dfb9
4
- data.tar.gz: 680f22d6e97ece0699cf02851d698fdb478588239b9c0a921ef72909dc1dd3dc
3
+ metadata.gz: 1249bdfdca3585ad83e5257085356af249e49ddd5691d1e5b8cd77f792c81c9a
4
+ data.tar.gz: 3b85bd63b62caa5554ee76f3737556b07e970999cc7ddf0153fd51169e4b7e54
5
5
  SHA512:
6
- metadata.gz: bf3c4613ca94861b2744e8e461e70142701c1205d07169fc05de0fc7111b22382e34414804fde1bf399eca2363d206b91efe20bfbe2b5941ad3b22c8c9f4c52b
7
- data.tar.gz: 7d089aa2b0bac1a86118659c0aa4efb82b50363f13588d21ecb1359c62650df55a7016e0d47545824c4d7a2d04adba67c8dd6e393fcc7b8516a20a5cdb43a81a
6
+ metadata.gz: 61a8a588eb87e99848c41c312b3eaa690a4c65ffb13d565266f89bdb850790822d5ea26132e69e26133f5bfae1eb5ed4e57c7bbd0f06c52d9d0dacc034c1d115
7
+ data.tar.gz: bfd1b4c4b1d7feb5c6b1726f4c73748d0e357a27983f69c8441a5882495d9d725dc04bab7550da22827fd1a7fe3316f703dc75e409fef7d048f5a9847aa243c3
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: '1.3.6.1.4.1.2021.9.1.2',
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: '1.3.6.1.2.1.25.3.8.1.4'
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: '1.3.6.1.2.1.25.2.3.1.2',
36
- path: '1.3.6.1.2.1.25.2.3.1.3',
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: '1.3.6.1.2.1.25.2.3.1.6'
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.warn self.identifiers[ host ]
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, percentage|
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, percentage|
130
+ current_mounts.each_pair do |path, data|
120
131
  warn = if warn_at.is_a?( Hash )
121
- warn_at[ path ] || WARN_AT
132
+ warn_at[ path ] || self.class.warn_at
122
133
  else
123
134
  warn_at
124
135
  end
125
136
 
126
- self.log.debug "%s:%s -> at %d, warn at %d" % [ host, path, percentage, warn ]
137
+ readonly = alert_readonly.is_a?( Hash ) ? alert_readonly[ path ] : alert_readonly
127
138
 
128
- if percentage >= warn.to_i
129
- if percentage >= 100
130
- errors << "%s at %d%% capacity" % [ path, percentage ]
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, percentage ]
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
- oids = [
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: oids[1] ).each_with_object( [] ) do |(_, value), acc|
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: oids[2] ).each_with_object( [] ) do |(_, value), acc|
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: oids[3] ).each_with_object( [] ) do |(_, value), acc|
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
- oids = [ STORAGE_NET_SNMP[:path], STORAGE_NET_SNMP[:percent] ]
199
- paths = snmp.walk( oid: oids.first ).each_with_object( [] ) do |(_, value), acc|
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
- capacities = snmp.walk( oid: oids.last ).each_with_object( [] ) do |(_, value), acc|
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.zip( capacities )
207
- return Hash[ *pairs.flatten ]
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
@@ -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.6.2'
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.6.2
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
- MIIENDCCApygAwIBAgIBATANBgkqhkiG9w0BAQsFADAiMSAwHgYDVQQDDBdtYWhs
15
- b24vREM9bWFydGluaS9EQz1udTAeFw0yMDAyMTkyMTU4NDBaFw0yMTAyMTgyMTU4
16
- NDBaMCIxIDAeBgNVBAMMF21haGxvbi9EQz1tYXJ0aW5pL0RDPW51MIIBojANBgkq
17
- hkiG9w0BAQEFAAOCAY8AMIIBigKCAYEA3cz7ILM8n+Y5nvz7mVRVqE8LusWdT8NX
18
- nlnETynDndenI+a2S3j22DR+U4ooGUjuCHE3iR1CVmTDGbxFfNRfmnC1AN9Hybat
19
- ewW+onvMBye7yfO0bJB5vkqaW5vd35rzquOffgBtJMo7rPRu6pX8RkL34Wnew4J7
20
- POooUcYbWSAO934HSCUC8wVm6b4v/ejVF1Lk44Dz45jtMqtR7KTAtpipdbTXAarO
21
- HQy3eVes/0oTqhk4CP50r1K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gR+QH
30
+ D8llK3JPaqKXuJkbd8jKchDk0Q+fA8Klan5SSnm7pMD51QM1mPsVPm5bEw5ib0bn
31
+ oR3hTQ==
37
32
  -----END CERTIFICATE-----
38
- date: 2020-04-28 00:00:00.000000000 Z
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