]>
git.proxmox.com Git - ceph.git/blob - ceph/src/messages/MMgrReport.h
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
;
39 void encode(bufferlist
&bl
) const
41 // TODO: decide whether to drop the per-type
42 // encoding here, we could rely on the MgrReport
43 // verisoning instead.
44 ENCODE_START(3, 1, bl
);
46 ::encode(description
, bl
);
48 static_assert(sizeof(type
) == 1, "perfcounter_type_d must be one byte");
49 ::encode((uint8_t)type
, bl
);
50 ::encode(priority
, bl
);
51 ::encode((uint8_t)unit
, bl
);
55 void decode(bufferlist::iterator
&p
)
59 ::decode(description
, p
);
61 ::decode((uint8_t&)type
, p
);
63 ::decode(priority
, p
);
66 ::decode((uint8_t&)unit
, p
);
71 WRITE_CLASS_ENCODER(PerfCounterType
)
73 class MMgrReport
: public Message
75 static const int HEAD_VERSION
= 5;
76 static const int COMPAT_VERSION
= 1;
80 * Client is responsible for remembering whether it has introduced
81 * each perf counter to the server. When first sending a particular
82 * counter, it must inline the counter's schema here.
84 std::vector
<PerfCounterType
> declare_types
;
85 std::vector
<std::string
> undeclare_types
;
87 // For all counters present, sorted by idx, output
88 // as many bytes as are needed to represent them
90 // Decode: iterate over the types we know about, sorted by idx,
91 // and use the current type's type to decide how to decode
92 // the next bytes from the bufferlist.
95 std::string daemon_name
;
96 std::string service_name
; // optional; otherwise infer from entity type
98 // for service registration
99 boost::optional
<std::map
<std::string
,std::string
>> daemon_status
;
101 std::vector
<OSDHealthMetric
> osd_health_metrics
;
103 void decode_payload() override
105 bufferlist::iterator p
= payload
.begin();
106 ::decode(daemon_name
, p
);
107 ::decode(declare_types
, p
);
109 if (header
.version
>= 2)
110 ::decode(undeclare_types
, p
);
111 if (header
.version
>= 3) {
112 ::decode(service_name
, p
);
113 ::decode(daemon_status
, p
);
115 if (header
.version
>= 5) {
116 ::decode(osd_health_metrics
, p
);
120 void encode_payload(uint64_t features
) override
{
121 ::encode(daemon_name
, payload
);
122 ::encode(declare_types
, payload
);
123 ::encode(packed
, payload
);
124 ::encode(undeclare_types
, payload
);
125 ::encode(service_name
, payload
);
126 ::encode(daemon_status
, payload
);
127 ::encode(osd_health_metrics
, payload
);
130 const char *get_type_name() const override
{ return "mgrreport"; }
131 void print(ostream
& out
) const override
{
132 out
<< get_type_name() << "(";
133 if (service_name
.length()) {
136 out
<< ceph_entity_type_name(get_source().type());
138 out
<< "." << daemon_name
139 << " +" << declare_types
.size()
140 << "-" << undeclare_types
.size()
141 << " packed " << packed
.length();
143 out
<< " status=" << daemon_status
->size();
145 if (!osd_health_metrics
.empty()) {
146 out
<< " osd_metrics=" << osd_health_metrics
.size();
152 : Message(MSG_MGR_REPORT
, HEAD_VERSION
, COMPAT_VERSION
)