Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
envsetup
Manage
Activity
Members
Plan
Redmine
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mediaserver
envsetup
Commits
a6d54cd9
Commit
a6d54cd9
authored
7 years ago
by
Stéphane Diemer
Browse files
Options
Downloads
Patches
Plain Diff
Check available disk space and not free space (refs
#22279
).
parent
263ba714
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_partitions.py
+11
-12
11 additions, 12 deletions
tests/test_partitions.py
with
11 additions
and
12 deletions
tests/test_partitions.py
+
11
−
12
View file @
a6d54cd9
...
...
@@ -29,13 +29,13 @@ paths = [
'
mount_point
'
:
'
/
'
,
'
recommended_types
'
:
(
'
ext4
'
,),
'
min_size_gbytes
'
:
14
,
'
min_
free_siz
e_gbytes
'
:
5
,
'
min_
availabl
e_gbytes
'
:
5
,
},
{
'
mount_point
'
:
'
/home/msuser/msinstance
'
,
'
recommended_types
'
:
(
'
ext4
'
,
'
nfsv4
'
),
'
min_size_gbytes
'
:
400
,
'
min_
free_siz
e_gbytes
'
:
15
,
'
min_
availabl
e_gbytes
'
:
15
,
},
{
'
type
'
:
'
swap
'
,
...
...
@@ -59,12 +59,12 @@ def get_swap_gbytes():
def
get_path
(
path
):
# Filesystem Type 1B-blocks Used Available Use% Mounted on
# /dev/loop2 ext4 52710469632 38253940736 11755397120 77% /
status
,
output
=
subprocess
.
getstatusoutput
(
'
df --output=
"
source,fstype,size,
used
"
-B 1 %s | tail -n 1
'
%
path
)
status
,
output
=
subprocess
.
getstatusoutput
(
'
df --output=
"
source,fstype,size,
avail
"
-B 1 %s | tail -n 1
'
%
path
)
if
status
==
0
:
dev
,
fstype
,
size
,
used
=
output
.
split
()
dev
,
fstype
,
size
,
available
=
output
.
split
()
else
:
dev
=
fstype
=
size
=
used
=
None
return
dev
,
fstype
,
to_gbytes
(
int
(
size
)),
to_gbytes
(
int
(
used
))
dev
=
fstype
=
size
=
available
=
None
return
dev
,
fstype
,
to_gbytes
(
int
(
size
)),
to_gbytes
(
int
(
available
))
def
check_allocation
(
dev
):
...
...
@@ -105,19 +105,18 @@ def check_path(p):
if
os
.
path
.
exists
(
mount_point
):
mount_point
=
os
.
path
.
realpath
(
mount_point
)
name
=
mount_point
dev
,
fstype
,
psize
,
used
=
get_path
(
mount_point
)
dev
,
fstype
,
psize
,
available
=
get_path
(
mount_point
)
if
fstype
not
in
p
.
get
(
'
recommended_types
'
):
print
(
'
Warning, partition of %s fs type not recommended %s(current: %s, recommended: %s)%s
'
%
(
name
,
YELLOW
,
fstype
,
p
[
'
recommended_types
'
],
DEF
))
warning
=
True
if
'
nfs
'
not
in
dev
:
warning
=
not
check_allocation
(
dev
)
free_gb
=
psize
-
used
min_free_size_gbytes
=
p
.
get
(
'
min_free_size_gbytes
'
)
if
min_free_size_gbytes
and
free_gb
<
min_free_size_gbytes
:
print
(
'
Partition of %s has less than %s GB free (%s GB free)
'
%
(
mount_point
,
min_free_size_gbytes
,
free_gb
))
min_available_gbytes
=
p
.
get
(
'
min_available_gbytes
'
)
if
min_available_gbytes
and
available
<
min_available_gbytes
:
print
(
'
Partition of %s has less than %s GB available (%s GB available)
'
%
(
mount_point
,
min_available_gbytes
,
available
))
error
=
True
else
:
print
(
'
Partition of %s is OK
'
%
name
)
print
(
'
Partition of %s is OK
(%s GB available)
'
%
(
name
,
available
)
)
else
:
print
(
'
%s not found, cannot check
'
%
mount_point
)
elif
p
.
get
(
'
type
'
)
==
'
swap
'
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment