]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
exporter daemon
authorPere Diaz Bou <pdiazbou@redhat.com>
Tue, 22 Feb 2022 14:00:51 +0000 (15:00 +0100)
committerAvan Thakkar <athakkar@redhat.com>
Mon, 20 Jun 2022 18:20:46 +0000 (23:50 +0530)
Signed-off-by: Pere Diaz Bou <pdiazbou@redhat.com>
13 files changed:
src/CMakeLists.txt
src/ceph_exporter.cc [new file with mode: 0644]
src/common/entity_name.cc
src/common/entity_name.h
src/include/msgr.h
src/mgr/ActivePyModules.cc
src/mgr/CMakeLists.txt
src/mgr/DaemonMetricCollector.cc [new file with mode: 0644]
src/mgr/DaemonMetricCollector.h [new file with mode: 0644]
src/msg/msg_types.cc
src/msg/msg_types.h
src/pybind/mgr/CMakeLists.txt
src/vstart.sh

index 89c53ea46eb93db4b0a8dfb34c7e7e6fa41c4546..2f608722099ba7ec8534be8424496261c05702e9 100644 (file)
@@ -894,6 +894,7 @@ add_custom_target(vstart-base DEPENDS
     ceph-mon
     ceph-authtool
     ceph-conf
+    ceph-exporter
     monmaptool
     crushtool
     rados)
diff --git a/src/ceph_exporter.cc b/src/ceph_exporter.cc
new file mode 100644 (file)
index 0000000..d19c2ae
--- /dev/null
@@ -0,0 +1,19 @@
+#include "mgr/DaemonMetricCollector.h"
+#include <iostream>
+#include "global/global_init.h"
+#include "common/ceph_argparse.h"
+#include <map>
+
+
+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);
+  DaemonMetricCollector collector;
+  collector.main();
+}
index 5357b34eacb7f3f5f190c7183130c56568f1a54e..fad4f0f3b4de93c08c429dad2399126a027cbe0e 100644 (file)
 using std::string;
 
 
-const std::array<EntityName::str_to_entity_type_t, 6> EntityName::STR_TO_ENTITY_TYPE = {{
+const std::array<EntityName::str_to_entity_type_t, 7> EntityName::STR_TO_ENTITY_TYPE = {{
   { CEPH_ENTITY_TYPE_AUTH, "auth" },
   { CEPH_ENTITY_TYPE_MON, "mon" },
   { CEPH_ENTITY_TYPE_OSD, "osd" },
   { CEPH_ENTITY_TYPE_MDS, "mds" },
   { CEPH_ENTITY_TYPE_MGR, "mgr" },
+  { CEPH_ENTITY_TYPE_EXPORTER, "exporter" },
   { CEPH_ENTITY_TYPE_CLIENT, "client" },
 }};
 
index 5e5ab111404a68f9a72c91b3794990aeb7f89b54..a9cc533886ba8206c6c7f8f9c2be30f87fdfc368 100644 (file)
@@ -60,6 +60,7 @@ struct EntityName
   bool is_mds() const { return get_type() == CEPH_ENTITY_TYPE_MDS; }
   bool is_client() const { return get_type() == CEPH_ENTITY_TYPE_CLIENT; }
   bool is_mon() const { return get_type() == CEPH_ENTITY_TYPE_MON; }
+  bool is_exporter() const { return get_type() == CEPH_ENTITY_TYPE_EXPORTER; }
 
   std::string_view get_type_name() const;
   const std::string &get_id() const;
@@ -78,7 +79,7 @@ private:
     uint32_t type;
     const char *str;
   };
-  static const std::array<str_to_entity_type_t, 6> STR_TO_ENTITY_TYPE;
+  static const std::array<str_to_entity_type_t, 7> STR_TO_ENTITY_TYPE;
 
   uint32_t type = 0;
   std::string id;
index c8ad48ad1afef1306a33662b92daa0e0245b3a0b..3c5f7aa8f53705f6a2048aff8e1c361f02c3277f 100644 (file)
@@ -92,6 +92,7 @@ struct ceph_entity_name {
 #define CEPH_ENTITY_TYPE_CLIENT 0x08
 #define CEPH_ENTITY_TYPE_MGR    0x10
 #define CEPH_ENTITY_TYPE_AUTH   0x20
+#define CEPH_ENTITY_TYPE_EXPORTER    0x30
 
 #define CEPH_ENTITY_TYPE_ANY    0xFF
 
index 58c3d9ee4d6f4d9fc062150f645fa518313e9048..9ac03739595f6032d807fd037df097191a8dbf23 100644 (file)
@@ -233,7 +233,6 @@ PyObject *ActivePyModules::get_python(const std::string &what)
   } 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") {
index f9ec04317f4be64fde5fe59af382a5b70d66bb9b..4f1003a6149a87462ea424a3cfbaaed6b95d8e22 100644 (file)
@@ -33,7 +33,14 @@ if(WITH_MGR)
     StandbyPyModules.cc
     mgr_commands.cc
     $<TARGET_OBJECTS:mgr_cap_obj>)
+  set(exporter_srcs
+    ${CMAKE_SOURCE_DIR}/src/ceph_exporter.cc
+    DaemonMetricCollector.cc
+    )
   add_executable(ceph-mgr ${mgr_srcs})
+  add_executable(ceph-exporter ${exporter_srcs})
+  target_link_libraries(ceph-exporter
+    global-static ceph-common)
   target_compile_definitions(ceph-mgr PRIVATE PY_SSIZE_T_CLEAN)
   if(WITH_LIBCEPHSQLITE)
     target_link_libraries(ceph-mgr cephsqlite SQLite3::SQLite3)
diff --git a/src/mgr/DaemonMetricCollector.cc b/src/mgr/DaemonMetricCollector.cc
new file mode 100644 (file)
index 0000000..8adcc39
--- /dev/null
@@ -0,0 +1,7 @@
+#include "DaemonMetricCollector.h"
+#include <iostream>
+
+
+void DaemonMetricCollector::main() {
+  std::cout << "metric" << std::endl;
+}
diff --git a/src/mgr/DaemonMetricCollector.h b/src/mgr/DaemonMetricCollector.h
new file mode 100644 (file)
index 0000000..93443f1
--- /dev/null
@@ -0,0 +1,7 @@
+#pragma once
+
+class DaemonMetricCollector {
+ public:
+  int i;
+  void main();
+};
index 1a78cb32680986285d882b15d3d92742eab622e7..e0e84c586e2fb8d52d5191af3222ca8bd04ebbf2 100644 (file)
@@ -28,6 +28,9 @@ bool entity_name_t::parse(std::string_view s)
   } else if (s.find("mgr.") == 0) {
     _type = TYPE_MGR;
     start += 4;
+  } else if (s.find("exporter.") == 0) {
+    _type = TYPE_EXPORTER;
+    start += 8;
   } else {
     return false;
   }
index a33545d916f3d51ed13592082bc72bea8b897d32..d247a2bb06cf27af172177bb7200b08579f8fd93 100644 (file)
@@ -51,6 +51,7 @@ public:
   static const int TYPE_OSD = CEPH_ENTITY_TYPE_OSD;
   static const int TYPE_CLIENT = CEPH_ENTITY_TYPE_CLIENT;
   static const int TYPE_MGR = CEPH_ENTITY_TYPE_MGR;
+  static const int TYPE_EXPORTER = CEPH_ENTITY_TYPE_EXPORTER;
 
   static const int64_t NEW = -1;
 
@@ -66,6 +67,7 @@ public:
   static entity_name_t OSD(int64_t i=NEW) { return entity_name_t(TYPE_OSD, i); }
   static entity_name_t CLIENT(int64_t i=NEW) { return entity_name_t(TYPE_CLIENT, i); }
   static entity_name_t MGR(int64_t i=NEW) { return entity_name_t(TYPE_MGR, i); }
+  static entity_name_t EXPORTER(int64_t i=NEW) { return entity_name_t(TYPE_EXPORTER, i); }
 
   int64_t num() const { return _num; }
   int type() const { return _type; }
@@ -80,6 +82,7 @@ public:
   bool is_osd() const { return type() == TYPE_OSD; }
   bool is_mon() const { return type() == TYPE_MON; }
   bool is_mgr() const { return type() == TYPE_MGR; }
+  bool is_exporter() const { return type() == TYPE_EXPORTER; }
 
   operator ceph_entity_name() const {
     ceph_entity_name n = { _type, ceph_le64(_num) };
index 54aa9142028927b5fd3d0ffa35a6133299f720e9..d25254048a5c5840fe1e1501b5cd86196fc90981 100644 (file)
@@ -8,9 +8,9 @@ set(mgr_module_install_excludes
 
 add_subdirectory(dashboard)
 
-if(WITH_MGR_ROOK_CLIENT)
-  add_subdirectory(rook)
-endif()
+if(WITH_MGR_ROOK_CLIENT)
+  add_subdirectory(rook)
+endif()
 if(WITH_TESTS)
   include(AddCephTest)
   add_tox_test(mgr ${CMAKE_CURRENT_SOURCE_DIR} TOX_ENVS py3 py37 mypy flake8 jinjalint nooptional)
index 5518e300624fe7e167c3c868187bc86bbd716d09..4a9d0005230e55f0010d21f82b83ef2ce764d3c2 100755 (executable)
@@ -788,7 +788,6 @@ $DAEMONOPTS
         mds root ino gid = `id -g`
         $(format_conf "${extra_conf}")
 [mgr]
-        mgr disabled modules = rook
         mgr data = $CEPH_DEV_DIR/mgr.\$id
         mgr module path = $MGR_PYTHON_PATH
         cephadm path = $CEPH_ROOT/src/cephadm/cephadm
@@ -823,6 +822,7 @@ $COSDSHORT
         $(format_conf "${extra_conf}")
 [mon]
         mon_data_avail_crit = 1
+        mgr disabled modules = rook
         mgr initial modules = $mgr_modules
 $DAEMONOPTS
 $CMONDEBUG