Commit be34e4c6 authored by Cédric Le Ninivin's avatar Cédric Le Ninivin

monitor: add possibility to refresh status

parent c48cd7a6
...@@ -120,6 +120,9 @@ filename = status.cgi ...@@ -120,6 +120,9 @@ filename = status.cgi
mode = 0744 mode = 0744
context = context =
key json_file monitor-parameters:json-path key json_file monitor-parameters:json-path
key monitor_bin monitor-parameters:executable
key pwd monitor-directory:monitoring-cgi
key this_file :filename
raw python_executable ${buildout:executable} raw python_executable ${buildout:executable}
[deploy-settings-cgi] [deploy-settings-cgi]
......
#!{{ python_executable }} #!{{ python_executable }}
import cgi
import cgitb import cgitb
import json import json
import subprocess
def refresh():
command = ["{{ monitor_bin }}", "-a"]
subprocess.call(command)
cgitb.enable(display=0, logdir="/tmp/cgi.log") cgitb.enable(display=0, logdir="/tmp/cgi.log")
form = cgi.FieldStorage()
if "refresh" in form:
refresh()
json_file = "{{ json_file }}" json_file = "{{ json_file }}"
result = json.load(open(json_file)) result = json.load(open(json_file))
...@@ -13,8 +22,12 @@ print "<link rel=\"stylesheet\" href=\"pure-min.css\">" ...@@ -13,8 +22,12 @@ print "<link rel=\"stylesheet\" href=\"pure-min.css\">"
print "<link rel=\"stylesheet\" href=\"/style.css\">" print "<link rel=\"stylesheet\" href=\"/style.css\">"
print "</head><body>" print "</head><body>"
print "<h1>Monitoring :</h1>" print "<h1>Monitoring :</h1>"
print "<form action=\"/index.cgi\" method=\"post\" class=\"pure-form-aligned\">"
print "<input type=\"hidden\" name=\"posting-script\" value=\"{{ pwd }}/{{ this_file }}\">"
print "<p><em>Last time of monitoring process : %s</em></p>" % (result['datetime']) print "<p><em>Last time of monitoring process : %s</em></p>" % (result['datetime'])
del result['datetime'] del result['datetime']
print "<div class=\"pure-controls\"><button type=\"submit\" class=\"pure-button \
pure-button-primary\" name=\"refresh\" value=\"refresh\">Refresh</button></div></form>"
print "<br/>" print "<br/>"
print "<h2>These scripts and promises have failed :</h2>" print "<h2>These scripts and promises have failed :</h2>"
......
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