137 -------- |
138 -------- |
138 |
139 |
139 In the simplest form, using default behaviors and settings, here's an |
140 In the simplest form, using default behaviors and settings, here's an |
140 example Monitor configuration: |
141 example Monitor configuration: |
141 |
142 |
142 require 'arborist/snmp' |
143 ``` |
143 |
144 require 'arborist/snmp' |
144 Arborist::Monitor 'cpu load check', :cpu do |
145 |
145 every 1.minute |
146 Arborist::Monitor 'cpu load check', :cpu do |
146 match type: 'resource', category: 'cpu' |
147 every 1.minute |
147 exec( Arborist::Monitor::SNMP::CPU ) |
148 match type: 'resource', category: 'cpu' |
148 end |
149 exec( Arborist::Monitor::SNMP::CPU ) |
149 |
150 end |
150 Arborist::Monitor 'partition capacity', :disk do |
151 |
151 every 1.minute |
152 Arborist::Monitor 'partition capacity', :disk do |
152 match type: 'resource', category: 'disk' |
153 every 1.minute |
153 exec( Arborist::Monitor::SNMP::Disk ) |
154 match type: 'resource', category: 'disk' |
154 end |
155 exec( Arborist::Monitor::SNMP::Disk ) |
155 |
156 end |
156 Arborist::Monitor 'process checks', :proc do |
157 |
157 every 1.minute |
158 Arborist::Monitor 'process checks', :proc do |
158 match type: 'resource', category: 'process' |
159 every 1.minute |
159 exec( Arborist::Monitor::SNMP::Process ) |
160 match type: 'resource', category: 'process' |
160 end |
161 exec( Arborist::Monitor::SNMP::Process ) |
161 |
162 end |
162 Arborist::Monitor 'memory', :memory do |
163 |
163 every 1.minute |
164 Arborist::Monitor 'memory', :memory do |
164 match type: 'resource', category: 'memory' |
165 every 1.minute |
165 exec( Arborist::Monitor::SNMP::Memory ) |
166 match type: 'resource', category: 'memory' |
166 end |
167 exec( Arborist::Monitor::SNMP::Memory ) |
167 |
168 end |
|
169 ``` |
168 |
170 |
169 Additionally, if you'd like these SNMP monitors to rely on the SNMP |
171 Additionally, if you'd like these SNMP monitors to rely on the SNMP |
170 service itself, you can add a UDP check for that. |
172 service itself, you can add a UDP check for that. |
171 |
173 |
172 Arborist::Monitor 'udp service checks', :udp do |
174 ``` |
173 every 30.seconds |
175 Arborist::Monitor 'udp service checks', :udp do |
174 match type: 'service', protocol: 'udp' |
176 every 30.seconds |
175 exec( Arborist::Monitor::Socket::UDP ) |
177 match type: 'service', protocol: 'udp' |
176 end |
178 exec( Arborist::Monitor::Socket::UDP ) |
|
179 end |
|
180 ``` |
177 |
181 |
178 |
182 |
179 And a default node declaration: |
183 And a default node declaration: |
180 |
184 |
181 |
185 ``` |
182 Arborist::Host 'example' do |
186 Arborist::Host 'example' do |
183 description 'An example host' |
187 description 'An example host' |
184 address 'demo.example.com' |
188 address 'demo.example.com' |
185 |
189 |
186 resource 'cpu' |
190 resource 'cpu' |
187 resource 'memory' |
191 resource 'memory' |
188 resource 'disk' |
192 resource 'disk' |
189 end |
193 end |
|
194 ``` |
190 |
195 |
191 |
196 |
192 |
197 |
193 All configuration can be overridden from the defaults using the `config` |
198 All configuration can be overridden from the defaults using the `config` |
194 pragma, per node. Here's a more elaborate example that performs the following: |
199 pragma, per node. Here's a more elaborate example that performs the following: |
198 * Ensure the 'important' processing is running with the '--production' flag. |
203 * Ensure the 'important' processing is running with the '--production' flag. |
199 * Warns at 95% memory utilization OR 10% swap. |
204 * Warns at 95% memory utilization OR 10% swap. |
200 |
205 |
201 - |
206 - |
202 |
207 |
203 Arborist::Host 'example' do |
208 ``` |
204 description 'An example host' |
209 Arborist::Host 'example' do |
205 address 'demo.example.com' |
210 description 'An example host' |
206 |
211 address 'demo.example.com' |
207 service 'snmp', protocol: 'udp' |
212 |
208 |
213 service 'snmp', protocol: 'udp' |
209 resource 'cpu', description: 'machine cpu load' do |
214 |
210 depends_on 'example-snmp' |
215 resource 'cpu', description: 'machine cpu load' do |
211 end |
216 depends_on 'example-snmp' |
212 |
217 end |
213 resource 'memory', description: 'machine ram and swap' do |
218 |
214 depends_on 'example-snmp' |
219 resource 'memory', description: 'machine ram and swap' do |
215 config physical_warn_at: 95, swap_warn_at: 10 |
220 depends_on 'example-snmp' |
216 end |
221 config physical_warn_at: 95, swap_warn_at: 10 |
217 |
222 end |
218 resource 'disk', description: 'partition capacity' do |
223 |
219 depends_on 'example-snmp' |
224 resource 'disk', description: 'partition capacity' do |
220 config \ |
225 depends_on 'example-snmp' |
221 include: [ |
226 config \ |
222 '^/tmp', |
227 include: [ |
223 '^/var' |
228 '^/tmp', |
224 ], |
229 '^/var' |
225 warn_at: { |
230 ], |
226 '/tmp' => 50, |
231 warn_at: { |
227 '/var' => 80 |
232 '/tmp' => 50, |
228 } |
233 '/var' => 80 |
229 end |
234 } |
230 |
235 end |
231 resource 'process' do |
236 |
232 depends_on 'example-snmp' |
237 resource 'process' do |
233 config check: 'important --production' |
238 depends_on 'example-snmp' |
234 end |
239 config check: 'important --production' |
235 end |
240 end |
236 |
241 end |
|
242 ``` |
237 |
243 |
238 |
244 |
239 ## License |
245 ## License |
240 |
246 |
241 Copyright (c) 2016-2018 Michael Granger and Mahlon E. Smith |
247 Copyright (c) 2016-2018 Michael Granger and Mahlon E. Smith |