Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Paste
P68900
ceph_reweight_dc.py
Active
Public
Actions
Authored by
ProdPasteBot
on Sep 11 2024, 7:53 AM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Flag For Later
Tags
None
Referenced Files
F57499119: ceph_reweight_dc.py
Sep 11 2024, 7:53 AM
2024-09-11 07:53:36 (UTC+0)
Subscribers
None
#!/usr/bin/env python3
import
subprocess
import
json
health_json
=
subprocess
.
check_output
([
"ceph"
,
"health"
,
"detail"
,
"-f=json"
])
health_data
=
json
.
loads
(
health_json
)
for
message_data
in
health_data
[
"checks"
][
"OSD_NEARFULL"
][
"detail"
]:
message
=
message_data
[
"message"
]
osd
=
message
.
split
(
" "
,
1
)[
0
]
print
(
f
"Reweighting osd {osd}"
)
weight_json
=
subprocess
.
check_output
([
"ceph"
,
"osd"
,
"df"
,
"-f=json"
,
osd
])
weight_data
=
json
.
loads
(
weight_json
)
cur_weight
=
weight_data
[
"nodes"
][
0
][
"reweight"
]
print
(
f
" cur_weight={cur_weight}"
)
new_weight
=
cur_weight
-
0.05
if
new_weight
<
0.5
:
print
(
f
"WARNING: weight of {osd} will go under 0.5 -> {new_weight}"
)
print
(
f
" new_weight={new_weight}"
)
print
(
"If that's ok, hit enter"
)
input
()
for
message_data
in
health_data
[
"checks"
][
"OSD_NEARFULL"
][
"detail"
]:
message
=
message_data
[
"message"
]
osd
=
message
.
split
(
" "
,
1
)[
0
]
print
(
f
"Reweighting osd {osd}"
)
weight_json
=
subprocess
.
check_output
([
"ceph"
,
"osd"
,
"df"
,
"-f=json"
,
osd
])
weight_data
=
json
.
loads
(
weight_json
)
cur_weight
=
weight_data
[
"nodes"
][
0
][
"reweight"
]
print
(
f
" cur_weight={cur_weight}"
)
new_weight
=
cur_weight
-
0.05
print
(
f
" new_weight={new_weight}"
)
subprocess
.
check_call
([
"ceph"
,
"osd"
,
"reweight"
,
osd
,
str
(
new_weight
)])
Event Timeline
ProdPasteBot
edited the content of this paste.
(Show Details)
Sep 11 2024, 7:53 AM
2024-09-11 07:53:36 (UTC+0)
ProdPasteBot
changed the title of this paste from untitled to
ceph_reweight_dc.py
.
dcaro
mentioned this in
T374043: Drain C8 rack
.
Sep 11 2024, 8:43 AM
2024-09-11 08:43:45 (UTC+0)
Log In to Comment