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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Eric Zheng
slapos
Commits
7f658df1
Commit
7f658df1
authored
Feb 27, 2015
by
Tristan Cavelier
Committed by
Alain Takoudjou
Mar 31, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
monitor: monitor.py.in naming conventions
parent
829b4a61
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
35 additions
and
35 deletions
+35
-35
stack/erp5/instance-http-monitor.cfg.in
stack/erp5/instance-http-monitor.cfg.in
+1
-1
stack/monitor/buildout.cfg
stack/monitor/buildout.cfg
+3
-3
stack/monitor/monitor.cfg.in
stack/monitor/monitor.cfg.in
+5
-5
stack/monitor/monitor.py.in
stack/monitor/monitor.py.in
+10
-10
stack/monitor/webfile-directory/resource-consumption.cgi.in
stack/monitor/webfile-directory/resource-consumption.cgi.in
+16
-16
No files found.
stack/erp5/instance-http-monitor.cfg.in
View file @
7f658df1
...
@@ -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-res
s
ource-monitoring-cgi
deploy-resource-monitoring-cgi
setup-static-files
setup-static-files
certificate-authority
certificate-authority
zero-parameters
zero-parameters
...
...
stack/monitor/buildout.cfg
View file @
7f658df1
...
@@ -100,12 +100,12 @@ md5sum = d2b85ac31cbbf49c78dc51e90ddf305f
...
@@ -100,12 +100,12 @@ md5sum = d2b85ac31cbbf49c78dc51e90ddf305f
filename = logfile.cgi.in
filename = logfile.cgi.in
mode = 0644
mode = 0644
[res
sources
-cgi]
[res
ource-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 = 6
aed44f5048b58cc01408caf265a3c4d
md5sum = 6
1069d8cfd7e7204106c147edc61ebbe
filename = res
sources
.cgi.in
filename = res
ource-consumption
.cgi.in
mode = 0644
mode = 0644
[status-cgi]
[status-cgi]
...
...
stack/monitor/monitor.cfg.in
View file @
7f658df1
...
@@ -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-res
source
-monitoring-cgi]
[deploy-res
ource-consumption
-monitoring-cgi]
recipe = slapos.recipe.template:jinja2
recipe = slapos.recipe.template:jinja2
template = ${res
sources-cgi:location}/${ressources
-cgi:filename}
template = ${res
ource-consumption-cgi:location}/${resource-consumption
-cgi:filename}
rendered = $${monitor-directory:monitoring-cgi}/$${:filename}
rendered = $${monitor-directory:monitoring-cgi}/$${:filename}
filename = res
sources
.cgi
filename = res
ource-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
...
...
stack/monitor/monitor.py.in
View file @
7f658df1
...
@@ -129,12 +129,12 @@ def runScripts(directory):
...
@@ -129,12 +129,12 @@ def runScripts(directory):
return result
return result
def writeFile
s(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 monitor
s
.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()
monitor
s
['datetime'] = time.ctime(timestamp)
monitor
_dict
['datetime'] = time.ctime(timestamp)
json.dump(monitor
s
, 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)
monitor
s
= {}
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:
monitor
s
.update(runScripts(monitor_dir))
monitor
_dict
.update(runScripts(monitor_dir))
if options.promise or options.all:
if options.promise or options.all:
monitor
s
.update(runScripts(promise_dir))
monitor
_dict
.update(runScripts(promise_dir))
if options.service or options.all:
if options.service or options.all:
monitor
s
.update(runServices(pid_dir))
monitor
_dict
.update(runServices(pid_dir))
if options.only_stdout:
if options.only_stdout:
print json.dumps(monitor
s
)
print json.dumps(monitor
_dict
)
else:
else:
writeFile
s(monitors
)
writeFile
(monitor_dict
)
if __name__ == "__main__":
if __name__ == "__main__":
...
...
stack/monitor/webfile-directory/res
sources
.cgi.in
→
stack/monitor/webfile-directory/res
ource-consumption
.cgi.in
View file @
7f658df1
...
@@ -44,7 +44,7 @@ if action:
...
@@ -44,7 +44,7 @@ if action:
partition_user, date_scope)
partition_user, date_scope)
result_dict['memory'] = db.getPartitionUsedMemoryAverage(
result_dict['memory'] = db.getPartitionUsedMemoryAverage(
partition_user, date_scope)
partition_user, date_scope)
print json.dumps(result_dict)
print json.dumps(result_dict)
else:
else:
print """
<html><head>
print """
<html><head>
...
@@ -82,17 +82,17 @@ else:
...
@@ -82,17 +82,17 @@ else:
<script
language=
"javascript"
type=
"text/javascript"
>
<script
language=
"javascript"
type=
"text/javascript"
>
$
(
document
).
ready
(
function
()
{
$
(
document
).
ready
(
function
()
{
var
send
=
false
;
var
send
=
false
;
autoRefresh
();
autoRefresh
();
function
autoRefresh
()
{
function
autoRefresh
()
{
refresh
();
refresh
();
setTimeout
(
function
(){
autoRefresh
();
},
60000
);
setTimeout
(
function
(){
autoRefresh
();
},
60000
);
}
}
function
refresh
()
{
function
refresh
()
{
if
(
send
)
{
return
}
if
(
send
)
{
return
}
var
dataPost
=
{
'
posting-script
'
:
"
monitoring/res
sources
.cgi
"
,
var
dataPost
=
{
'
posting-script
'
:
"
monitoring/res
ource-consumption
.cgi
"
,
action
:
"
refresh
"
};
action
:
"
refresh
"
};
send
=
true
;
send
=
true
;
$
(
"
#msg
"
).
fadeIn
();
$
(
"
#msg
"
).
fadeIn
();
...
@@ -109,15 +109,15 @@ $(document).ready(function () {
...
@@ -109,15 +109,15 @@ $(document).ready(function () {
table2
+=
'
<th class="tg-s6z2">CPU %</th><th class="tg-s6z2">CPU Time</th>
'
;
table2
+=
'
<th class="tg-s6z2">CPU %</th><th class="tg-s6z2">CPU Time</th>
'
;
table2
+=
'
<th class="tg-s6z2">Threads</th><th class="tg-s6z2">Memory Usage</th>
'
;
table2
+=
'
<th class="tg-s6z2">Threads</th><th class="tg-s6z2">Memory Usage</th>
'
;
table2
+=
'
<th class="tg-s6z2">Memory %</th></tr>
'
;
table2
+=
'
<th class="tg-s6z2">Memory %</th></tr>
'
;
table1
=
'
<tr><th class="tg-s6z2">Process PID</th>
'
;
table1
=
'
<tr><th class="tg-s6z2">Process PID</th>
'
;
table1
+=
'
<th class="tg-s6z2">CPU %</th><th class="tg-s6z2">CPU Time</th>
'
;
table1
+=
'
<th class="tg-s6z2">CPU %</th><th class="tg-s6z2">CPU Time</th>
'
;
table1
+=
'
<th class="tg-s6z2">Threads</th><th class="tg-s6z2">Memory Usage</th>
'
;
table1
+=
'
<th class="tg-s6z2">Threads</th><th class="tg-s6z2">Memory Usage</th>
'
;
table1
+=
'
<th class="tg-s6z2">Memory %</th></tr>
'
;
table1
+=
'
<th class="tg-s6z2">Memory %</th></tr>
'
;
table3
=
'
<tr><th class="tg-s6z2">CPU Load Average %</th>
'
;
table3
=
'
<tr><th class="tg-s6z2">CPU Load Average %</th>
'
;
table3
+=
'
<th class="tg-s6z2">Memory Consumption Average</th></tr>
'
;
table3
+=
'
<th class="tg-s6z2">Memory Consumption Average</th></tr>
'
;
line2
=
"
<tr class='tg-4eph tg-s6z2'>
"
line2
=
"
<tr class='tg-4eph tg-s6z2'>
"
line2
+=
"
<td>
"
+
result
[
'
status
'
][
'
total_process
'
]
+
"
</td>
"
;
line2
+=
"
<td>
"
+
result
[
'
status
'
][
'
total_process
'
]
+
"
</td>
"
;
line2
+=
"
<td>
"
+
result
[
'
status
'
][
'
cpu_percent
'
]
+
"
</td>
"
;
line2
+=
"
<td>
"
+
result
[
'
status
'
][
'
cpu_percent
'
]
+
"
</td>
"
;
...
@@ -138,11 +138,11 @@ $(document).ready(function () {
...
@@ -138,11 +138,11 @@ $(document).ready(function () {
line
+=
"
<td>
"
+
consump
[
i
][
4
]
+
"
</td>
"
;
line
+=
"
<td>
"
+
consump
[
i
][
4
]
+
"
</td>
"
;
line
+=
"
</tr>
"
;
line
+=
"
</tr>
"
;
}
}
table3
+=
"
<tr class='tg-4eph tg-s6z2'>
"
table3
+=
"
<tr class='tg-4eph tg-s6z2'>
"
table3
+=
"
<td>
"
+
result
[
'
cpu-load
'
]
+
"
</td>
"
;
table3
+=
"
<td>
"
+
result
[
'
cpu-load
'
]
+
"
</td>
"
;
table3
+=
"
<td>
"
+
result
[
'
memory
'
]
+
"
Mb</td></tr></table>
"
;
table3
+=
"
<td>
"
+
result
[
'
memory
'
]
+
"
Mb</td></tr></table>
"
;
$
(
"
#box3
"
).
html
(
table3
);
$
(
"
#box3
"
).
html
(
table3
);
$
(
"
#box2
"
).
html
(
table2
+
line2
+
'
</table>
'
);
$
(
"
#box2
"
).
html
(
table2
+
line2
+
'
</table>
'
);
$
(
"
#box1
"
).
html
(
table1
+
line
+
'
</table>
'
);
$
(
"
#box1
"
).
html
(
table1
+
line
+
'
</table>
'
);
...
@@ -155,15 +155,15 @@ $(document).ready(function () {
...
@@ -155,15 +155,15 @@ $(document).ready(function () {
$
(
"
#msg
"
).
fadeOut
();
$
(
"
#msg
"
).
fadeOut
();
});
});
}
}
$
(
"
#refresh
"
).
click
(
function
()
{
$
(
"
#refresh
"
).
click
(
function
()
{
refresh
();
refresh
();
});
});
});
});
</script>
</script>
</head><body>
</head><body>
<h1>
Computer partition res
s
ources 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 res
s
ources 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>
res
s
ources 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>
...
@@ -204,4 +204,4 @@ $(document).ready(function () {
...
@@ -204,4 +204,4 @@ $(document).ready(function () {
</tr>
</tr>
</table>
</table>
<p
id=
"error"
></p>
<p
id=
"error"
></p>
</body></html>
"""
</body></html>
"""
\ No newline at end of file
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