summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 647ac31)
raw | patch | inline | side by side (parent: 647ac31)
author | Aleksei Zakharov <zaharov@selectel.ru> | |
Thu, 5 Oct 2017 08:27:27 +0000 (11:27 +0300) | ||
committer | Aleksei Zakharov <zaharov@selectel.ru> | |
Thu, 5 Oct 2017 08:39:20 +0000 (11:39 +0300) |
src/ceph.c | patch | blob | history |
diff --git a/src/ceph.c b/src/ceph.c
index 59ddca210e9f804b5306df85b9bc3ebcb1fd6c5f..0776c622f0d6d3351b42bb7a14ed42aac09792e6 100644 (file)
--- a/src/ceph.c
+++ b/src/ceph.c
/** Number of elements in g_daemons */
static size_t g_num_daemons = 0;
+/** Next expected latency metric value */
+enum latency_loop_state {
+ CEPH_AVGCOUNT,
+ CEPH_SUM,
+ CEPH_AVGTIME,
+};
+
/**
* A set of data that we build up in memory while parsing the JSON.
*/
uint64_t avgcount;
/** current index of counters - used to get type of counter */
int index;
- /** do we already have an avgcount for latency pair */
- int avgcount_exists;
+ /** value we expect to get next when parsing latency metric */
+ enum latency_loop_state latency_next_metric;
/**
* similar to index, but current index of latency type counters -
* used to get last poll data of counter
switch (type) {
case DSET_LATENCY:
- if (vtmp->avgcount_exists == -1) {
+ if (vtmp->latency_next_metric == CEPH_AVGCOUNT) {
sscanf(val, "%" PRIu64, &vtmp->avgcount);
- vtmp->avgcount_exists = 0;
+ vtmp->latency_next_metric = CEPH_SUM;
// return after saving avgcount - don't dispatch value
// until latency calculation
return 0;
- } else if (vtmp->avgcount_exists == 0) {
+ } else if (vtmp->latency_next_metric == CEPH_SUM) {
if (vtmp->avgcount == 0) {
vtmp->avgcount = 1;
}
- vtmp->avgcount_exists = 1;
+ vtmp->latency_next_metric = CEPH_AVGTIME;
// user wants latency values as long run avg
// skip this step
if (long_run_latency_avg) {
}
uv.gauge = result;
vtmp->latency_index = (vtmp->latency_index + 1);
- } else if (vtmp->avgcount_exists == 1 ) {
- vtmp->avgcount_exists = -1;
+ } else if (vtmp->latency_next_metric == CEPH_AVGTIME) {
+ vtmp->latency_next_metric = CEPH_AVGCOUNT;
// skip this step if no need in long run latency
if (!long_run_latency_avg) {
return 0;
sizeof(vtmp->vlist.plugin_instance));
vtmp->d = io->d;
- vtmp->avgcount_exists = -1;
+ vtmp->latency_next_metric = CEPH_AVGCOUNT;
vtmp->latency_index = 0;
vtmp->index = 0;
yajl->handler_arg = vtmp;