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