Commit 7f658df1 authored by Tristan Cavelier's avatar Tristan Cavelier Committed by Alain Takoudjou

monitor: monitor.py.in naming conventions

parent 829b4a61
...@@ -8,7 +8,7 @@ parts = ...@@ -8,7 +8,7 @@ parts =
deploy-settings-cgi deploy-settings-cgi
deploy-status-cgi deploy-status-cgi
deploy-status-history-cgi deploy-status-history-cgi
deploy-ressource-monitoring-cgi deploy-resource-monitoring-cgi
setup-static-files setup-static-files
certificate-authority certificate-authority
zero-parameters zero-parameters
......
...@@ -100,12 +100,12 @@ md5sum = d2b85ac31cbbf49c78dc51e90ddf305f ...@@ -100,12 +100,12 @@ md5sum = d2b85ac31cbbf49c78dc51e90ddf305f
filename = logfile.cgi.in filename = logfile.cgi.in
mode = 0644 mode = 0644
[ressources-cgi] [resource-consumption-cgi]
recipe = hexagonit.recipe.download recipe = hexagonit.recipe.download
url = ${:_profile_base_location_}/webfile-directory/${:filename} url = ${:_profile_base_location_}/webfile-directory/${:filename}
download-only = true download-only = true
md5sum = 6aed44f5048b58cc01408caf265a3c4d md5sum = 61069d8cfd7e7204106c147edc61ebbe
filename = ressources.cgi.in filename = resource-consumption.cgi.in
mode = 0644 mode = 0644
[status-cgi] [status-cgi]
......
...@@ -184,8 +184,8 @@ context = ...@@ -184,8 +184,8 @@ context =
recipe = slapos.recipe.template:jinja2 recipe = slapos.recipe.template:jinja2
template = ${logfile-cgi:location}/${logfile-cgi:filename} template = ${logfile-cgi:location}/${logfile-cgi:filename}
rendered = $${monitor-directory:monitoring-cgi}/$${:filename} rendered = $${monitor-directory:monitoring-cgi}/$${:filename}
filename = Files.cgi filename = logfile-tool.cgi
script-path= monitoring/Files.cgi script-path= monitoring/logfile-tool.cgi
mode = 0744 mode = 0744
context = context =
key monitor_bin monitor-parameters:executable key monitor_bin monitor-parameters:executable
...@@ -196,11 +196,11 @@ context = ...@@ -196,11 +196,11 @@ context =
[log-folder-cgi] [log-folder-cgi]
log-folder = $${monitor-directory:log} log-folder = $${monitor-directory:log}
[deploy-ressource-monitoring-cgi] [deploy-resource-consumption-monitoring-cgi]
recipe = slapos.recipe.template:jinja2 recipe = slapos.recipe.template:jinja2
template = ${ressources-cgi:location}/${ressources-cgi:filename} template = ${resource-consumption-cgi:location}/${resource-consumption-cgi:filename}
rendered = $${monitor-directory:monitoring-cgi}/$${:filename} rendered = $${monitor-directory:monitoring-cgi}/$${:filename}
filename = ressources.cgi filename = resource-consumption.cgi
mode = $${deploy-settings-cgi:mode} mode = $${deploy-settings-cgi:mode}
context = context =
key monitor_bin monitor-parameters:executable key monitor_bin monitor-parameters:executable
......
...@@ -129,12 +129,12 @@ def runScripts(directory): ...@@ -129,12 +129,12 @@ def runScripts(directory):
return result return result
def writeFiles(monitors): def writeFile(monitor_dict):
timestamp = int(time.time()) timestamp = int(time.time())
db = sqlite3.connect(db_path) db = sqlite3.connect(db_path)
init_db(db) init_db(db)
status = SUCCESS status = SUCCESS
for key, value in monitors.iteritems(): for key, value in monitor_dict.iteritems():
if value: if value:
element_status = status = FAILURE element_status = status = FAILURE
else: else:
...@@ -143,12 +143,12 @@ def writeFiles(monitors): ...@@ -143,12 +143,12 @@ def writeFiles(monitors):
db.execute("insert into status(timestamp, status) values (?, ?)", (timestamp, status)) db.execute("insert into status(timestamp, status) values (?, ?)", (timestamp, status))
db.commit() db.commit()
db.close() db.close()
monitors['datetime'] = time.ctime(timestamp) monitor_dict['datetime'] = time.ctime(timestamp)
json.dump(monitors, open(monitoring_file_json, "w+")) json.dump(monitor_dict, open(monitoring_file_json, "w+"))
def main(): def main():
parser = OptionParser(option_list=option_list) parser = OptionParser(option_list=option_list)
monitors = {} monitor_dict = {}
(options, args) = parser.parse_args() (options, args) = parser.parse_args()
if not (options.monitor or options.promise if not (options.monitor or options.promise
...@@ -156,16 +156,16 @@ def main(): ...@@ -156,16 +156,16 @@ def main():
exit("Please provide at list one arg in : -a, -m, -p, -s") exit("Please provide at list one arg in : -a, -m, -p, -s")
if options.monitor or options.all: if options.monitor or options.all:
monitors.update(runScripts(monitor_dir)) monitor_dict.update(runScripts(monitor_dir))
if options.promise or options.all: if options.promise or options.all:
monitors.update(runScripts(promise_dir)) monitor_dict.update(runScripts(promise_dir))
if options.service or options.all: if options.service or options.all:
monitors.update(runServices(pid_dir)) monitor_dict.update(runServices(pid_dir))
if options.only_stdout: if options.only_stdout:
print json.dumps(monitors) print json.dumps(monitor_dict)
else: else:
writeFiles(monitors) writeFile(monitor_dict)
if __name__ == "__main__": if __name__ == "__main__":
......
...@@ -92,7 +92,7 @@ $(document).ready(function () { ...@@ -92,7 +92,7 @@ $(document).ready(function () {
function refresh() { function refresh() {
if (send) { return} if (send) { return}
var dataPost = {'posting-script': "monitoring/ressources.cgi", var dataPost = {'posting-script': "monitoring/resource-consumption.cgi",
action: "refresh"}; action: "refresh"};
send = true; send = true;
$("#msg").fadeIn(); $("#msg").fadeIn();
...@@ -163,7 +163,7 @@ $(document).ready(function () { ...@@ -163,7 +163,7 @@ $(document).ready(function () {
}); });
</script> </script>
</head><body> </head><body>
<h1>Computer partition ressources monitoring</h1> <h1>Computer partition resources monitoring</h1>
<div style="width:850px; padding: 10px 0;"> <div style="width:850px; padding: 10px 0;">
<div style='float:left; width: 500px'> <div style='float:left; width: 500px'>
<table class="tg" id="box3"> <table class="tg" id="box3">
...@@ -181,7 +181,7 @@ $(document).ready(function () { ...@@ -181,7 +181,7 @@ $(document).ready(function () {
</div> </div>
</div> </div>
<div style='clear:both'></div> <div style='clear:both'></div>
<h2>Total ressources consumption for partition (last minute)</h2> <h2>Total resources consumption for partition (last minute)</h2>
<table class="tg" id="box2"> <table class="tg" id="box2">
<tr> <tr>
<th class="tg-s6z2">Total Process</th> <th class="tg-s6z2">Total Process</th>
...@@ -192,7 +192,7 @@ $(document).ready(function () { ...@@ -192,7 +192,7 @@ $(document).ready(function () {
<th class="tg-s6z2">Memory %</th> <th class="tg-s6z2">Memory %</th>
</tr> </tr>
</table> </table>
<h2>ressources consumption for partition by process pid (last minute)</h2> <h2>resources consumption for partition by process pid (last minute)</h2>
<table class="tg" id="box1"> <table class="tg" id="box1">
<tr> <tr>
<th class="tg-s6z2">Process PID</th> <th class="tg-s6z2">Process PID</th>
......
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