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
Lisa Casino
slapos.core
Commits
7bfb27e4
Commit
7bfb27e4
authored
Jun 08, 2021
by
Lisa Casino
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos.collect: snapshot.py command is now gdu -n
parent
01e74ae5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
13 deletions
+20
-13
slapos/collect/entity.py
slapos/collect/entity.py
+3
-8
slapos/collect/snapshot.py
slapos/collect/snapshot.py
+17
-5
No files found.
slapos/collect/entity.py
View file @
7bfb27e4
...
@@ -33,11 +33,6 @@ from slapos.collect.snapshot import FolderSizeSnapshot
...
@@ -33,11 +33,6 @@ from slapos.collect.snapshot import FolderSizeSnapshot
from
time
import
strftime
,
gmtime
from
time
import
strftime
,
gmtime
def
_get_time
():
# add by Lisa to print
return
strftime
(
"%Y-%m-%d -- %H:%M:%S"
,
gmtime
()).
split
(
" -- "
)
def
get_user_list
(
config
):
def
get_user_list
(
config
):
nb_user
=
int
(
config
.
get
(
"slapformat"
,
"partition_amount"
))
nb_user
=
int
(
config
.
get
(
"slapformat"
,
"partition_amount"
))
name_prefix
=
config
.
get
(
"slapformat"
,
"user_base_name"
)
name_prefix
=
config
.
get
(
"slapformat"
,
"user_base_name"
)
...
@@ -47,7 +42,7 @@ def get_user_list(config):
...
@@ -47,7 +42,7 @@ def get_user_list(config):
# By default, enable disk snapshot,
# By default, enable disk snapshot,
# and set time_cycle to 24hours after the first disk snapshot run
# and set time_cycle to 24hours after the first disk snapshot run
pid_folder_tmp
=
instance_root
+
"/var/run/"
pid_folder_tmp
=
instance_root
+
"/var/run/"
disk_snapshot_params
=
{
'enable'
:
True
,
'time_cycle'
:
8640
0
,
\
disk_snapshot_params
=
{
'enable'
:
True
,
'time_cycle'
:
1
0
,
\
'pid_folder'
:
pid_folder_tmp
,
'use_quota'
:
False
}
'pid_folder'
:
pid_folder_tmp
,
'use_quota'
:
False
}
if
config
.
has_section
(
'collect'
):
if
config
.
has_section
(
'collect'
):
...
@@ -102,11 +97,11 @@ class User(object):
...
@@ -102,11 +97,11 @@ class User(object):
pid_file
=
self
.
disk_snapshot_params
.
get
(
'pid_folder'
,
None
)
pid_file
=
self
.
disk_snapshot_params
.
get
(
'pid_folder'
,
None
)
if
pid_file
is
not
None
:
if
pid_file
is
not
None
:
pid_file
=
os
.
path
.
join
(
pid_file
,
'%s_disk_size.pid'
%
self
.
name
)
pid_file
=
os
.
path
.
join
(
pid_file
,
'%s_disk_size.pid'
%
self
.
name
)
#print("path", self.path)
print
(
"pid_file"
,
pid_file
)
disk_snapshot
=
FolderSizeSnapshot
(
self
.
path
,
pid_file
)
disk_snapshot
=
FolderSizeSnapshot
(
self
.
path
,
pid_file
)
disk_snapshot
.
update_folder_size
()
disk_snapshot
.
update_folder_size
()
print
(
"pid_file"
,
pid_file
,
disk_snapshot
.
disk_usage
)
# Skeep insert empty partition: size <= 1Mb
# Skeep insert empty partition: size <= 1Mb
if
disk_snapshot
.
disk_usage
<=
1024.0
and
\
if
disk_snapshot
.
disk_usage
<=
1024.0
and
\
not
self
.
disk_snapshot_params
.
get
(
'testing'
,
False
):
not
self
.
disk_snapshot_params
.
get
(
'testing'
,
False
):
...
...
slapos/collect/snapshot.py
View file @
7bfb27e4
...
@@ -112,18 +112,30 @@ class FolderSizeSnapshot(_Snapshot):
...
@@ -112,18 +112,30 @@ class FolderSizeSnapshot(_Snapshot):
def
_getSize
(
self
,
file_path
):
def
_getSize
(
self
,
file_path
):
size
=
0
size
=
0
command
=
'
du -s
%s'
%
file_path
command
=
'
gdu -n
%s'
%
file_path
process
=
subprocess
.
Popen
(
command
,
stdout
=
subprocess
.
PIPE
,
process
=
subprocess
.
Popen
(
command
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
,
shell
=
True
)
stderr
=
subprocess
.
PIPE
,
shell
=
True
)
# write pid process : du -s /srv/slapgrid/slappart[i]
if
self
.
pid_file
:
if
self
.
pid_file
:
with
open
(
self
.
pid_file
,
'w'
)
as
fpid
:
with
open
(
self
.
pid_file
,
'w'
)
as
fpid
:
pid
=
fpid
.
write
(
str
(
process
.
pid
))
pid
=
fpid
.
write
(
str
(
process
.
pid
))
resul
t
=
process
.
communicate
()[
0
]
outpu
t
=
process
.
communicate
()[
0
]
if
process
.
returncode
==
0
:
if
process
.
returncode
==
0
:
size
,
_
=
result
.
strip
().
split
()
# retourne la taille + path
result
=
output
.
strip
().
split
()
unwanted_char
=
{
'@'
,
'e'
,
'!'
,
'.'
,
'H'
}
result
=
[
ele
for
ele
in
result
if
ele
not
in
unwanted_char
]
for
item
in
range
(
0
,
len
(
result
),
3
):
if
(
result
[
item
+
1
]
==
"MiB"
):
result
[
item
]
=
float
(
result
[
item
])
*
1024
elif
(
result
[
item
+
1
]
==
"GiB"
):
result
[
item
]
=
float
(
result
[
item
])
*
1024
*
1024
elif
(
result
[
item
+
1
]
==
"TiB"
):
result
[
item
]
=
float
(
result
[
item
])
*
1024
*
1024
*
1024
#print("Taille : %s \tfolder/file : %s" % (float(result[item]), result[item+2]))
size
+=
float
(
result
[
item
])
return
float
(
size
)
return
float
(
size
)
class
SystemSnapshot
(
_Snapshot
):
class
SystemSnapshot
(
_Snapshot
):
...
...
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