Commit 9fca331c authored by Tristan Cavelier's avatar Tristan Cavelier

monitor: handle promises by monitor

parent cc32ff06
......@@ -56,7 +56,7 @@ md5sum = 2db5c08c7e8658981b4b1e3f27fd5967
[monitor-bin]
<= monitor-download-base
filename = monitor.py.in
md5sum = 1a376c4063121db33ffab25b4cd99c76
md5sum = 331e8579c390aba5c5f4a4e7820b4c03
[monitor-web-index-html]
<= monitor-download-base
......@@ -71,7 +71,7 @@ md5sum = a18ab932e5e2e656995f47c7d4a7853a
[monitor-web-monitor-js]
<= monitor-download-base
filename = monitor.js.in
md5sum = 89ca4da3a1895014a052f114605ed527
md5sum = 8bc4b8368a752f90da2571866768e81f
[monitor-web-monitor-logout-cgi]
<= monitor-download-base
......@@ -89,7 +89,7 @@ recipe = slapos.recipe.template:jinja2
filename = template-monitor.cfg
template = ${:_profile_base_location_}/instance-monitor.cfg.jinja2.in
rendered = ${buildout:directory}/template-monitor.cfg
md5sum = 80527d09711810f74cfc2a8c2c9be880
md5sum = 1c731d879992c218bc6823e88c33f3b3
context =
key apache_location apache:location
key gzip_location gzip:location
......
......@@ -219,6 +219,7 @@ context =
key public_folder monitor-directory:public
key configuration_location monitor-conf:rendered
key promise_runner_path monitor-run-promise:rendered
key promise_folder directory:promises
[monitor-run-promise]
recipe = slapos.recipe.template:jinja2
......
......@@ -98,7 +98,7 @@
var interface_url = softGetProperty(service_dict, ["_links", "interface", "href"]),
status_url = softGetProperty(service_dict, ["_links", "status", "href"]),
href_html_part = (interface_url ? " href=\"" + escapeHtml(interface_url) + "\"" : ""),
title_html_part = (service_dict.title ? escapeHtml(service_dict.title) : "Untitled"),
title_html_part = (service_dict.title ? escapeHtml(service_dict.title) : (service_dict.id ||"Untitled")),
row = htmlToElementList("<table><tbody><tr><td><a" + href_html_part + ">" + title_html_part + "</a></td><td>Loading status...</td><td><a" + href_html_part + "><div style=\"height: 10mm; width: 10mm; background-color: gray;\"></div></a></td></tr></tbody></table>");
table.appendChild(row[2]);
if (!status_url) {
......@@ -109,9 +109,7 @@
if (status_dict.description) {
row[2].title = status_dict.description;
}
if (status_dict.message) {
row[5].textContent = status_dict.message;
}
row[5].textContent = status_dict.message || "";
row[8].style.backgroundColor = status_dict.status === "OK" ? "green" : "red";
}).catch(function (reason) {
row[5].textContent = (reason && (reason.name + ": " + reason.message));
......
......@@ -2,6 +2,7 @@
configuration_location = "{{ configuration_location }}"
promise_runner_path = "{{ promise_runner_path }}"
public_folder = "{{ public_folder }}"
promise_folder = "{{ promise_folder }}"
import sys
import os
......@@ -21,8 +22,16 @@ def main():
for filename in os.listdir(configuration_folder_location)
if os.path.isfile(os.path.join(configuration_folder_location, filename))
]
# search for promises in ...? or let promises be on some service conf files?
# XXX see old monitor.py.in
# search for promises in promise folder and convert into configuration
for filename in os.listdir(promise_folder):
path = os.path.join(promise_folder, filename)
if os.path.isfile(path):
c = ConfigParser.ConfigParser()
c.add_section("service")
c.set("service", "name", filename)
c.set("service", "frequency", "* * * * *") # every minutes
c.set("service", "promise-path", os.path.join(path))
service_config_list.append(c)
# generate monitor.json
monitor_dict = {}
tmp = softConfigGet(config, "monitor", "title")
......
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