Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
slapos.core
Commits
bf1908bb
Commit
bf1908bb
authored
May 15, 2014
by
Lutra Conseil
Committed by
Rafael Monnerat
Nov 10, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[slapos.collect] Minor cleanups and cosmetic changes.
parent
40b2cf24
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
10 additions
and
21 deletions
+10
-21
slapos/cli/collect.py
slapos/cli/collect.py
+0
-1
slapos/collect/__init__.py
slapos/collect/__init__.py
+10
-9
slapos/collect/db.py
slapos/collect/db.py
+0
-2
slapos/collect/entity.py
slapos/collect/entity.py
+0
-2
slapos/collect/reporter.py
slapos/collect/reporter.py
+0
-1
slapos/tests/collect.py
slapos/tests/collect.py
+0
-6
No files found.
slapos/cli/collect.py
View file @
bf1908bb
...
...
@@ -23,5 +23,4 @@ class CollectCommand(ConfigCommand):
@
must_be_root
def
take_action
(
self
,
args
):
configp
=
self
.
fetch_config
(
args
)
# Make sure ipv4 is working
do_collect
(
configp
)
slapos/collect/__init__.py
View file @
bf1908bb
...
...
@@ -4,6 +4,10 @@ from slapos.collect.db import Database
from
slapos.util
import
mkdir_p
# Local import
from
snapshot
import
ProcessSnapshot
,
SystemSnapshot
,
ComputerSnapshot
from
slapos.collect.reporter
import
SystemJSONReporterDumper
,
\
RawCSVDumper
,
\
SystemCSVReporterDumper
from
entity
import
get_user_list
,
Computer
def
_get_time
():
...
...
@@ -44,21 +48,18 @@ def do_collect(conf):
except
(
KeyboardInterrupt
,
SystemExit
,
NoSuchProcess
):
raise
# XXX: we should use a value from the config file and not a hardcoded one
instance_root
=
conf
.
get
(
"slapos"
,
"instance_root"
)
mkdir_p
(
"%s/var/data-log/"
%
instance_root
)
database
=
Database
(
"%s/var/data-log/"
%
instance_root
)
log_directory
=
"%s/var/data-log"
%
conf
.
get
(
"slapos"
,
"instance_root"
)
mkdir_p
(
log_directory
)
database
=
Database
(
log_directory
)
computer
=
Computer
(
ComputerSnapshot
())
computer
.
save
(
database
,
collected_date
,
collected_time
)
for
user
in
user_dict
.
values
():
user
.
save
(
database
,
collected_date
,
collected_time
)
from
slapos.collect.reporter
import
SystemJSONReporterDumper
,
RawCSVDumper
,
SystemCSVReporterDumper
#SystemJSONReporterDumper(database).dump()
SystemCSVReporterDumper
(
database
).
dump
(
"%s/var/data-log/"
%
instance_root
)
RawCSVDumper
(
database
).
dump
(
"%s/var/data-log/"
%
instance_root
)
SystemCSVReporterDumper
(
database
).
dump
(
log_directory
)
RawCSVDumper
(
database
).
dump
(
log_directory
)
except
AccessDenied
:
print
"You HAVE TO execute this script with root permission."
...
...
slapos/collect/db.py
View file @
bf1908bb
...
...
@@ -39,8 +39,6 @@ class Database:
"date, time) values "
\
"('%s', %s, '%s', %s, %s, %s, %s, %s, %s, %s, '%s', '%s' )"
INSERT_COMPUTER_TEMPLATE
=
"insert into computer("
\
" cpu_num_core, cpu_frequency, cpu_type,"
\
"memory_size, memory_type, partition_list,"
\
...
...
slapos/collect/entity.py
View file @
bf1908bb
...
...
@@ -44,7 +44,6 @@ class User(object):
database
.
commit
()
database
.
close
()
class
Computer
(
dict
):
def
__init__
(
self
,
computer_snapshot
):
...
...
@@ -87,7 +86,6 @@ class Computer(dict):
insertion_date
=
collected_date
,
insertion_time
=
collected_time
)
def
_save_disk_partition_snapshot
(
self
,
database
,
collected_date
,
collected_time
):
for
disk_partition
in
self
.
computer_snapshot
.
get
(
"disk_snapshot_list"
):
database
.
insertDiskPartitionSnapshot
(
...
...
slapos/collect/reporter.py
View file @
bf1908bb
...
...
@@ -25,7 +25,6 @@ class SystemReporter(Dumper):
partition_id
=
partition
.
split
(
"-"
)[
0
].
split
(
"/"
)[
-
1
]
item
=
"memory_%s"
%
partition
.
split
(
"-"
)[
1
]
self
.
writeFile
(
"disk_%s_%s"
%
(
item
,
partition_id
),
folder
,
collected_item_list
)
self
.
writeFile
(
"disk_%s_%s"
%
(
item
,
partition_id
),
folder
,
collected_item_list
)
self
.
db
.
close
()
...
...
slapos/tests/collect.py
View file @
bf1908bb
...
...
@@ -64,9 +64,6 @@ class FakeDatabase(object):
def
insertDiskPartitionSnapshot
(
self
,
*
args
,
**
kw
):
self
.
invoked_method_list
.
append
((
"insertDiskPartitionSnapshot"
,
(
args
,
kw
)))
class
TestCollectDatabase
(
unittest
.
TestCase
):
def
setUp
(
self
):
...
...
@@ -217,9 +214,6 @@ class TestCollectSnapshot(unittest.TestCase):
if
os
.
path
.
exists
(
self
.
temp_dir
):
shutil
.
rmtree
(
self
.
temp_dir
)
def
tearDown
(
self
):
pass
def
test_process_snapshot
(
self
):
process
=
psutil
.
Process
(
os
.
getpid
())
process_snapshot
=
snapshot
.
ProcessSnapshot
(
process
)
...
...
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