Commit 317189b4 authored by Tristan Cavelier's avatar Tristan Cavelier

monitor: note +1

parent 6309ed47
...@@ -8,48 +8,109 @@ Create a new buildout: ...@@ -8,48 +8,109 @@ Create a new buildout:
[buildout] [buildout]
extends = extends =
my_software_url
monitor_url monitor_url
my_software_url
KVM Log access + parsing KVM Log access + parsing
------------------------ ------------------------
Open HTTP GET on static files, open HTTP POST on cgi, make cron to run bin/monitor.py Open HTTP GET on static files, open HTTP POST on cgi, make cron to run bin/monitor.py
Tree (`<url>/` = `/srv/monitor/public/`) GET <root_monitor>/ // classical monitoring interface
GET <root_monitor>/monitor.haljson // monitor conf
GET <root_monitor>/ // classical monitoring interface GET <root_monitor>/public/<service>.status.json // service status json
GET <root_monitor>/monitor.haljson // monitor conf
GET <root_monitor>/<service>/status.json // service status json
KVM Example KVM Example
GET <kvm_monitor>/monitor.haljson GET <kvm_monitor>/monitor.haljson
GET <kvm_monitor>/kvm-log-parser/status.json GET <kvm_monitor>/public/kvm-log-parser.status.json
GET <kvm_monitor>/kvm-log-parser/index.html GET <kvm_monitor>/public/kvm-log-parser/index.html
POST <kvm_monitor>/cgi-bin/kvm-log-parse.cgi // post handler POST <kvm_monitor>/cgi-bin/monitor-run-promise.cgi?service=kvm-log-parse // rerun the promise
Tree for monitor runtime Tree for monitor runtime
etc/monitor.conf // generated by slapos etc/monitor.conf // generated by slapos
etc/cron.d/monitor // generated by slapos etc/cron.d/monitor // generated by slapos
bin/monitor.py // generated by slapos // import var/monitor/run/X.py as plop; plop.run(**conf [parameter] section) bin/monitor.py // generated by slapos // import var/monitor/run/X.py as plop; plop.run(**conf [parameter] section)
srv/monitor/public/index.html // generated by slapos srv/monitor/index.html // generated by slapos
srv/monitor/public/monitor.css // static srv/monitor/monitor.css // static
srv/monitor/public/monitor.js // static srv/monitor/monitor.js // static
srv/monitor/public/monitor.haljson // generated by monitor.py srv/monitor/monitor.haljson // generated by monitor.py
srv/monitor/public/*.log|*.json|*.csv // generator by monitor.py srv/monitor/public/.... // generated by monitor.py
srv/monitor/private/-^ srv/monitor/private/.... // generated by monitor.py
KVM Example KVM Example
etc/monitor.conf.d/kvm-log-parse.conf // generated by slapos etc/monitor-promise/kvm-log-parse.cfg // generated by slapos (kvm-log-parser-promise)
var/monitor/run/kvm-log-parse.py // generated by slapos (a promise that should stdout a status.json) etc/monitor-promise/kvm-log-parse // generated by slapos (kvm-log-parser-promise)
srv/monitor/cgi-bin/kvm-log-parse.cgi // generated by slapos (only way to handle post request kvm-log-parse ui) var/kvm-log-parser-promise/interface/index.html // generated by slapos (kvm-log-parser-promise)
srv/monitor/public/kvm-log-parse/index.html // static (renderjs component) var/log/kvm.log // generated by kvm
srv/monitor/public/kvm-log-parse/status.json // generated by kvm-log-parse.py var/log/kvm-log-parse-last-report.csv // generated by kvm-log-parse
srv/monitor/public/kvm-log-parse/kvm.log -> var/log/kvm.log // generated by monitor.py srv/monitor/public/kvm-log-parse.status.json // generated by kvm-log-parse (indirectly by the monitor promise executor)
srv/monitor/public/kvm-log-parse/kvm-log-parse-result.csv // genareted by kvm-log-parse.py srv/monitor/public/kvm-log-parse/kvm.log -> var/log/kvm.log // generated by monitor.py
srv/monitor/public/kvm-log-parse/interface -> var/kvm-log-parser-promise/interface // generated by monitor.py
srv/monitor/public/kvm-log-parse/kvm-log-parse-last-report.csv -> var/log/kvm-log-parse-last-report.csv // genareted by monitor.py
Add a monitor promise
---------------------
For instance, we want to create a promise for kvm log parsing. Add these sections somewhere:
[directory]
monitor-promise = ${:etc}/monitor-promise
[kvm-log-parser-promise]
recipe = ....
filename = kvm-log-parser
rendered = ${directory:monitor-promise}/${:filename}
mode = 0755
[buildout]
parts += kvm-log-parser-promise
We can optionaly add promise title:
[kvm-log-parser-promise-parameter]
# fill with -> see "Service config example" below
title = Kvm log parse
[kvm-log-parser-promise-cfg]
recipe = slapos.recipe.template:jinja2
rendered = ${directory:monitor-promise}/${kvm-log-parser-promise:filename}.cfg
template = service.cfg
context = section parameter_dict kvm-log-parser-promise-parameter
[buildout]
parts += kvm-log-parser-promise-cfg
... and optionaly a specific frequency:
[kvm-log-parser-promise-parameter]
frequency = */5 * * * *
Optionaly, we also want an custom interface:
[directory]
kvm-log-parser-promise-interface-dir = ....../interface
[kvm-log-parser-promise-parameter]
private-path-list += ${directory:kvm-log-parser-promise-interface-dir}
[kvm-log-parser-promise-interface]
recipe = ....
rendered = ${directory:kvm-log-parser-interface-dir}/index.html
[buildout]
parts += kvm-log-parser-promise-interface
service.cfg:
[service]
{% for key, value in parameter_dict.items() -%}
{{ key }} = {{ dumps(value) }}
{% endfor -%}
Service config example etc/monitor.conf.d/kvm-log-parse.conf Service config example etc/monitor.conf.d/kvm-log-parse.conf
...@@ -57,14 +118,9 @@ Service config example etc/monitor.conf.d/kvm-log-parse.conf ...@@ -57,14 +118,9 @@ Service config example etc/monitor.conf.d/kvm-log-parse.conf
[service] [service]
title = Kvm log parse title = Kvm log parse
name = kvm-log-parse
frequency = <Cron Syntax> frequency = <Cron Syntax>
promise-path = $instance/var/monitor/run/kvm-log-parse.py public-path-list = $instance/var/log/kvm.log # automatically symlink to srv/monitor/public/$service/
interface-path = $instance/srv/monitor/public/kvm-log-parse/index.html private-path-list = $instance/var/log/kvm.log # automatically symlink to srv/monitor/private/$service/
public-path-list = $instance/var/log/kvm.log # automatically symlink to srv/monitor/public/$service/file/
private-path-list = $instance/var/log/kvm.log # automatically symlink to srv/monitor/private/$service/file/
the cgi path should be hardcoded to `${monitor:cgi-path}/${:name}.cgi so $instance/srv/monitor/cgi-bin/kvm-log-parse`, this should be the only way to handle post requests
on cron, the command will be `${service:frequency} ${monitor:promise-executor-path} '${monitor:service-pid-folder}/${service:name}.pid' '${service:status-path}' '${promise_path}' ` on cron, the command will be `${service:frequency} ${monitor:promise-executor-path} '${monitor:service-pid-folder}/${service:name}.pid' '${service:status-path}' '${promise_path}' `
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment