]>
git.proxmox.com Git - ceph.git/blob - ceph/src/messages/MMgrReport.h
f6af6dfb86aa06a0da4b0e1744fba0e1916ab6c1
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2016 John Spray <john.spray@redhat.com>
8 * This is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License version 2.1, as published by the Free Software
11 * Foundation. See file COPYING.
15 #ifndef CEPH_MMGRREPORT_H_
16 #define CEPH_MMGRREPORT_H_
18 #include <boost/optional.hpp>
20 #include "msg/Message.h"
22 #include "common/perf_counters.h"
23 #include "osd/OSDHealthMetric.h"
29 std::string description
;
31 enum perfcounter_type_d type
;
33 // For older clients that did not send priority, pretend everything
34 // is "useful" so that mgr plugins filtering on prio will get some
35 // data (albeit probably more than they wanted)
36 uint8_t priority
= PerfCountersBuilder::PRIO_USEFUL
;
38 void encode(bufferlist
&bl
) const
40 // TODO: decide whether to drop the per-type
41 // encoding here, we could rely on the MgrReport
42 // verisoning instead.
43 ENCODE_START(2, 1, bl
);
45 ::encode(description
, bl
);
47 static_assert(sizeof(type
) == 1, "perfcounter_type_d must be one byte");
48 ::encode((uint8_t)type
, bl
);
49 ::encode(priority
, bl
);
53 void decode(bufferlist::iterator
&p
)
57 ::decode(description
, p
);
59 ::decode((uint8_t&)type
, p
);
61 ::decode(priority
, p
);
66 WRITE_CLASS_ENCODER(PerfCounterType
)
68 class MMgrReport
: public Message
70 static const int HEAD_VERSION
= 5;
71 static const int COMPAT_VERSION
= 1;
75 * Client is responsible for remembering whether it has introduced
76 * each perf counter to the server. When first sending a particular
77 * counter, it must inline the counter's schema here.
79 std::vector
<PerfCounterType
> declare_types
;
80 std::vector
<std::string
> undeclare_types
;
82 // For all counters present, sorted by idx, output
83 // as many bytes as are needed to represent them
85 // Decode: iterate over the types we know about, sorted by idx,
86 // and use the current type's type to decide how to decode
87 // the next bytes from the bufferlist.
90 std::string daemon_name
;
91 std::string service_name
; // optional; otherwise infer from entity type
93 // for service registration
94 boost::optional
<std::map
<std::string
,std::string
>> daemon_status
;
96 std::vector
<OSDHealthMetric
> osd_health_metrics
;
98 void decode_payload() override
100 bufferlist::iterator p
= payload
.begin();
101 ::decode(daemon_name
, p
);
102 ::decode(declare_types
, p
);
104 if (header
.version
>= 2)
105 ::decode(undeclare_types
, p
);
106 if (header
.version
>= 3) {
107 ::decode(service_name
, p
);
108 ::decode(daemon_status
, p
);
110 if (header
.version
>= 5) {
111 ::decode(osd_health_metrics
, p
);
115 void encode_payload(uint64_t features
) override
{
116 ::encode(daemon_name
, payload
);
117 ::encode(declare_types
, payload
);
118 ::encode(packed
, payload
);
119 ::encode(undeclare_types
, payload
);
120 ::encode(service_name
, payload
);
121 ::encode(daemon_status
, payload
);
122 ::encode(osd_health_metrics
, payload
);
125 const char *get_type_name() const override
{ return "mgrreport"; }
126 void print(ostream
& out
) const override
{
127 out
<< get_type_name() << "(";
128 if (service_name
.length()) {
131 out
<< ceph_entity_type_name(get_source().type());
133 out
<< "." << daemon_name
134 << " +" << declare_types
.size()
135 << "-" << undeclare_types
.size()
136 << " packed " << packed
.length();
138 out
<< " status=" << daemon_status
->size();
140 if (!osd_health_metrics
.empty()) {
141 out
<< " osd_metrics=" << osd_health_metrics
.size();
147 : Message(MSG_MGR_REPORT
, HEAD_VERSION
, COMPAT_VERSION
)