Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Yusei Tahara
slapos
Commits
0233105b
Commit
0233105b
authored
Dec 24, 2013
by
Nicolas Wavrant
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stack-monitor: added cgi interface for control
parent
950a004a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
83 additions
and
9 deletions
+83
-9
stack/monitor/buildout.cfg
stack/monitor/buildout.cfg
+10
-2
stack/monitor/control.cgi.in
stack/monitor/control.cgi.in
+53
-0
stack/monitor/make-rss.sh.in
stack/monitor/make-rss.sh.in
+1
-1
stack/monitor/monitor.cfg.in
stack/monitor/monitor.cfg.in
+18
-5
stack/monitor/monitor.cgi.in
stack/monitor/monitor.cgi.in
+1
-1
No files found.
stack/monitor/buildout.cfg
View file @
0233105b
...
...
@@ -53,12 +53,20 @@ download-only = true
filename = monitor.py.in
mode = 0644
[
cgi-bin
]
[
monitor-cgi
]
recipe = hexagonit.recipe.download
url = ${:_profile_base_location_}/${:filename}
download-only = true
#md5sum =
filename = index.cgi
filename = monitor.cgi.in
mode = 0644
[control-cgi]
recipe = hexagonit.recipe.download
url = ${:_profile_base_location_}/${:filename}
download-only = true
#md5sum =
filename = control.cgi.in
mode = 0644
[rss-bin]
...
...
stack/monitor/control.cgi.in
0 → 100644
View file @
0233105b
#!{{ python_executable }}
import cgi
import cgitb
import ConfigParser
cgitb.enable(display=0, logdir="/tmp/cgi.log")
# Headers
print "Content-Type: text/html"
print
# Body content
form = cgi.FieldStorage()
if "password" not in form:
print """
<html>
<body>
<h1>
This is the monitoring interface
</h1>
<p>
Please enter the monitor_password in the next field to access the data
</p>
<form
action=
"/{{ this_filename }}"
method=
"post"
>
Password :
<input
type=
"password"
name=
"password"
>
<input
type=
"submit"
value=
"Access"
>
</form></body></html>
"""
elif form['password'].value != '{{ password }}':
print "
<html><body><h1>
Error
</h1><p>
Wrong password
</p></body></html>
"
else:
parser = ConfigParser.ConfigParser()
parser.read("{{ config_cfg }}")
if len(form) > 1:
for name in form:
if name != 'password':
parser.set('public', name, form[name].value)
with open("{{ config_cfg }}", 'w') as file:
parser.write(file)
print "
<html><body>
"
print "
<h1>
Values to be defined by the user
</h1>
"
print "
<form
action=
\"/control.cgi\"
method=
\"post\"
>
"
print "
<input
type=
\"hidden\"
name=
\"password\"
value=
\"{{
password
}}\"
>
"
for option in parser.options("public"):
print "%s :
<input
type=
\"text\"
name=
\"%s\"
\
value=
\"%s\"
><br>
"% (option, option, parser.get('public', option))
print "
<input
type=
\"submit\"
value=
\"Save\"
></form>
"
print "
<h1>
Other values:
</h1>
"
for section in parser.sections():
if section != 'public':
for option in parser.options(section):
print "
<b>
%s
</b>
: value=\"%s\"
<br>
" % (option,
parser.get(section, option))
print "
</body></html>
"
\ No newline at end of file
stack/monitor/make-rss.sh.in
View file @
0233105b
...
...
@@ -6,4 +6,4 @@ PYTHON=${buildout:directory}/bin/${extra-eggs:interpreter}
STATUS2RSS=${rss-bin:location}/${rss-bin:filename}
NAME=`basename $STATUS`
cat $STATUS/* | $PYTHON $STATUS2RSS "Monitoring RSS feed" "https://[$${slap-parameters:ipv6-random}]:$${cgi-httpd-configuration-file:listening-port}/$${deploy-cgi-script:filename}" > $RSS_FILE
\ No newline at end of file
cat $STATUS/* | $PYTHON $STATUS2RSS "Monitoring RSS feed" "https://[$${slap-parameters:ipv6-random}]:$${cgi-httpd-configuration-file:listening-port}/$${deploy-monitor-cgi:filename}" > $RSS_FILE
\ No newline at end of file
stack/monitor/monitor.cfg.in
View file @
0233105b
...
...
@@ -7,7 +7,7 @@ key = $${slap-connection:key-file}
cert = $${slap-connection:cert-file}
[monitor-parameters]
monitor-dir = $${directory:
monitor-result}
monitor-dir = $${directory:
var}/monitor
result-dir = $${:monitor-dir}/bool
json-filename = monitor.json
json-path = $${:monitor-dir}/$${:json-filename}
...
...
@@ -27,7 +27,7 @@ crontabs = $${:etc}/crontabs
cronstamps = $${:etc}/cronstamps
log = $${:var}/log
monitor = $${:etc}/monitor
monitor-result = $${
:var}/monitor
monitor-result = $${
monitor-parameters:monitor-dir}
monitor-result-bool = $${monitor-parameters:result-dir}
promise = $${:etc}/promise
run = $${:var}/run
...
...
@@ -64,16 +64,29 @@ name = build-rss
frequency = * * * * *
command = $${make-rss:output}
[deploy-
cgi-script
]
[deploy-
monitor-cgi
]
recipe = slapos.recipe.template:jinja2
template = ${
cgi-bin:location}/${cgi-bin
:filename}
template = ${
monitor-cgi:location}/${monitor-cgi
:filename}
rendered = $${directory:www}/$${:filename}
filename =
index
.cgi
filename =
monitor
.cgi
mode = 0744
context =
key json_file monitor-parameters:json-path
key password cgi-password:passwd
raw python_executable ${buildout:executable}
key this_filename :filename
[deploy-control-cgi]
recipe = slapos.recipe.template:jinja2
template = ${control-cgi:location}/${control-cgi:filename}
rendered = $${directory:www}/$${:filename}
filename = control.cgi
mode = 0744
context =
raw config_cfg $${buildout:directory}/knowledge0.cfg
key password cgi-password:passwd
raw python_executable ${buildout:executable}
key this_filename :filename
[deploy-monitor-script]
recipe = slapos.recipe.template:jinja2
...
...
stack/monitor/
index.cgi
→
stack/monitor/
monitor.cgi.in
View file @
0233105b
...
...
@@ -21,7 +21,7 @@ if "password" not in form:
<body>
<h1>
This is the monitoring interface
</h1>
<p>
Please enter the monitor_password in the next field to access the data
</p>
<form
action=
"/
index.cgi
"
method=
"post"
>
<form
action=
"/
{{ this_filename }}
"
method=
"post"
>
Password :
<input
type=
"password"
name=
"password"
>
<input
type=
"submit"
value=
"Access"
>
</form></body></html>
"""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment