}
}
+PyObject *ActivePyModules::get_osd_perf_counters(OSDPerfMetricQueryID query_id)
+{
+ std::map<OSDPerfMetricKey, PerformanceCounters> counters;
+
+ int r = server.get_osd_perf_counters(query_id, &counters);
+ if (r < 0) {
+ dout(0) << "get_osd_perf_counters for query_id=" << query_id << " failed: "
+ << cpp_strerror(r) << dendl;
+ Py_RETURN_NONE;
+ }
+
+ PyFormatter f;
+
+ f.open_array_section("counters");
+ for (auto &it : counters) {
+ auto &key = it.first;
+ auto &instance_counters = it.second;
+ f.open_object_section("i");
+ f.open_array_section("k");
+ for (auto &sub_key : key) {
+ f.open_array_section("s");
+ for (size_t i = 0; i < sub_key.size(); i++) {
+ f.dump_string(stringify(i).c_str(), sub_key[i]);
+ }
+ f.close_section(); // s
+ }
+ f.close_section(); // k
+ f.open_array_section("c");
+ for (auto &c : instance_counters) {
+ f.open_array_section("p");
+ f.dump_unsigned("0", c.first);
+ f.dump_unsigned("1", c.second);
+ f.close_section(); // p
+ }
+ f.close_section(); // c
+ f.close_section(); // i
+ }
+ f.close_section(); // counters
+
+ return f.get();
+}
+
void ActivePyModules::cluster_log(const std::string &channel, clog_type prio,
const std::string &message)
{
OSDPerfMetricQueryID add_osd_perf_query(const OSDPerfMetricQuery &query);
void remove_osd_perf_query(OSDPerfMetricQueryID query_id);
+ PyObject *get_osd_perf_counters(OSDPerfMetricQueryID query_id);
bool get_store(const std::string &module_name,
const std::string &key, std::string *val) const;
Py_RETURN_NONE;
}
+static PyObject*
+ceph_get_osd_perf_counters(BaseMgrModule *self, PyObject *args)
+{
+ OSDPerfMetricQueryID query_id;
+ if (!PyArg_ParseTuple(args, "i:ceph_get_osd_perf_counters", &query_id)) {
+ derr << "Invalid args!" << dendl;
+ return nullptr;
+ }
+
+ return self->py_modules->get_osd_perf_counters(query_id);
+}
+
PyMethodDef BaseMgrModule_methods[] = {
{"_ceph_get", (PyCFunction)ceph_state_get, METH_VARARGS,
"Get a cluster object"},
{"_ceph_remove_osd_perf_query", (PyCFunction)ceph_remove_osd_perf_query,
METH_VARARGS, "Remove an osd perf query"},
+ {"_ceph_get_osd_perf_counters", (PyCFunction)ceph_get_osd_perf_counters,
+ METH_VARARGS, "Get osd perf counters"},
+
{NULL, NULL, 0, NULL}
};
{
return osd_perf_metric_collector.remove_query(query_id);
}
+
+int DaemonServer::get_osd_perf_counters(
+ OSDPerfMetricQueryID query_id,
+ std::map<OSDPerfMetricKey, PerformanceCounters> *counters)
+{
+ return osd_perf_metric_collector.get_counters(query_id, counters);
+}
OSDPerfMetricQueryID add_osd_perf_query(const OSDPerfMetricQuery &query);
int remove_osd_perf_query(OSDPerfMetricQueryID query_id);
+ int get_osd_perf_counters(OSDPerfMetricQueryID query_id,
+ std::map<OSDPerfMetricKey, PerformanceCounters> *c);
virtual const char** get_tracked_conf_keys() const override;
virtual void handle_conf_change(const ConfigProxy& conf,