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
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
Léo-Paul Géneau
slapos.core
Commits
657f9447
Commit
657f9447
authored
Oct 23, 2019
by
Łukasz Nowak
Committed by
Rafael Monnerat
Oct 23, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix/slapos node collect utc
/reviewed-on
nexedi/slapos.core!147
parent
2baa2125
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
11 deletions
+11
-11
slapos/collect/__init__.py
slapos/collect/__init__.py
+4
-4
slapos/collect/db.py
slapos/collect/db.py
+4
-4
slapos/collect/entity.py
slapos/collect/entity.py
+1
-1
slapos/collect/reporter.py
slapos/collect/reporter.py
+2
-2
No files found.
slapos/collect/__init__.py
View file @
657f9447
...
...
@@ -29,7 +29,7 @@
from
__future__
import
print_function
from
psutil
import
process_iter
,
NoSuchProcess
,
AccessDenied
from
time
import
strftime
from
time
import
strftime
,
gmtime
import
shutil
import
datetime
from
slapos.collect.db
import
Database
...
...
@@ -46,7 +46,7 @@ from slapos.collect.reporter import RawCSVDumper, \
from
.entity
import
get_user_list
,
Computer
def
_get_time
():
return
strftime
(
"%Y-%m-%d -- %H:%M:%S"
).
split
(
" -- "
)
return
strftime
(
"%Y-%m-%d -- %H:%M:%S"
,
gmtime
()
).
split
(
" -- "
)
def
build_snapshot
(
proc
):
try
:
...
...
@@ -144,10 +144,10 @@ def do_collect(conf):
database
=
database
,
location
=
consumption_report_directory
)
base
=
datetime
.
datetime
.
today
()
base
=
datetime
.
datetime
.
utcnow
().
date
()
for
x
in
range
(
1
,
3
):
report_file
=
consumption_report
.
buildXMLReport
(
(
base
-
datetime
.
timedelta
(
days
=
x
)).
strftime
(
"%Y-%m-%d"
))
(
base
-
datetime
.
timedelta
(
days
=
x
)).
strftime
(
"%Y-%m-%d"
)
,
gmtime
()
)
if
report_file
is
not
None
:
shutil
.
copy
(
report_file
,
xml_report_directory
)
...
...
slapos/collect/db.py
View file @
657f9447
...
...
@@ -28,7 +28,7 @@
##############################################################################
import
os
from
time
import
strftime
from
time
import
strftime
,
gmtime
import
datetime
from
slapos.util
import
sqlite_connect
...
...
@@ -162,7 +162,7 @@ class Database:
self
.
close
()
def
_getInsertionDateTuple
(
self
):
return
strftime
(
"%Y-%m-d -- %H:%M:%S"
).
split
(
" -- "
)
return
strftime
(
"%Y-%m-d -- %H:%M:%S"
,
gmtime
()
).
split
(
" -- "
)
###################
# Insertion methods
...
...
@@ -252,7 +252,7 @@ class Database:
def
_getGarbageCollectionDateList
(
self
,
days_to_preserve
=
3
):
""" Return the list of dates to Preserve when data collect
"""
base
=
datetime
.
datetime
.
today
()
base
=
datetime
.
datetime
.
utcnow
().
date
()
date_list
=
[]
for
x
in
range
(
0
,
days_to_preserve
):
date_list
.
append
((
base
-
datetime
.
timedelta
(
days
=
x
)).
strftime
(
"%Y-%m-%d"
))
...
...
@@ -419,7 +419,7 @@ class Database:
select_sql
=
"SELECT date, time FROM heating ORDER BY date, time DESC LIMIT 1"
for
__date
,
__time
in
self
.
_execute
(
select_sql
):
_date
=
datetime
.
datetime
.
strptime
(
"%s %s"
%
(
__date
,
__time
),
"%Y-%m-%d %H:%M:%S"
)
return
datetime
.
datetime
.
now
()
-
_date
return
datetime
.
datetime
.
utc
now
()
-
_date
return
datetime
.
timedelta
(
weeks
=
520
)
def
getLastZeroEmissionRatio
(
self
):
...
...
slapos/collect/entity.py
View file @
657f9447
...
...
@@ -79,7 +79,7 @@ class User(object):
where
=
"partition='%s'"
%
self
.
name
):
latest_date
=
datetime
.
strptime
(
'%s %s'
%
date_time
,
"%Y-%m-%d %H:%M:%S"
)
if
(
datetime
.
now
()
-
latest_date
).
seconds
<
time_cycle
:
if
(
datetime
.
utc
now
()
-
latest_date
).
seconds
<
time_cycle
:
# wait the time cycle
return
break
...
...
slapos/collect/reporter.py
View file @
657f9447
...
...
@@ -59,7 +59,7 @@ class SystemReporter(Dumper):
def
dump
(
self
,
folder
):
""" Dump data """
_date
=
time
.
strftime
(
"%Y-%m-%d"
)
_date
=
time
.
strftime
(
"%Y-%m-%d"
,
time
.
gmtime
()
)
self
.
db
.
connect
()
for
item
,
collected_item_list
in
six
.
iteritems
(
self
.
db
.
exportSystemAsDict
(
_date
)):
self
.
writeFile
(
item
,
folder
,
collected_item_list
)
...
...
@@ -94,7 +94,7 @@ class RawDumper(Dumper):
""" Dump raw data in a certain format
"""
def
dump
(
self
,
folder
):
date
=
time
.
strftime
(
"%Y-%m-%d"
)
date
=
time
.
strftime
(
"%Y-%m-%d"
,
time
.
gmtime
()
)
self
.
db
.
connect
()
table_list
=
self
.
db
.
getTableList
()
for
date_scope
,
amount
in
self
.
db
.
getDateScopeList
(
ignore_date
=
date
):
...
...
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