Commit 06e7e151 authored by Tristan Cavelier's avatar Tristan Cavelier

monitor: README & notes +1

parent 0b00addf
This diff is collapsed.
Monitor Monitor
======= =======
Activate monitoring This stack has for purpose to know if all promises went/are ok.
-------------------
Create a new buildout: It provides a web interface, to see which promises failed. It also provide a rss
feed to easily know the actual state of your instance, and to know when it
started to went bad.
[buildout] Index:
extends =
monitor_url
my_software_url
- Activate monitoring for you software
- Add a monitor promise
- Information about URL access
- Monitor promise configuration example
- Promise requirements
- monitor.haljson example
- monitor.conf example
KVM Log access + parsing
------------------------
Open HTTP GET on static files, open HTTP POST on cgi, make cron to run bin/monitor.py Activate monitoring for your software
-------------------------------------
GET <root_monitor>/ // classical monitoring interface
GET <root_monitor>/monitor.haljson // monitor conf
GET <root_monitor>/public/<service>.status.json // service status json
KVM Example You just have to extend the monitor stack from your software.cfg.
GET <kvm_monitor>/monitor.haljson You can also create a new buildout which extends your software, and the
GET <kvm_monitor>/public/kvm-log-parser.status.json monitoring stack:
GET <kvm_monitor>/public/kvm-log-parser/index.html
POST <kvm_monitor>/cgi-bin/monitor-run-promise.cgi?service=kvm-log-parse // rerun the promise
Tree for monitor runtime [buildout]
extends =
monitor_url
my_software_url
etc/monitor.conf // generated by slapos In your instance.cfg, your publish section should be named `[publish]` in order
etc/cron.d/monitor // generated by slapos to extends the one of the monitoring stack.
bin/monitor.py // generated by slapos // import var/monitor/run/X.py as plop; plop.run(**conf [parameter] section)
srv/monitor/index.html // generated by slapos
srv/monitor/monitor.css // static
srv/monitor/monitor.js // static
srv/monitor/monitor.haljson // generated by monitor.py
srv/monitor/public/.... // generated by monitor.py
srv/monitor/private/.... // generated by monitor.py
KVM Example Then, in the same file you can configure the monitor by adding this section:
etc/monitor-promise/kvm-log-parse.cfg // generated by slapos (kvm-log-parser-promise) [monitor-instance-parameter]
etc/monitor-promise/kvm-log-parse // generated by slapos (kvm-log-parser-promise) monitor-httpd-ipv6 = ...
var/kvm-log-parser-promise/interface/index.html // generated by slapos (kvm-log-parser-promise) monitor-httpd-port = ...
var/log/kvm.log // generated by kvm monitor-title = ...
var/log/kvm-log-parse-last-report.csv // generated by kvm-log-parse
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 -> 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 Add a monitor promise
--------------------- ---------------------
For instance, we want to create a promise for kvm log parsing. Add these sections somewhere: For instance, we want to create a promise for KVM log parsing. Add these
sections in its instance.cfg:
[directory] [directory]
monitor-promise = ${:etc}/monitor-promise monitor-promise = ${:etc}/monitor-promise
...@@ -90,7 +80,7 @@ We can optionaly add promise title: ...@@ -90,7 +80,7 @@ We can optionaly add promise title:
[kvm-log-parser-promise-parameter] [kvm-log-parser-promise-parameter]
frequency = */5 * * * * frequency = */5 * * * *
Optionaly, we also want an custom interface: Optionaly, we also want a custom interface:
[directory] [directory]
kvm-log-parser-promise-interface-dir = ....../interface kvm-log-parser-promise-interface-dir = ....../interface
...@@ -113,28 +103,81 @@ service.cfg: ...@@ -113,28 +103,81 @@ service.cfg:
{% endfor -%} {% endfor -%}
Service config example etc/monitor.conf.d/kvm-log-parse.conf Information about URL access
------------------------------------------------------------ ----------------------------
Open HTTP GET on static files, open HTTP POST on cgi
GET <root_monitor>/ // classical monitoring interface
GET <root_monitor>/monitor.haljson // monitor conf
GET <root_monitor>/public/<service>.status.json // service status json
Example for KVM log parsing promise
GET <kvm_monitor>/monitor.haljson
GET <kvm_monitor>/public/kvm-log-parser.status.json
GET <kvm_monitor>/public/kvm-log-parser/index.html
POST <kvm_monitor>/cgi-bin/monitor-run-promise.cgi?service=kvm-log-parse // rerun the promise
Information about internal file tree
------------------------------------
Tree for monitor runtime:
etc/monitor.conf // generated by slapos
etc/cron.d/monitor // generated by slapos
bin/monitor.py // generated by slapos
srv/monitor/web/index.html // static
srv/monitor/web/monitor.css // static
srv/monitor/web/monitor.js // static
srv/monitor/web/monitor.haljson // generated by monitor.py
srv/monitor/public/.... // generated by monitor.py
srv/monitor/private/.... // generated by monitor.py
Example for KVM log parsing promise
etc/monitor-promise/kvm-log-parse.cfg // generated by slapos (kvm-log-parser-promise)
etc/monitor-promise/kvm-log-parse // generated by slapos (kvm-log-parser-promise)
var/kvm-log-parser-promise/interface/index.html // generated by slapos (kvm-log-parser-promise)
var/log/kvm.log // generated by kvm
var/log/kvm-log-parse-last-report.csv // generated by kvm-log-parse
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 -> var/log/kvm.log // 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
srv/monitor/private/kvm-log-parse/interface -> var/kvm-log-parser-promise/interface // generated by monitor.py
Monitor promise config example
------------------------------
Example for KVM log parsing promise
# etc/monitor-promise/kvm-log-parse.cfg
[service] [service]
title = Kvm log parse title = Kvm log parse
frequency = <Cron Syntax> frequency = <Cron Syntax>
public-path-list = $instance/var/log/kvm.log # automatically symlink to srv/monitor/public/$service/ public-path-list = $instance/var/log/kvm.log # automatically symlink to srv/monitor/public/$service/
private-path-list = $instance/var/log/kvm.log # automatically symlink to srv/monitor/private/$service/ private-path-list = $instance/var/log # automatically symlink to srv/monitor/private/$service/
On cron, the command will be something like:
on cron, the command will be `${service:frequency} ${monitor:promise-executor-path} '${monitor:service-pid-folder}/${service:name}.pid' '${service:status-path}' '${promise_path}' ` ${service:frequency} ${monitor:promise-executor-path} '${monitor:service-pid-folder}/${service:name}.pid' '${service:status-path}' '${promise_path}'
TODO cron accepts 999 characters maximum for a command, so we should reduce the size of the cron command and "monitor:promise-executor-path" is a script that would run a promise if not
already on going (see `run-promise.py`).
and "monitor:promise-executor-path" is a script that would run a promise if not already on going (see `run-promise.py`) TODO cron accepts 999 characters maximum for a command, so we should reduce the
size of the cron command
TODO put `run-promise.py` in the software TODO put `run-promise.py` in the software
Promise or script requirements Promise requirements
------------------------------ --------------------
A promise should check something (like web cache, not too much slow queries, ...) A promise should check something (like web page is well cached, there's not too
much slow queries, ...):
- MUST output the status.json in stdout - MUST output the status.json in stdout
- SHOULD output on stdout - SHOULD output on stdout
...@@ -142,8 +185,8 @@ A promise should check something (like web cache, not too much slow queries, ... ...@@ -142,8 +185,8 @@ A promise should check something (like web cache, not too much slow queries, ...
- the status.json MUST contain "message" (string) which explains why the status is OK or bad - the status.json MUST contain "message" (string) which explains why the status is OK or bad
srv/monitor/public/monitor.haljson for kvm instance (example) monitor.haljson example
------------------------------------------------------------- -----------------------
{ {
"_links": { "_links": {
...@@ -176,8 +219,8 @@ srv/monitor/public/monitor.haljson for kvm instance (example) ...@@ -176,8 +219,8 @@ srv/monitor/public/monitor.haljson for kvm instance (example)
} }
etc/monitor.conf example monitor.conf example
------------------------ --------------------
[monitor] [monitor]
title = KVM Monitoring interface title = KVM Monitoring interface
......
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