"""
from __future__ import print_function
+from time import sleep
import codecs
import os
import sys
print('error handling command target: {0}'.format(e), file=sys.stderr)
return 1
+ # ceph iostat
+ if len(childargs) > 0 and childargs[0] == 'iostat':
+ def call_iostat():
+ while 1:
+ subprocess.call([sys.argv[0], 'mgr', 'iostat'])
+ sleep(1)
+
+ run_in_thread(call_iostat)
+ return 1
+
# Repulsive hack to handle tell: lop off 'tell' and target
# and validate the rest of the command. 'target' is already
# determined in our callers, so it's ok to remove it here.
}
);
return f.get();
+ } else if (what == "io_rate") {
+ PyFormatter f;
+ cluster_state.with_pgmap(
+ [&f](const PGMap &pg_map) {
+ pg_map.dump_delta(&f);
+ }
+ );
+ return f.get();
} else if (what == "df") {
PyFormatter f;
{
f->open_object_section("pg_stats_delta");
pg_sum_delta.dump(f);
+ f->dump_stream("stamp_delta") << stamp_delta;
f->close_section();
}
--- /dev/null
+from .module import Module
--- /dev/null
+
+from mgr_module import MgrModule
+
+
+class Module(MgrModule):
+ COMMANDS = [
+ {
+ "cmd": "mgr iostat",
+ "desc": "Get IO rates",
+ "perm": "r"
+ }
+ ]
+
+
+ def __init__(self, *args, **kwargs):
+ super(Module, self).__init__(*args, **kwargs)
+
+
+ def handle_command(self, command):
+ rd = 0
+ wr = 0
+ ops = 0
+
+ if command['prefix'] == 'mgr 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(str(int(wr)), str(int(rd)), str(int(ops)))
+
+ return 0, '', ret
:param str data_name: Valid things to fetch are osd_crush_map_text,
osd_map, osd_map_tree, osd_map_crush, config, mon_map, fs_map,
- osd_metadata, pg_summary, df, osd_stats, health, mon_status.
+ osd_metadata, pg_summary, io_rate, pg_dump, df, osd_stats, health, mon_status.
Note:
All these structures have their own JSON representations: experiment