From 83a9319129d4373ae6c0242672346d9a6039c813 Mon Sep 17 00:00:00 2001 From: Tadas Date: Fri, 10 Jan 2020 09:53:31 +0200 Subject: [PATCH] Enable ceph-mgr socket metrics --- collector.go | 6 ++++++ collector_test.go | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/collector.go b/collector.go index 3e2ffeb..d80cffd 100644 --- a/collector.go +++ b/collector.go @@ -77,6 +77,12 @@ func GetDeviceType(socketName string) map[string]string { device["type"] = "ceph_radosgw" device["name"] = strings.ReplaceAll(re.FindString(socketName), ".", "") } + if strings.Contains(socketName, "mgr.") { + log.Debug("Device is a mgr") + var re = regexp.MustCompile(`mgr(.[0-9]*)`) + device["type"] = "ceph_mgr" + device["name"] = strings.ReplaceAll(re.FindString(socketName), ".", "") + } log.Debug("Device:", device) return device } diff --git a/collector_test.go b/collector_test.go index cf8b65b..3cd069e 100644 --- a/collector_test.go +++ b/collector_test.go @@ -45,6 +45,10 @@ func TestGetDeviceType(t *testing.T) { if value["type"] != "ceph_radosgw" || value["name"] != "radosgw" { t.Errorf("GetDeviceType failed. Got: type: %s, name: %s", value["type"], value["name"]) } + value = GetDeviceType("/var/run/ceph/ceph-cluster-client.radosgw.test-ceph-mgr.asok") + if value["type"] != "ceph_mgr" || value["name"] != "mgr" { + t.Errorf("GetDeviceType failed. Got: type: %s, name: %s", value["type"], value["name"]) + } } func TestLoadJson(t *testing.T) {