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
Sebastien Robin
slapos
Commits
78b737be
Commit
78b737be
authored
Feb 02, 2015
by
Alain Takoudjou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
monitor-fix: get collector database path from configuration file
parent
f6bfa177
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
22 deletions
+35
-22
stack/monitor/buildout.cfg
stack/monitor/buildout.cfg
+3
-3
stack/monitor/collect.py
stack/monitor/collect.py
+6
-10
stack/monitor/monitor.cfg.in
stack/monitor/monitor.cfg.in
+3
-3
stack/monitor/webfile-directory/ressources.cgi.in
stack/monitor/webfile-directory/ressources.cgi.in
+23
-6
No files found.
stack/monitor/buildout.cfg
View file @
78b737be
...
...
@@ -46,7 +46,7 @@ recipe = slapos.recipe.template
url = ${:_profile_base_location_}/monitor.cfg.in
output = ${buildout:directory}/monitor.cfg
filename = monitor.cfg
md5sum =
05ed0063a8de43d3711b23605cdab4d7
md5sum =
87d7c22ed77a0e77b06b6c7869024b74
mode = 0644
[monitor-bin]
...
...
@@ -104,7 +104,7 @@ mode = 0644
recipe = hexagonit.recipe.download
url = ${:_profile_base_location_}/webfile-directory/${:filename}
download-only = true
md5sum =
739a6e470ef174b9d0b523aa349860cb
md5sum =
6aed44f5048b58cc01408caf265a3c4d
filename = ressources.cgi.in
mode = 0644
...
...
@@ -173,7 +173,7 @@ mode = 0644
recipe = hexagonit.recipe.download
url = ${:_profile_base_location_}/${:filename}
download-only = true
md5sum =
b0b22c8c2fd8dfbf6ee7271aaa09a7d2
md5sum =
08c31783601214109e803ab69ea83aa1
filename = collect.py
mode = 0644
...
...
stack/monitor/collect.py
View file @
78b737be
...
...
@@ -34,13 +34,9 @@ from datetime import datetime, timedelta
class
Database
:
database_name
=
"collector.db"
table_list
=
[
"user"
,
"computer"
,
"system"
,
"disk"
,
\
"temperature"
,
"heating"
]
def
__init__
(
self
,
directory
=
None
):
assert
self
.
database_name
is
not
None
self
.
uri
=
os
.
path
.
join
(
directory
,
self
.
database_name
)
def
__init__
(
self
,
db_path
=
None
):
assert
os
.
path
.
exists
(
db_path
)
and
os
.
path
.
isfile
(
db_path
)
self
.
uri
=
db_path
self
.
connection
=
None
self
.
cursor
=
None
...
...
@@ -109,7 +105,7 @@ class Database:
self
.
close
()
if
len
(
sample_amount
)
and
len
(
memory_sum
):
return
round
(
memory_sum
[
0
][
0
]
/
sample_amount
[
0
][
0
]
,
2
)
return
round
(
memory_sum
[
0
][
0
]
/
(
sample_amount
[
0
][
0
]
*
1024
*
1024.0
)
,
2
)
def
getPartitionConsumption
(
self
,
partition_id
,
where
=
""
):
self
.
connect
()
...
...
@@ -132,7 +128,7 @@ group by pid order by cpu_result desc""" % (
comsumption_list
.
append
([
result
[
6
],
round
((
result
[
1
]
/
count
),
2
),
round
((
result
[
2
]
/
count
),
2
),
round
(
result
[
3
],
2
),
round
((
result
[
4
]
/
count
),
2
),
round
((
result
[
5
]
/
count
),
2
)])
round
((
result
[
5
]
/
(
count
*
1024
*
1024.0
)
),
2
)])
self
.
close
()
return
comsumption_list
...
...
@@ -158,6 +154,6 @@ date='%s' and partition='%s' and (time between '%s' and '%s') %s""" % (
'cpu_time'
:
round
(
result
[
2
][
0
],
2
),
'cpu_num_threads'
:
round
(
result
[
3
][
0
],
2
),
'memory_percent'
:
round
(
result
[
4
][
0
],
2
),
'memory_rss'
:
round
(
result
[
5
][
0
],
2
)}
'memory_rss'
:
round
(
result
[
5
][
0
]
/
(
1024
*
1024.0
)
,
2
)}
return
None
stack/monitor/monitor.cfg.in
View file @
78b737be
...
...
@@ -200,13 +200,12 @@ recipe = slapos.recipe.template:jinja2
template = ${ressources-cgi:location}/${ressources-cgi:filename}
rendered = $${monitor-directory:monitoring-cgi}/$${:filename}
filename = ressources.cgi
mode = 0744
# XXX - We need to find a proper way to set db_path here, maybe by using zero-parameters ??
mode = $${deploy-settings-cgi:mode}
context =
key monitor_bin monitor-parameters:executable
raw python_executable ${buildout:directory}/bin/${extra-eggs:interpreter}
key root_folder buildout:directory
raw
db_path /srv/slapgrid/var/data-log/
raw
config_cfg $${buildout:directory}/$${public:filename}
[make-rss]
recipe = slapos.recipe.template:jinja2
...
...
@@ -345,6 +344,7 @@ name = example.com
recipe = slapos.cookbook:zero-knowledge.write
filename = knowledge0.cfg
status-history-length = 5
collect-db-path = /srv/slapgrid/var/data-log/collector.db
[zero-parameters]
recipe = slapos.cookbook:zero-knowledge.read
...
...
stack/monitor/webfile-directory/ressources.cgi.in
View file @
78b737be
...
...
@@ -7,16 +7,32 @@ import os
import pwd
from time import strftime
from datetime import datetime
import ConfigParser
import collect
cgitb.enable(display=0, logdir="/tmp/cgi.log")
form = cgi.FieldStorage()
db_path = "{{ db_path
}}"
config_file = "{{ config_cfg
}}"
action = form.getvalue("action", "")
home = "{{ root_folder }}".strip()
db_path = ""
if not os.path.exists(config_file):
print """
<html><head></head>
<body><h2>
Could not find database path in configuration file.
the file %s might not exist.
</h2></body></html>
""" % config_file
exit(0)
parser = ConfigParser.ConfigParser()
parser.read(config_file)
try:
db_path = parser.get('public', 'collect-db-path')
except ConfigParser.NoOptionError, e:
print """
<html><head></head>
<body><h2>
Could not find database path in configuration file.
<br/>
%s
</h2></body></html>
""" % str(e)
exit(0)
if action:
db = collect.Database(d
irectory
=db_path)
db = collect.Database(d
b_path
=db_path)
stat_info = os.stat(home)
partition_user = pwd.getpwuid(stat_info.st_uid)[0]
result_dict = {}
...
...
@@ -44,6 +60,7 @@ else:
.tg
.tg-s6z2
td
{
text-align
:
center
}
.tg
.tg-zapm
{
background-color
:
#f9f9f9
;}
.tg
.tg-4eph
{
background-color
:
#f9f9f9
}
.tg
tr
:hover
td
{
background-color
:
#FAFAFA
}
.head
{
background-color
:
#0078e7
;
border
:
0px
solid
#ffffff
;
...
...
@@ -98,7 +115,7 @@ $(document).ready(function () {
table1
+=
'
<th class="tg-s6z2">Threads</th><th class="tg-s6z2">Memory Usage</th>
'
;
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>
'
;
line2
=
"
<tr class='tg-4eph tg-s6z2'>
"
...
...
@@ -106,7 +123,7 @@ $(document).ready(function () {
line2
+=
"
<td>
"
+
result
[
'
status
'
][
'
cpu_percent
'
]
+
"
</td>
"
;
line2
+=
"
<td>
"
+
result
[
'
status
'
][
'
cpu_time
'
]
+
"
</td>
"
;
line2
+=
"
<td>
"
+
result
[
'
status
'
][
'
cpu_num_threads
'
]
+
"
</td>
"
;
line2
+=
"
<td>
"
+
result
[
'
status
'
][
'
memory_rss
'
]
+
"
</td>
"
;
line2
+=
"
<td>
"
+
result
[
'
status
'
][
'
memory_rss
'
]
+
"
Mb
</td>
"
;
line2
+=
"
<td>
"
+
result
[
'
status
'
][
'
memory_percent
'
]
+
"
</td>
"
;
line2
+=
"
</tr>
"
;
for
(
var
i
=
0
;
i
<
consump
.
length
;
i
++
)
{
...
...
@@ -117,14 +134,14 @@ $(document).ready(function () {
line
+=
"
<td>
"
+
consump
[
i
][
1
]
+
"
</td>
"
;
line
+=
"
<td>
"
+
consump
[
i
][
2
]
+
"
</td>
"
;
line
+=
"
<td>
"
+
consump
[
i
][
3
]
+
"
</td>
"
;
line
+=
"
<td>
"
+
consump
[
i
][
5
]
+
"
</td>
"
;
line
+=
"
<td>
"
+
consump
[
i
][
5
]
+
"
Mb
</td>
"
;
line
+=
"
<td>
"
+
consump
[
i
][
4
]
+
"
</td>
"
;
line
+=
"
</tr>
"
;
}
table3
+=
"
<tr class='tg-4eph tg-s6z2'>
"
table3
+=
"
<td>
"
+
result
[
'
cpu-load
'
]
+
"
</td>
"
;
table3
+=
"
<td>
"
+
result
[
'
memory
'
]
+
"
</td></tr></table>
"
;
table3
+=
"
<td>
"
+
result
[
'
memory
'
]
+
"
Mb
</td></tr></table>
"
;
$
(
"
#box3
"
).
html
(
table3
);
$
(
"
#box2
"
).
html
(
table2
+
line2
+
'
</table>
'
);
...
...
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