From e3644704874f274fe4245ee44d5578bf5c4bb301 Mon Sep 17 00:00:00 2001 From: Avan Thakkar Date: Thu, 24 Mar 2022 14:21:56 +0530 Subject: [PATCH] exporter: add ceph-exporter package Signed-off-by: Avan Thakkar --- ceph.spec.in | 12 ++++++++++++ src/exporter/CMakeLists.txt | 1 + src/exporter/DaemonMetricCollector.cc | 18 ++++++++++-------- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/ceph.spec.in b/ceph.spec.in index 718731c88e9e8..35691c4460566 100644 --- a/ceph.spec.in +++ b/ceph.spec.in @@ -722,6 +722,15 @@ Requires: libcephfs2 = %{_epoch_prefix}%{version}-%{release} %description -n cephfs-mirror Daemon for mirroring CephFS snapshots between Ceph clusters. +%package -n ceph-exporter +Summary: Ceph daemon for collecting perf counters +%if 0%{?suse_version} +Group: System/Filesystems +%endif +Requires: ceph-base = %{_epoch_prefix}%{version}-%{release} +%description -n ceph-exporter +Daemon for collecting perf counters. + %package -n rbd-fuse Summary: Ceph fuse-based client %if 0%{?suse_version} @@ -1975,6 +1984,9 @@ if [ $1 -ge 1 ] ; then fi fi +%files -n ceph-exporter +%{_bindir}/ceph-exporter + %files -n rbd-fuse %{_bindir}/rbd-fuse %{_mandir}/man8/rbd-fuse.8* diff --git a/src/exporter/CMakeLists.txt b/src/exporter/CMakeLists.txt index ba062954888b7..01f3ab4d8743c 100644 --- a/src/exporter/CMakeLists.txt +++ b/src/exporter/CMakeLists.txt @@ -6,3 +6,4 @@ set(exporter_srcs add_executable(ceph-exporter ${exporter_srcs}) target_link_libraries(ceph-exporter global-static ceph-common) +install(TARGETS ceph-exporter DESTINATION bin) diff --git a/src/exporter/DaemonMetricCollector.cc b/src/exporter/DaemonMetricCollector.cc index c50b0ed51985b..fa88834198b93 100644 --- a/src/exporter/DaemonMetricCollector.cc +++ b/src/exporter/DaemonMetricCollector.cc @@ -137,15 +137,17 @@ void DaemonMetricCollector::send_requests() { } void DaemonMetricCollector::update_sockets() { - std::string path = "/tmp/ceph-asok.Qq4nS2"; + std::string path = "/var/run/ceph/"; for (const auto & entry : std::filesystem::directory_iterator(path)) { - std::string daemon_socket_name = entry.path().filename().string(); - std::cout << "Got socket: " << daemon_socket_name << std::endl; - // remove .asok - std::string daemon_name = daemon_socket_name.substr(0, daemon_socket_name.size() - 5); - if (clients.find(daemon_name) == clients.end()) { - AdminSocketClient sock(entry.path().string()); - clients.insert({daemon_name, std::move(sock)}); + if (entry.path().extension() == ".asok") { + std::string daemon_socket_name = entry.path().filename().string(); + std::cout << "Got socket: " << daemon_socket_name << std::endl; + // remove .asok + std::string daemon_name = daemon_socket_name.substr(0, daemon_socket_name.size() - 5); + if (clients.find(daemon_name) == clients.end()) { + AdminSocketClient sock(entry.path().string()); + clients.insert({daemon_name, std::move(sock)}); + } } } } -- 2.39.5