monitor.cfg.in 14.4 KB
Newer Older
1 2 3 4 5 6 7 8
[slap-parameters]
recipe = slapos.cookbook:slapconfiguration
computer = $${slap-connection:computer-id}
partition = $${slap-connection:partition-id}
url = $${slap-connection:server-url}
key = $${slap-connection:key-file}
cert = $${slap-connection:cert-file}

9 10
[monitor-parameters]
json-filename = monitor.json
11
json-path = $${monitor-directory:monitor-result}/$${:json-filename}
12
rss-filename = rssfeed.html
13
rss-path = $${monitor-directory:public-cgi}/$${:rss-filename}
14
executable = $${monitor-directory:bin}/monitor.py
15
port = 9685
16 17 18 19
htaccess-file = $${monitor-directory:etc}/.htaccess-monitor
url = https://[$${slap-parameters:ipv6-random}]:$${:port}
index-filename = index.cgi
index-path = $${monitor-directory:www}/$${:index-filename}
20
db-path = $${monitor-directory:etc}/monitor.db
21
monitor-password-path = $${monitor-directory:etc}/.monitor.shadow
22
log-rss-directory = $${monitor-directory:log-rss-directory}
23

24 25
[monitor-directory]
recipe = slapos.cookbook:mkdirectory
26
# Standard directory needed by monitoring stack
27 28 29
home = $${buildout:directory}
etc = $${:home}/etc
bin = $${:home}/bin
30
srv = $${:home}/srv
31
var = $${:home}/var
32 33 34 35 36 37 38 39 40 41
log = $${:var}/log
run = $${:var}/run
service = $${:etc}/service/
etc-run = $${:etc}/run/
tmp = $${:home}/tmp
promise = $${:etc}/promise

cron-entries = $${:etc}/cron.d
crontabs = $${:etc}/crontabs
cronstamps = $${:etc}/cronstamps
42

43
ca-dir = $${:srv}/ssl
44 45
www = $${:var}/www

46 47 48
cgi-bin = $${:var}/cgi-bin
monitoring-cgi = $${:cgi-bin}/monitoring
knowledge0-cgi = $${:cgi-bin}/zero-knowledge
49
public-cgi = $${:cgi-bin}/monitor-public
50 51 52

monitor-custom-scripts = $${:etc}/monitor
monitor-result = $${:var}/monitor
53

54 55
apachedex-result = $${:srv}/apachedex

56
private-directory = $${:srv}/monitor-private
57
log-rss-directory = $${:srv}/ERRORLogAsRSS
58
mysql-slowquery-report = $${:srv}/mysql-slowquery-report
59

60 61
[public-symlink]
recipe = cns.recipe.symlink
62
symlink = $${monitor-directory:public-cgi} = $${monitor-directory:www}/monitor-public
63 64
autocreate = true

65 66 67
[cron]
recipe = slapos.cookbook:cron
dcrond-binary = ${dcron:location}/sbin/crond
68 69 70
cron-entries = $${monitor-directory:cron-entries}
crontabs = $${monitor-directory:crontabs}
cronstamps = $${monitor-directory:cronstamps}
71
catcher = $${cron-simplelogger:wrapper}
72
binary = $${monitor-directory:service}/crond
73 74 75 76

# Add log to cron
[cron-simplelogger]
recipe = slapos.cookbook:simplelogger
77 78
wrapper = $${monitor-directory:bin}/cron_simplelogger
log = $${monitor-directory:log}/cron.log
79 80 81 82 83

[cron-entry-monitor]
<= cron
recipe = slapos.cookbook:cron.d
name = launch-monitor
84
frequency = */5 * * * *
85
command = $${deploy-monitor-script:rendered} -a
86 87 88 89 90

[cron-entry-rss]
<= cron
recipe = slapos.cookbook:cron.d
name = build-rss
91
frequency = */5 * * * *
92
command = $${make-rss:rendered}
93

94
[setup-static-files]
95 96 97
recipe = plone.recipe.command
command = ln -s ${download-monitor-jquery:destination} $${monitor-directory:www}/static
update-command = $${:command}
98

99
[deploy-index]
100
recipe = slapos.recipe.template:jinja2
101
template = ${index:location}/${index:filename}
102
rendered = $${monitor-parameters:index-path}
103
update-apache-access = ${apache:location}/bin/htpasswd -cb $${monitor-parameters:htaccess-file} admin
104 105
# Force deploy information.html
mode = $${partition-parameters:mode}
106
context =
107
  key cgi_directory monitor-directory:cgi-bin
108
  raw index_template $${deploy-index-template:location}/$${deploy-index-template:filename}
109 110 111
  key monitor_password_path monitor-parameters:monitor-password-path
  key monitor_password_script_path deploy-monitor-password-cgi:rendered
  key apache_update_command :update-apache-access
112
  raw extra_eggs_interpreter ${buildout:directory}/bin/${extra-eggs:interpreter}
113
  raw default_page /static/welcome.html
114
  section rewrite_element monitor-rewrite-rule
115 116 117 118

[deploy-index-template]
recipe = hexagonit.recipe.download
url = ${index-template:location}/$${:filename}
119
destination = $${monitor-directory:www}
120 121 122
filename = ${index-template:filename}
download-only = true
mode = 0644
123 124 125 126

[deploy-status-cgi]
recipe = slapos.recipe.template:jinja2
template = ${status-cgi:location}/${status-cgi:filename}
127
rendered = $${monitor-directory:monitoring-cgi}/$${:filename}
128
filename = status.cgi
129 130 131
mode = 0744
context =
  key json_file monitor-parameters:json-path
132 133 134
  key monitor_bin monitor-parameters:executable
  key pwd monitor-directory:monitoring-cgi
  key this_file :filename
135
  raw python_executable ${buildout:executable}
136

137 138 139 140 141 142 143 144 145 146 147
[deploy-status-history-cgi]
recipe = slapos.recipe.template:jinja2
template = ${status-history-cgi:location}/${status-history-cgi:filename}
rendered = $${monitor-directory:monitoring-cgi}/$${:filename}
filename = status-history.cgi
mode = 0744
context =
  key monitor_db_path monitor-parameters:db-path
  key status_history_length zero-parameters:status-history-length
  raw python_executable ${buildout:executable}

148
[deploy-settings-cgi]
149
recipe = slapos.recipe.template:jinja2
150
template = ${settings-cgi:location}/${settings-cgi:filename}
151
rendered = $${monitor-directory:knowledge0-cgi}/$${:filename}
152
filename = settings.cgi
153 154 155
mode = 0744
context =
  raw config_cfg $${buildout:directory}/knowledge0.cfg
156
  raw timestamp $${buildout:directory}/.timestamp
157
  raw python_executable ${buildout:executable}
158
  key pwd monitor-directory:knowledge0-cgi
159
  key this_file :filename
160

161 162 163 164 165 166 167 168 169 170 171
[deploy-monitor-password-cgi]
recipe = slapos.recipe.template:jinja2
template = ${monitor-password-cgi:location}/${monitor-password-cgi:filename}
rendered = $${monitor-directory:knowledge0-cgi}/$${:filename}
filename = monitor-password.cgi
mode = 0744
context =
  raw python_executable ${buildout:executable}
  key pwd monitor-directory:knowledge0-cgi
  key this_file :filename

172 173 174
[deploy-monitor-script]
recipe = slapos.recipe.template:jinja2
template = ${monitor-bin:location}/${monitor-bin:filename}
175
rendered = $${monitor-parameters:executable}
176 177
mode = 0744
context =
178
  section directory monitor-directory
179
  section monitor_parameter monitor-parameters
180
  key monitoring_file_json monitor-parameters:json-path
181
  raw python_executable ${buildout:executable}
182

183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198
[deploy-logfile-cgi]
recipe = slapos.recipe.template:jinja2
template = ${logfile-cgi:location}/${logfile-cgi:filename}
rendered = $${monitor-directory:monitoring-cgi}/$${:filename}
filename = Files.cgi
script-path= monitoring/Files.cgi
mode = 0744
context =
  key monitor_bin monitor-parameters:executable
  key script_path :script-path
  section base_folder_list log-folder-cgi
  raw python_executable ${buildout:directory}/bin/${extra-eggs:interpreter}

[log-folder-cgi]
log-folder = $${monitor-directory:log}

Tristan Cavelier's avatar
Tristan Cavelier committed
199
[deploy-resource-monitoring-cgi]
200
recipe = slapos.recipe.template:jinja2
Tristan Cavelier's avatar
Tristan Cavelier committed
201
template = ${resources-cgi:location}/${resources-cgi:filename}
202
rendered = $${monitor-directory:monitoring-cgi}/$${:filename}
Tristan Cavelier's avatar
Tristan Cavelier committed
203
filename = resources.cgi
204
mode = $${deploy-settings-cgi:mode}
205 206 207 208
context =
  key monitor_bin monitor-parameters:executable
  raw python_executable ${buildout:directory}/bin/${extra-eggs:interpreter}
  key root_folder buildout:directory
209
  raw config_cfg $${buildout:directory}/$${public:filename}
210

211
[make-rss]
212 213 214
recipe = slapos.recipe.template:jinja2
template = ${make-rss-script:output}
rendered = $${monitor-directory:bin}/make-rss.sh
215
mode = 0744
216 217 218
context =
  section directory monitor-directory
  section monitor_parameters monitor-parameters
219

220 221
[monitor-directory-access]
recipe = plone.recipe.command
222
command = ln -s $${:source} $${monitor-directory:private-directory}
223
source =
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268

# ErrorLog URL As RSS
[error-log-rss-base]
recipe = slapos.recipe.template:jinja2
template = ${errorlog-2rss:location}/${errorlog-2rss:filename}
rendered = $${monitor-directory:bin}/$${:script-name}
mode = 0700
extensions = jinja2.ext.do
base-link = $${monitor-parameters:url}/private/
extra-context =
context = 
  raw python_executable ${buildout:directory}/bin/${extra-eggs:interpreter}
  raw log_tool_folder ${log-tools:location}
  raw db_location $${monitor-directory:etc}/$${:script-name}.db
  key log_as_rss_ouptut monitor-directory:log-rss-directory
  key base_link :base-link
  $${:extra-context}

[log-as-rss-symlink]
< = monitor-directory-access
source = $${monitor-directory:log-rss-directory}

[error-log-rss]
<= error-log-rss-base
script-name = fileLog_AsRSS
# rotate_time: Max time (in hour) before remove an rss entry from database
# item_limit: Max number of rss entries to generate per cycle
extra-context = 
  section log_file_list error-log-list
  raw item_limit 10
  raw hour_interval 1
  raw rotate_time 24
  raw type zope

[error-log-list]
# XXX - error-log-name = FILE_PATH

[cron-entry-logAsRss]
<= cron
recipe = slapos.cookbook:cron.d
name = $${error-log-rss:script-name}
frequency = 30 * * * *
command = $${error-log-rss:rendered}

# Apache Dex
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289
[apachedex-entries-base]
recipe = slapos.recipe.template:jinja2
template = ${run-apachedex:location}/${run-apachedex:filename}
rendered = $${monitor-directory:bin}/$${:script-name}
mode = 0700
extensions = jinja2.ext.do
extra-context =
context = 
  raw python_executable ${buildout:executable}
  raw apachedex_executable ${buildout:directory}/bin/apachedex
  key output_folder monitor-directory:apachedex-result
  $${:extra-context}
  
[apachedex-entries]
<= apachedex-entries-base
script-name = apachedex
extra-context =
  section parameter_dict apachedex-parameters
  key name :script-name
  
[apachedex-parameters]
290
default_parameter = 
291 292 293 294 295 296 297 298 299 300 301 302 303
# XXX - Sample log file with curent date: apache_access.log-%(date)s.gz
# which will be equivalent to apache_access.log-20150112.gz if the date is 2015-01-12
apache-log-list = 
base-list = 
skip-base-list = 
erp5-base-list = 

[cron-entry-apachedex]
<= cron
recipe = slapos.cookbook:cron.d
name = $${apachedex-entries:script-name}
frequency = 0 3 * * *
command = $${apachedex-entries:rendered}
304

305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326
# Generate Mysql slowqueries report with pt-querry-digest
[mysql-slowquery-report]
recipe = slapos.recipe.template:jinja2
template = ${mysql-querydigest:location}/${mysql-querydigest:filename}
rendered = $${cron-mysql-slowquery-report:command}
mode = 0700
extensions = jinja2.ext.do
output-folder = $${monitor-directory:mysql-slowquery-report}
extra-context =
context = 
  raw python_executable ${buildout:executable}
  raw pt_query_executable ${perl:siteprefix}/bin/pt-query-digest
  key output_folder :output-folder
  $${:extra-context}

[cron-mysql-slowquery-report]
<= cron
recipe = slapos.cookbook:cron.d
name = mysql-slowquery-report
frequency = 0 3 * * *
command = $${monitor-directory:bin}/mysql_slowquery_report.py

327 328 329 330 331
[monitor-instance-log-access]
recipe = plone.recipe.command
command = if [ -d $${:source} ]; then ln -s $${:source} $${monitor-directory:private-directory}/instance-logs; fi
update-command = if [ -d $${:source} ]; then ln -s $${:source} $${monitor-directory:private-directory}/instance-logs; fi
source = $${monitor-directory:home}/.slapgrid/log/
332
location = $${:source}
333

334 335
[cadirectory]
recipe = slapos.cookbook:mkdirectory
336 337 338 339 340
requests = $${monitor-directory:ca-dir}/requests/
private = $${monitor-directory:ca-dir}/private/
certs = $${monitor-directory:ca-dir}/certs/
newcerts = $${monitor-directory:ca-dir}/newcerts/
crl = $${monitor-directory:ca-dir}/crl/
341 342 343 344

[certificate-authority]
recipe = slapos.cookbook:certificate_authority
openssl-binary = ${openssl:location}/bin/openssl
345
ca-dir = $${monitor-directory:ca-dir}
346
requests-directory = $${cadirectory:requests}
347
wrapper = $${monitor-directory:service}/certificate_authority
348 349 350 351 352
ca-private = $${cadirectory:private}
ca-certs = $${cadirectory:certs}
ca-newcerts = $${cadirectory:newcerts}
ca-crl = $${cadirectory:crl}

353 354 355 356 357
[ca-httpd]
<= certificate-authority
recipe = slapos.cookbook:certificate_authority.request
key-file = $${cadirectory:certs}/httpd.key
cert-file = $${cadirectory:certs}/httpd.crt
358 359
executable = $${monitor-directory:bin}/cgi-httpd
wrapper = $${monitor-directory:service}/cgi-httpd
360 361 362
# Put domain name
name = example.com

363 364 365
###########
# Deploy a webserver running cgi scripts for monitoring
###########
366
[public]
367
recipe = slapos.cookbook:zero-knowledge.write
368
filename = knowledge0.cfg
369
status-history-length = 5
370
collect-db-path = /srv/slapgrid/var/data-log/collector.db
371 372

[zero-parameters]
373
recipe = slapos.cookbook:zero-knowledge.read
374
filename = $${public:filename}
375

376 377
[monitor-rewrite-rule]

378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398
[partition-parameters]
recipe = slapos.recipe.template:jinja2
template = ${info-template:location}/${info-template:filename}
rendered = $${monitor-directory:monitoring-cgi}/information.html
mode = 0744
instance-id = 
context =
  raw extra_eggs_interpreter ${buildout:directory}/bin/${extra-eggs:interpreter}
  key computer_id slap-connection:computer-id
  key partition_id slap-connection:partition-id
  key home buildout:directory
  key master_url slap-connection:server-url
  key software_url slap-connection:software-release-url
  key ipv4 slap-parameters:ipv4-random
  key ipv6 slap-parameters:ipv6-random
  key slapparameter_dict slap-parameters:configuration
  key instance_reference :instance-id
  section extra_parameters extra-parameters-output

[extra-parameters-output]

399
# XXX could it be something lighter?
400
[monitor-httpd-configuration]
401 402 403
pid-file = $${monitor-directory:run}/cgi-httpd.pid
cgid-pid-file = $${monitor-directory:run}/cgi-httpd-cgid.pid
error-log = $${monitor-directory:log}/cgi-httpd-error-log
404 405 406 407
listening-ip = $${slap-parameters:ipv6-random}
certificate = $${ca-httpd:cert-file}
key = $${ca-httpd:key-file}

408
[httpd-environment]
409
PYTHONPATH = ${log-tools:location}:${collect-tools:location}
410

411 412 413 414 415 416 417 418 419
[monitor-httpd-configuration-file]
recipe = slapos.recipe.template:jinja2
template = ${monitor-httpd-template:destination}/${monitor-httpd-template:filename}
rendered = $${monitor-directory:etc}/cgi-httpd.conf
mode = 0744
context =
  section directory monitor-directory
  section monitor_parameters monitor-parameters
  section httpd_configuration monitor-httpd-configuration
420
  section monitor_rewrite_rule monitor-rewrite-rule
421
  section environment_dict httpd-environment
422 423 424 425

[cgi-httpd-wrapper]
recipe = slapos.cookbook:wrapper
apache-executable = ${apache:location}/bin/httpd
426
command-line = $${:apache-executable} -f $${monitor-httpd-configuration-file:rendered} -DFOREGROUND
427
wrapper-path = $${ca-httpd:executable}
428

429
[cgi-httpd-graceful-wrapper]
430 431 432 433 434 435 436 437
recipe = slapos.recipe.template:jinja2
template = ${template-wrapper:output}
rendered = $${monitor-directory:etc-run}/cgi-httpd-graceful
mode = 0700
context =
    key content :command
command = kill -USR1 $(cat $${monitor-httpd-configuration:pid-file})

438

439 440
[monitor-promise]
recipe = slapos.cookbook:check_url_available
441 442
path = $${monitor-directory:promise}/monitor
url = $${monitor-parameters:url}/$${monitor-parameters:index-filename}
443 444 445 446
check-secure = 1
dash_path = ${dash:location}/bin/dash
curl_path = ${curl:location}/bin/curl

447
[publish-connection-informations]
448
recipe = slapos.cookbook:publish
449
monitor_url = $${monitor-parameters:url}