forked from scylladb/seastar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
scollectd_api.hh
82 lines (66 loc) · 1.7 KB
/
scollectd_api.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*
* 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;
}
scollectd::data_type type() const {
return _type;
}
double d() const {
return u._d;
}
uint64_t ui() const {
return u._ui;
}
int64_t i() const {
return u._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(
const scollectd::type_instance_id& id);
std::vector<scollectd::type_instance_id> get_collectd_ids();
bool is_enabled(const scollectd::type_instance_id& id);
/**
* Enable or disable collectd metrics on local instance
* @id - the metric to enable or disable
* @enable - should the collectd metrics be enable or disable
*/
void enable(const scollectd::type_instance_id& id, bool enable);
}
#endif /* CORE_SCOLLECTD_API_HH_ */