]>
git.proxmox.com Git - ceph.git/blob - ceph/src/mgr/OSDHealthMetricCollector.cc
1 #include <boost/format.hpp>
3 #include "include/health.h"
4 #include "include/types.h"
5 #include "OSDHealthMetricCollector.h"
10 ostream
& operator<<(ostream
& os
,
11 const OSDHealthMetricCollector::DaemonKey
& daemon
) {
12 return os
<< daemon
.first
<< "." << daemon
.second
;
17 class PendingPGs final
: public OSDHealthMetricCollector
{
18 bool _is_relevant(osd_metric type
) const override
{
19 return type
== osd_metric::PENDING_CREATING_PGS
;
21 health_check_t
& _get_check(health_check_map_t
& cm
) const override
{
22 return cm
.get_or_add("PENDING_CREATING_PGS", HEALTH_WARN
, "");
24 bool _update(const DaemonKey
& osd
,
25 const OSDHealthMetric
& metric
) override
{
26 value
.n
+= metric
.get_n();
34 void _summarize(health_check_t
& check
) const override
{
38 static const char* fmt
= "%1% PGs pending on creation";
39 check
.summary
= boost::str(boost::format(fmt
) % value
.n
);
41 if (osds
.size() > 1) {
42 ss
<< "osds " << osds
<< " have pending PGs.";
44 ss
<< osds
.front() << " has pending PGs";
46 check
.detail
.push_back(ss
.str());
48 vector
<DaemonKey
> osds
;
51 } // anonymous namespace
53 unique_ptr
<OSDHealthMetricCollector
>
54 OSDHealthMetricCollector::create(osd_metric m
)
57 case osd_metric::PENDING_CREATING_PGS
:
58 return unique_ptr
<OSDHealthMetricCollector
>{new PendingPGs
};
60 return unique_ptr
<OSDHealthMetricCollector
>{};