New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mgr/iostat: implement 'ceph iostat' as a mgr plugin #20100
Changes from all commits
40983f7
78e884d
474c94b
22047b3
2abfb52
3f3a183
be3c7f6
fb63838
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,8 +23,9 @@ | |
import uuid | ||
|
||
|
||
# Flags are from MonCommand.h | ||
FLAG_MGR = 8 # command is intended for mgr | ||
|
||
FLAG_POLL = 16 # command is intended to be ran continuously by the client | ||
|
||
try: | ||
basestring | ||
|
@@ -999,6 +1000,9 @@ def validate(args, signature, flags=0, partial=False): | |
if flags & FLAG_MGR: | ||
d['target'] = ('mgr','') | ||
|
||
if flags & FLAG_POLL: | ||
d['poll'] = True | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @tchaikov The problem was that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ahh, thanks for the explanation! actually, i was debugging this yesterday. |
||
|
||
# Finally, success | ||
return d | ||
|
||
|
@@ -1239,7 +1243,7 @@ def send_command(cluster, target=('mon', ''), cmd=None, inbuf=b'', timeout=0, | |
verbose=False): | ||
""" | ||
Send a command to a daemon using librados's | ||
mon_command, osd_command, or pg_command. Any bulk input data | ||
mon_command, osd_command, mgr_command, or pg_command. Any bulk input data | ||
comes in inbuf. | ||
|
||
Returns (ret, outbuf, outs); ret is the return code, outbuf is | ||
|
@@ -1351,7 +1355,6 @@ def json_command(cluster, target=('mon', ''), prefix=None, argdict=None, | |
except: | ||
# use the target we were originally given | ||
pass | ||
|
||
ret, outbuf, outs = send_command_retry(cluster, | ||
target, [json.dumps(cmddict)], | ||
inbuf, timeout, verbose) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .module import Module |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
|
||
from mgr_module import MgrModule | ||
|
||
|
||
class Module(MgrModule): | ||
COMMANDS = [ | ||
{ | ||
"cmd": "iostat", | ||
"desc": "Get IO rates", | ||
"perm": "r", | ||
"poll": "true" | ||
}, | ||
{ | ||
"cmd": "iostat self-test", | ||
"desc": "Run a self test the iostat module", | ||
"perm": "r" | ||
} | ||
] | ||
|
||
|
||
def __init__(self, *args, **kwargs): | ||
super(Module, self).__init__(*args, **kwargs) | ||
|
||
|
||
def handle_command(self, command): | ||
rd = 0 | ||
wr = 0 | ||
ops = 0 | ||
ret = '' | ||
|
||
if command['prefix'] == 'iostat': | ||
r = self.get('io_rate') | ||
|
||
stamp_delta = float(r['pg_stats_delta']['stamp_delta']) | ||
if (stamp_delta > 0): | ||
rd = int(r['pg_stats_delta']['stat_sum']['num_read_kb']) / stamp_delta | ||
wr = int(r['pg_stats_delta']['stat_sum']['num_write_kb']) / stamp_delta | ||
ops = ( int(r['pg_stats_delta']['stat_sum']['num_write']) + int(r['pg_stats_delta']['stat_sum']['num_read']) ) / stamp_delta | ||
|
||
ret = "wr: {0} kB/s, rd: {1} kB/s, iops: {2}".format(int(wr), int(rd), int(ops)) | ||
|
||
elif command['prefix'] == 'iostat self-test': | ||
r = self.get('io_rate') | ||
assert('pg_stats_delta' in r) | ||
assert('stamp_delta' in r['pg_stats_delta']) | ||
assert('stat_sum' in r['pg_stats_delta']) | ||
assert('num_read_kb' in r['pg_stats_delta']['stat_sum']) | ||
assert('num_write_kb' in r['pg_stats_delta']['stat_sum']) | ||
assert('num_write' in r['pg_stats_delta']['stat_sum']) | ||
assert('num_read' in r['pg_stats_delta']['stat_sum']) | ||
ret = 'iostat self-test OK' | ||
|
||
return 0, '', ret |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could just use
boost::iequals(polling, "true")