X-Git-Url: https://git.octo.it/?p=collectd.git;a=blobdiff_plain;f=src%2Fceph.c;h=5ea90499ae2090a35d646a2d4284768e4a80fc43;hp=bfd95e829eed6b1cc4f82ed351de8aeb45c697e7;hb=da11ce02eb202b3e01d3e2d1b40f248a84430973;hpb=ddde85aad33bad5e7f5ed0d21ee082ef1dcda140 diff --git a/src/ceph.c b/src/ceph.c index bfd95e82..5ea90499 100644 --- a/src/ceph.c +++ b/src/ceph.c @@ -280,8 +280,10 @@ static int ceph_cb_number(void *ctx, const char *number_val, * the same type of other "Bytes". Instead of keeping an "average" or * "rate", use the "sum" in the pair and assign that to the derive * value. */ - if (convert_special_metrics && (state->depth >= 2) && + if (convert_special_metrics && (state->depth > 2) && + state->stack[state->depth - 2] && (strcmp("filestore", state->stack[state->depth - 2]) == 0) && + state->stack[state->depth - 1] && (strcmp("journal_wr_bytes", state->stack[state->depth - 1]) == 0) && (strcmp("avgcount", state->key) == 0)) { DEBUG("ceph plugin: Skipping avgcount for filestore.JournalWrBytes"); @@ -396,7 +398,7 @@ static void ceph_daemon_free(struct ceph_daemon *d) { } /* compact_ds_name removed the special characters ":", "_", "-" and "+" from the - * intput string. Characters following these special characters are capitalized. + * input string. Characters following these special characters are capitalized. * Trailing "+" and "-" characters are replaces with the strings "Plus" and * "Minus". */ static int compact_ds_name(char *buffer, size_t buffer_size, char const *src) { @@ -518,12 +520,6 @@ static int parse_keys(char *buffer, size_t buffer_size, const char *key_str) { size_t tmp_size = sizeof(tmp); const char *cut_suffixes[] = {".type", ".avgcount", ".sum", ".avgtime"}; - /* The "avgtime" metric reports ("sum" / "avgcount"), i.e. the average time - * per request since the start of the Ceph daemon. Report this only when the - * user has configured "long running average". Otherwise, use the rate of - * "sum" and "avgcount" to calculate the current latency. - */ - if (buffer == NULL || buffer_size == 0 || key_str == NULL || strlen(key_str) == 0) return EINVAL; @@ -933,7 +929,13 @@ static int node_handler_fetch_data(void *arg, const char *val, uv.gauge = result; vtmp->latency_index = (vtmp->latency_index + 1); } else if (has_suffix(key, ".avgtime")) { - // skip this step if no need in long run latency + + /* The "avgtime" metric reports ("sum" / "avgcount"), i.e. the average + * time per request since the start of the Ceph daemon. Report this only + * when the user has configured "long running average". Otherwise, use the + * rate of "sum" and "avgcount" to calculate the current latency. + */ + if (!long_run_latency_avg) { return 0; }