int main(int argc, char** argv) {
// TODO: daemonize
std::cout << "inside exporter" << std::endl;
- std::map<std::string,std::string> defaults = {
- { "keyring", "$mgr_data/keyring" }
- };
- auto args = argv_to_vec(argc, argv);
- auto cct = global_init(&defaults, args, CEPH_ENTITY_TYPE_EXPORTER,
- CODE_ENVIRONMENT_DAEMON, 0);
+ // std::map<std::string,std::string> defaults = {
+ // { "keyring", "$mgr_data/keyring" }
+ // };
+ // auto args = argv_to_vec(argc, argv);
+ // auto cct = global_init(&defaults, args, CEPH_ENTITY_TYPE_EXPORTER,
+ // CODE_ENVIRONMENT_DAEMON, 0);
DaemonMetricCollector collector;
collector.main();
}
} else if (what.substr(0, 7) == "osd_map") {
without_gil_t no_gil;
cluster_state.with_osdmap([&](const OSDMap &osd_map){
+ no_gil.acquire_gil();
if (what == "osd_map") {
osd_map.dump(&f);
} else if (what == "osd_map_tree") {
#include "DaemonMetricCollector.h"
+#include "common/admin_socket_client.h"
+
#include <iostream>
+#include <string>
+#include <filesystem>
+
+#include <iostream>
+#include <string>
+#include <filesystem>
void DaemonMetricCollector::main() {
std::cout << "metric" << std::endl;
+ while (1) {
+ update_sockets();
+ }
+}
+
+void update_sockets() {
+ for (const auto &entry : fs::recursive_directory_iterator(socketdir)) {
+ if (entry.path().extension() == ".asok") {
+ if (clients.find(entry.path()) == clients.end()) {
+ AdminSocketClient sock(entry.path());
+ clients[entry.path()] = sock;
+ }
+ }
+ }
+}
+
+void DaemonMetricCollector::send_request_per_client() {
+ AdminSocketClient mgr_sock_client("/var/run/ceph/whatever");
+ std::string request("{\"prefix\":\"perf dump\"}");
+ std::string path = "/run/"
+ for (const auto & entry : std::filesystem::directory_iterator(path)) {
+ if (clients.find(entry.path()) == clients.end()) {
+ AdminSocketClient sock(entry.path());
+ clients[entry.path()] = sock;
+ }
+ }
+}
+
+void DaemonMetricCollector::start_mgr_connection() {
+ AdminSocketClient mgr_sock_client("/var/run/ceph/whatever");
+ std::string request("{\"prefix\":\"help\"}");
+ std::string response;
+ mgr_sock_client.do_request(request, &response);
+ std::cout << response << std::endl;
}
#pragma once
+#include "common/admin_socket_client.h"
+#include <string>
+#include <map>
+#include <vector>
+
+#include <string>
+#include <map>
+#include <vector>
class DaemonMetricCollector {
public:
int i;
void main();
+
+private:
+ // TODO: add clients
+ // check removed sockets
+ // list dir of sockets
+ std::map<std::string, AdminSocketClient> clients;
+ void update_sockets();
+ void start_mgr_connection();
};