mirror of
https://github.com/scylladb/scylladb.git
synced 2026-04-21 17:10:35 +00:00
The scollectd is an infrastructure that allows different part of the code to register internal counters and the infrastructure would send it periodically to an external server. This patch adds and API to the scollectd that allows to inquire a register value and the names of the registered values. The collectd_value structure is used to return a single value that can be of type: double or signed and unsigned 64 bit long. The definition of the API are found in scollectd_api.hh The inquiries are for the local cpu, it is up to the caller to call a relevent cpu. Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
59 lines
1.2 KiB
C++
59 lines
1.2 KiB
C++
/*
|
|
* Copyright 2015 Cloudius Systems
|
|
*/
|
|
|
|
#ifndef CORE_SCOLLECTD_API_HH_
|
|
#define CORE_SCOLLECTD_API_HH_
|
|
|
|
#include "core/scollectd.hh"
|
|
|
|
namespace scollectd {
|
|
|
|
struct collectd_value {
|
|
union {
|
|
double _d;
|
|
uint64_t _ui;
|
|
int64_t _i;
|
|
} u;
|
|
scollectd::data_type _type;
|
|
collectd_value()
|
|
: _type(data_type::GAUGE) {
|
|
}
|
|
collectd_value(data_type t, uint64_t i)
|
|
: _type(t) {
|
|
u._ui = i;
|
|
}
|
|
|
|
collectd_value& operator=(const collectd_value& c) = default;
|
|
|
|
collectd_value& operator+=(const collectd_value& c) {
|
|
*this = *this + c;
|
|
return *this;
|
|
}
|
|
|
|
collectd_value operator+(const collectd_value& c) {
|
|
collectd_value res(*this);
|
|
switch (_type) {
|
|
case data_type::GAUGE:
|
|
res.u._d += c.u._d;
|
|
break;
|
|
case data_type::DERIVE:
|
|
res.u._i += c.u._i;
|
|
break;
|
|
default:
|
|
res.u._ui += c.u._ui;
|
|
break;
|
|
}
|
|
return res;
|
|
}
|
|
};
|
|
|
|
std::vector<collectd_value> get_collectd_value(
|
|
shared_ptr<scollectd::type_instance_id> id);
|
|
|
|
std::vector<scollectd::type_instance_id> get_collectd_ids();
|
|
|
|
}
|
|
|
|
#endif /* CORE_SCOLLECTD_API_HH_ */
|