68 |
68 |
69 |
69 |
70 ### Return the properties used by this monitor. |
70 ### Return the properties used by this monitor. |
71 ### |
71 ### |
72 def self::node_properties |
72 def self::node_properties |
73 return USED_PROPERTIES |
73 used_properties = USED_PROPERTIES.dup |
|
74 used_properties << :mounts |
|
75 return used_properties |
74 end |
76 end |
75 |
77 |
76 |
78 |
77 ### Class #run creates a new instance and immediately runs it. |
79 ### Class #run creates a new instance and immediately runs it. |
78 ### |
80 ### |
96 |
98 |
97 ### Collect mount point usage for +host+ from an existing (and open) |
99 ### Collect mount point usage for +host+ from an existing (and open) |
98 ### +snmp+ connection. |
100 ### +snmp+ connection. |
99 ### |
101 ### |
100 def gather_disks( host, snmp ) |
102 def gather_disks( host, snmp ) |
101 mounts = self.system =~ /windows\s+/i ? self.windows_disks( snmp ) : self.unix_disks( snmp ) |
103 current_mounts = self.system =~ /windows\s+/i ? self.windows_disks( snmp ) : self.unix_disks( snmp ) |
102 config = self.identifiers[ host ].last || {} |
104 config = self.identifiers[ host ].last['config'] || {} |
103 warn_at = config[ 'warn_at' ] || self.class.warn_at |
105 warn_at = config[ 'warn_at' ] || self.class.warn_at |
|
106 |
|
107 self.log.warn self.identifiers[ host ] |
104 |
108 |
105 includes = self.format_mounts( config, 'include' ) || self.class.include |
109 includes = self.format_mounts( config, 'include' ) || self.class.include |
106 excludes = self.format_mounts( config, 'exclude' ) || self.class.exclude |
110 excludes = self.format_mounts( config, 'exclude' ) || self.class.exclude |
107 |
111 |
108 mounts.reject! do |path, percentage| |
112 current_mounts.reject! do |path, percentage| |
109 path = path.to_s |
113 path = path.to_s |
110 excludes.match( path ) || ( includes && ! includes.match( path ) ) |
114 excludes.match( path ) || ( includes && ! includes.match( path ) ) |
111 end |
115 end |
112 |
116 |
113 errors = [] |
117 errors = [] |
114 warnings = [] |
118 warnings = [] |
115 mounts.each_pair do |path, percentage| |
119 current_mounts.each_pair do |path, percentage| |
116 |
|
117 warn = if warn_at.is_a?( Hash ) |
120 warn = if warn_at.is_a?( Hash ) |
118 warn_at[ path ] || WARN_AT |
121 warn_at[ path ] || WARN_AT |
119 else |
122 else |
120 warn_at |
123 warn_at |
121 end |
124 end |
129 warnings << "%s at %d%% capacity" % [ path, percentage ] |
132 warnings << "%s at %d%% capacity" % [ path, percentage ] |
130 end |
133 end |
131 end |
134 end |
132 end |
135 end |
133 |
136 |
|
137 # Remove any past mounts that configuration exclusions should |
|
138 # now omit. |
|
139 mounts = self.identifiers[ host ].last[ 'mounts' ] || {} |
|
140 mounts.keys.each{|k| mounts[k] = nil } |
|
141 |
|
142 mounts.merge!( current_mounts ) |
|
143 |
134 self.results[ host ] = { mounts: mounts } |
144 self.results[ host ] = { mounts: mounts } |
135 self.results[ host ][ :error ] = errors.join(', ') unless errors.empty? |
145 self.results[ host ][ :error ] = errors.join(', ') unless errors.empty? |
136 self.results[ host ][ :warning ] = warnings.join(', ') unless warnings.empty? |
146 self.results[ host ][ :warning ] = warnings.join(', ') unless warnings.empty? |
137 end |
147 end |
138 |
148 |