}
}
-void OpHistory::dump_ops(utime_t now, Formatter *f)
+void OpHistory::dump_ops(utime_t now, Formatter *f, set<string> filters)
{
Mutex::Locker history_lock(ops_history_lock);
cleanup(now);
arrived.begin();
i != arrived.end();
++i) {
+ if (!i->second->filter_out(filters))
+ continue;
f->open_object_section("op");
i->second->dump(now, f);
f->close_section();
f->close_section();
}
-void OpHistory::dump_ops_by_duration(utime_t now, Formatter *f)
+void OpHistory::dump_ops_by_duration(utime_t now, Formatter *f, set<string> filters)
{
Mutex::Locker history_lock(ops_history_lock);
cleanup(now);
arrived.begin();
i != arrived.end();
++i) {
+ if (!i->second->filter_out(filters))
+ continue;
durationvec.push_back(pair<double, TrackedOpRef>(i->second->get_duration(), i->second));
}
}
}
-bool OpTracker::dump_historic_ops(Formatter *f, bool by_duration)
+bool OpTracker::dump_historic_ops(Formatter *f, bool by_duration, set<string> filters)
{
RWLock::RLocker l(lock);
if (!tracking_enabled)
utime_t now = ceph_clock_now();
if (by_duration) {
- history.dump_ops_by_duration(now, f);
+ history.dump_ops_by_duration(now, f, filters);
} else {
- history.dump_ops(now, f);
+ history.dump_ops(now, f, filters);
}
return true;
}
-void OpHistory::dump_slow_ops(utime_t now, Formatter *f)
+void OpHistory::dump_slow_ops(utime_t now, Formatter *f, set<string> filters)
{
Mutex::Locker history_lock(ops_history_lock);
cleanup(now);
slow_op.begin();
i != slow_op.end();
++i) {
+ if (!i->second->filter_out(filters))
+ continue;
f->open_object_section("Op");
i->second->dump(now, f);
f->close_section();
f->close_section();
}
-bool OpTracker::dump_historic_slow_ops(Formatter *f)
+bool OpTracker::dump_historic_slow_ops(Formatter *f, set<string> filters)
{
RWLock::RLocker l(lock);
if (!tracking_enabled)
return false;
utime_t now = ceph_clock_now();
- history.dump_slow_ops(now, f);
+ history.dump_slow_ops(now, f, filters);
return true;
}
-bool OpTracker::dump_ops_in_flight(Formatter *f, bool print_only_blocked)
+bool OpTracker::dump_ops_in_flight(Formatter *f, bool print_only_blocked, set<string> filters)
{
RWLock::RLocker l(lock);
if (!tracking_enabled)
for (auto& op : sdata->ops_in_flight_sharded) {
if (print_only_blocked && (now - op.get_initiated() <= complaint_time))
break;
+ if (!op.filter_out(filters))
+ continue;
f->open_object_section("op");
op.dump(now, f);
f->close_section(); // this TrackedOp
assert(slow_op.empty());
}
void insert(utime_t now, TrackedOpRef op);
- void dump_ops(utime_t now, Formatter *f);
- void dump_ops_by_duration(utime_t now, Formatter *f);
- void dump_slow_ops(utime_t now, Formatter *f);
+ void dump_ops(utime_t now, Formatter *f, set<string> filters = {""});
+ void dump_ops_by_duration(utime_t now, Formatter *f, set<string> filters = {""});
+ void dump_slow_ops(utime_t now, Formatter *f, set<string> filters = {""});
void on_shutdown();
void set_size_and_duration(uint32_t new_size, uint32_t new_duration) {
history_size = new_size;
RWLock::WLocker l(lock);
tracking_enabled = enable;
}
- bool dump_ops_in_flight(Formatter *f, bool print_only_blocked=false);
- bool dump_historic_ops(Formatter *f, bool by_duration = false);
- bool dump_historic_slow_ops(Formatter *f);
+ bool dump_ops_in_flight(Formatter *f, bool print_only_blocked = false, set<string> filters = {""});
+ bool dump_historic_ops(Formatter *f, bool by_duration = false, set<string> filters = {""});
+ bool dump_historic_slow_ops(Formatter *f, set<string> filters = {""});
bool register_inflight_op(TrackedOp *i);
void unregister_inflight_op(TrackedOp *i);
/// called when the last non-OpTracker reference is dropped
virtual void _unregistered() {};
+ virtual bool filter_out(const set<string>& filters) { return true; }
+
public:
ZTracer::Trace osd_trace;
ZTracer::Trace pg_trace;
} else if (admin_command == "flush_journal") {
store->flush_journal();
} else if (admin_command == "dump_ops_in_flight" ||
- admin_command == "ops") {
- if (!op_tracker.dump_ops_in_flight(f)) {
- ss << "op_tracker tracking is not enabled now, so no ops are tracked currently, even those get stuck. \
- Please enable \"osd_enable_op_tracker\", and the tracker will start to track new ops received afterwards.";
- }
- } else if (admin_command == "dump_blocked_ops") {
- if (!op_tracker.dump_ops_in_flight(f, true)) {
- ss << "op_tracker tracking is not enabled now, so no ops are tracked currently, even those get stuck. \
- Please enable \"osd_enable_op_tracker\", and the tracker will start to track new ops received afterwards.";
- }
- } else if (admin_command == "dump_historic_ops") {
- if (!op_tracker.dump_historic_ops(f, false)) {
- ss << "op_tracker tracking is not enabled now, so no ops are tracked currently, even those get stuck. \
- Please enable \"osd_enable_op_tracker\", and the tracker will start to track new ops received afterwards.";
- }
- } else if (admin_command == "dump_historic_ops_by_duration") {
- if (!op_tracker.dump_historic_ops(f, true)) {
- ss << "op_tracker tracking is not enabled now, so no ops are tracked currently, even those get stuck. \
- Please enable \"osd_enable_op_tracker\", and the tracker will start to track new ops received afterwards.";
- }
- } else if (admin_command == "dump_historic_slow_ops") {
- if (!op_tracker.dump_historic_slow_ops(f)) {
- ss << "op_tracker tracking is not enabled now, so no ops are tracked currently, even those get stuck. \
- Please enable \"osd_enable_op_tracker\", and the tracker will start to track new ops received afterwards.";
+ admin_command == "ops" ||
+ admin_command == "dump_blocked_ops" ||
+ admin_command == "dump_historic_ops" ||
+ admin_command == "dump_historic_ops_by_duration" ||
+ admin_command == "dump_historic_slow_ops") {
+
+ const string error_str = "op_tracker tracking is not enabled now, so no ops are tracked currently, \
+even those get stuck. Please enable \"osd_enable_op_tracker\", and the tracker \
+will start to track new ops received afterwards.";
+
+ set<string> filters;
+ vector<string> filter_str;
+ if (cmd_getval(cct, cmdmap, "filterstr", filter_str)) {
+ copy(filter_str.begin(), filter_str.end(),
+ inserter(filters, filters.end()));
+ }
+
+ if (admin_command == "dump_ops_in_flight" ||
+ admin_command == "ops") {
+ if (!op_tracker.dump_ops_in_flight(f, false, filters)) {
+ ss << error_str;
+ }
+ }
+ if (admin_command == "dump_blocked_ops") {
+ if (!op_tracker.dump_ops_in_flight(f, true, filters)) {
+ ss << error_str;
+ }
+ }
+ if (admin_command == "dump_historic_ops") {
+ if (!op_tracker.dump_historic_ops(f, false, filters)) {
+ ss << error_str;
+ }
+ }
+ if (admin_command == "dump_historic_ops_by_duration") {
+ if (!op_tracker.dump_historic_ops(f, true, filters)) {
+ ss << error_str;
+ }
+ }
+ if (admin_command == "dump_historic_slow_ops") {
+ if (!op_tracker.dump_historic_slow_ops(f, filters)) {
+ ss << error_str;
+ }
}
} else if (admin_command == "dump_op_pq_state") {
f->open_object_section("pq");
"flush the journal to permanent store");
assert(r == 0);
r = admin_socket->register_command("dump_ops_in_flight",
- "dump_ops_in_flight", asok_hook,
+ "dump_ops_in_flight " \
+ "name=filterstr,type=CephString,n=N,req=false",
+ asok_hook,
"show the ops currently in flight");
assert(r == 0);
r = admin_socket->register_command("ops",
- "ops", asok_hook,
+ "ops " \
+ "name=filterstr,type=CephString,n=N,req=false",
+ asok_hook,
"show the ops currently in flight");
assert(r == 0);
r = admin_socket->register_command("dump_blocked_ops",
- "dump_blocked_ops", asok_hook,
+ "dump_blocked_ops " \
+ "name=filterstr,type=CephString,n=N,req=false",
+ asok_hook,
"show the blocked ops currently in flight");
assert(r == 0);
- r = admin_socket->register_command("dump_historic_ops", "dump_historic_ops",
+ r = admin_socket->register_command("dump_historic_ops",
+ "dump_historic_ops " \
+ "name=filterstr,type=CephString,n=N,req=false",
asok_hook,
"show recent ops");
assert(r == 0);
- r = admin_socket->register_command("dump_historic_slow_ops", "dump_historic_slow_ops",
+ r = admin_socket->register_command("dump_historic_slow_ops",
+ "dump_historic_slow_ops " \
+ "name=filterstr,type=CephString,n=N,req=false",
asok_hook,
"show slowest recent ops");
assert(r == 0);
- r = admin_socket->register_command("dump_historic_ops_by_duration", "dump_historic_ops_by_duration",
+ r = admin_socket->register_command("dump_historic_ops_by_duration",
+ "dump_historic_ops_by_duration " \
+ "name=filterstr,type=CephString,n=N,req=false",
asok_hook,
"show slowest recent ops, sorted by duration");
assert(r == 0);