README.md
changeset 11 9187008b0989
parent 10 794cd469a1a2
child 14 d5cb8bd33170
equal deleted inserted replaced
10:794cd469a1a2 11:9187008b0989
    47 Global configuration overrides can be added to the Arborist config file,
    47 Global configuration overrides can be added to the Arborist config file,
    48 under the `snmp` key.
    48 under the `snmp` key.
    49 
    49 
    50 The defaults are as follows:
    50 The defaults are as follows:
    51 
    51 
    52 	arborist:
    52 ```
    53 	  snmp:
    53 arborist:
    54 		timeout: 2
    54   snmp:
    55 		retries: 1
    55 	timeout: 2
    56 		community: public
    56 	retries: 1
    57 		version: 2c
    57 	community: public
    58 		port: 161
    58 	version: 2c
    59 		batchsize: 25
    59 	port: 161
    60 		cpu:
    60 	batchsize: 25
    61 		  warn_at: 80
    61 	cpu:
    62 		disk:
    62 	  warn_at: 80
    63 		  warn_at: 90
    63 	disk:
    64 		  include: ~
    64 	  warn_at: 90
    65 		  exclude:
    65 	  include: ~
    66 		  - "^/dev(/.+)?$"
    66 	  exclude:
    67 		  - "^/net(/.+)?$"
    67 	  - "^/dev(/.+)?$"
    68 		  - "^/proc$"
    68 	  - "^/net(/.+)?$"
    69 		  - "^/run$"
    69 	  - "^/proc$"
    70 		  - "^/sys/"
    70 	  - "^/run$"
    71 		memory:
    71 	  - "^/sys/"
    72 		  physical_warn_at: ~
    72 	memory:
    73 		  swap_warn_at: 60
    73 	  physical_warn_at: ~
    74 		processes:
    74 	  swap_warn_at: 60
    75 		  check: []
    75 	processes:
    76 
    76 	  check: []
       
    77 ```
    77 
    78 
    78 The `warn_at` keys imply usage capacity as a percentage. ie:  "Warn me
    79 The `warn_at` keys imply usage capacity as a percentage. ie:  "Warn me
    79 when a disk mount point is at 90 percent utilization."
    80 when a disk mount point is at 90 percent utilization."
    80 
    81 
    81 
    82 
   118 #### Memory
   119 #### Memory
   119 
   120 
   120   * **physical_warn_at**: Set the node to a `warning` state when RAM utilization is at or over this percentage.
   121   * **physical_warn_at**: Set the node to a `warning` state when RAM utilization is at or over this percentage.
   121   * **swap_warn_at**: Set the node to a `warning` state when swap utilization is at or over this percentage.
   122   * **swap_warn_at**: Set the node to a `warning` state when swap utilization is at or over this percentage.
   122 
   123 
   123 Warnings are only set for swap my default, since that is usually a
   124 Warnings are only set for swap by default, since that is usually a
   124 better indication of an impending problem.
   125 better indication of an impending problem.
   125 
   126 
   126 
   127 
   127 #### Processes
   128 #### Processes
   128 
   129 
   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