Merge pull request #2876 from abays/fix_amqp1_typo
authorPavel Rochnyak <pavel2000@ngs.ru>
Wed, 25 Jul 2018 17:17:28 +0000 (00:17 +0700)
committerGitHub <noreply@github.com>
Wed, 25 Jul 2018 17:17:28 +0000 (00:17 +0700)
Fix typo in amqp1 JSON format error message

src/processes.c
src/tail.c
src/utils_latency.c
src/utils_latency_config.c
src/utils_latency_config.h
src/utils_tail.c

index 86e99c3..aa7cfa3 100644 (file)
@@ -924,7 +924,7 @@ static void ps_submit_proc_list(procstat_t *ps) {
     sstrncpy(vl.type, "delay_rate", sizeof(vl.type));
     sstrncpy(vl.type_instance, delay_metrics[i].type_instance,
              sizeof(vl.type_instance));
-    vl.values[0].gauge = delay_metrics[i].rate_ns * delay_factor;
+    vl.values[0].gauge = delay_metrics[i].rate_ns / delay_factor;
     vl.values_len = 1;
     plugin_dispatch_values(&vl);
   }
index 841b331..df94580 100644 (file)
@@ -95,7 +95,7 @@ static int ctail_config_add_match_dstype(ctail_config_match_t *cm,
   } else if (strcasecmp("Distribution", ds_type) == 0) {
     cm->flags = UTILS_MATCH_DS_TYPE_GAUGE | UTILS_MATCH_CF_GAUGE_DIST;
 
-    int status = latency_config(&cm->latency, ci, "tail");
+    int status = latency_config(&cm->latency, ci);
     if (status != 0)
       return status;
   } else if (strncasecmp("Counter", ds_type, strlen("Counter")) == 0) {
index 1d3bf2e..6e4f873 100644 (file)
@@ -156,7 +156,7 @@ void latency_counter_add(latency_counter_t *lc, cdtime_t latency) /* {{{ */
     change_bin_width(lc, latency);
     bin = (latency - 1) / lc->bin_width;
     if (bin >= HISTOGRAM_NUM_BINS) {
-      ERROR("utils_latency: latency_counter_add: Invalid bin: %" PRIu64, bin);
+      P_ERROR("latency_counter_add: Invalid bin: %" PRIu64, bin);
       return;
     }
   }
index 5eb5b6d..9a91f11 100644 (file)
  *   Pavel Rochnyack <pavel2000 at ngs.ru>
  */
 
-#include "utils_latency_config.h"
-#include "common.h"
 #include "collectd.h"
+#include "common.h"
+#include "utils_latency_config.h"
 
 static int latency_config_add_percentile(latency_config_t *conf,
-                                         oconfig_item_t *ci,
-                                         const char *plugin) {
+                                         oconfig_item_t *ci) {
   double percent;
   int status = cf_util_get_double(ci, &percent);
   if (status != 0)
     return status;
 
   if ((percent <= 0.0) || (percent >= 100)) {
-    ERROR("%s plugin: The value for \"%s\" must be between 0 and 100, "
-          "exclusively.",
-          plugin, ci->key);
+    P_ERROR("The value for \"%s\" must be between 0 and 100, "
+            "exclusively.",
+            ci->key);
     return ERANGE;
   }
 
   double *tmp = realloc(conf->percentile,
                         sizeof(*conf->percentile) * (conf->percentile_num + 1));
   if (tmp == NULL) {
-    ERROR("%s plugin: realloc failed.", plugin);
+    P_ERROR("realloc failed.");
     return ENOMEM;
   }
   conf->percentile = tmp;
@@ -57,31 +56,29 @@ static int latency_config_add_percentile(latency_config_t *conf,
   return 0;
 } /* int latency_config_add_percentile */
 
-static int latency_config_add_bucket(latency_config_t *conf, oconfig_item_t *ci,
-                                     const char *plugin) {
+static int latency_config_add_bucket(latency_config_t *conf,
+                                     oconfig_item_t *ci) {
   if ((ci->values_num != 2) || (ci->values[0].type != OCONFIG_TYPE_NUMBER) ||
       (ci->values[1].type != OCONFIG_TYPE_NUMBER)) {
-    ERROR("%s plugin: \"%s\" requires exactly two numeric arguments.", plugin,
-          ci->key);
+    P_ERROR("\"%s\" requires exactly two numeric arguments.", ci->key);
     return EINVAL;
   }
 
   if (ci->values[1].value.number &&
       ci->values[1].value.number <= ci->values[0].value.number) {
-    ERROR("%s plugin: MIN must be less than MAX in \"%s\".", plugin, ci->key);
+    P_ERROR("MIN must be less than MAX in \"%s\".", ci->key);
     return ERANGE;
   }
 
   if (ci->values[0].value.number < 0) {
-    ERROR("%s plugin: MIN must be greater then or equal to zero in \"%s\".",
-          plugin, ci->key);
+    P_ERROR("MIN must be greater then or equal to zero in \"%s\".", ci->key);
     return ERANGE;
   }
 
   latency_bucket_t *tmp =
       realloc(conf->buckets, sizeof(*conf->buckets) * (conf->buckets_num + 1));
   if (tmp == NULL) {
-    ERROR("%s plugin: realloc failed.", plugin);
+    P_ERROR("realloc failed.");
     return ENOMEM;
   }
   conf->buckets = tmp;
@@ -94,22 +91,21 @@ static int latency_config_add_bucket(latency_config_t *conf, oconfig_item_t *ci,
   return 0;
 } /* int latency_config_add_bucket */
 
-int latency_config(latency_config_t *conf, oconfig_item_t *ci,
-                   char const *plugin) {
+int latency_config(latency_config_t *conf, oconfig_item_t *ci) {
   int status = 0;
 
   for (int i = 0; i < ci->children_num; i++) {
     oconfig_item_t *child = ci->children + i;
 
     if (strcasecmp("Percentile", child->key) == 0)
-      status = latency_config_add_percentile(conf, child, plugin);
+      status = latency_config_add_percentile(conf, child);
     else if (strcasecmp("Bucket", child->key) == 0)
-      status = latency_config_add_bucket(conf, child, plugin);
+      status = latency_config_add_bucket(conf, child);
     else if (strcasecmp("BucketType", child->key) == 0)
       status = cf_util_get_string(child, &conf->bucket_type);
     else
-      WARNING("%s plugin: \"%s\" is not a valid option within a \"%s\" block.",
-              plugin, child->key, ci->key);
+      P_WARNING("\"%s\" is not a valid option within a \"%s\" block.",
+                child->key, ci->key);
 
     if (status != 0)
       return status;
@@ -117,9 +113,9 @@ int latency_config(latency_config_t *conf, oconfig_item_t *ci,
 
   if ((status == 0) && (conf->percentile_num == 0) &&
       (conf->buckets_num == 0)) {
-    ERROR("%s plugin: The \"%s\" block must contain at least one "
-          "\"Percentile\" or \"Bucket\" option.",
-          plugin, ci->key);
+    P_ERROR("The \"%s\" block must contain at least one "
+            "\"Percentile\" or \"Bucket\" option.",
+            ci->key);
     return EINVAL;
   }
 
index 2572fa0..3d2691a 100644 (file)
@@ -53,8 +53,7 @@ typedef struct {
   */
 } latency_config_t;
 
-int latency_config(latency_config_t *conf, oconfig_item_t *ci,
-                   char const *plugin);
+int latency_config(latency_config_t *conf, oconfig_item_t *ci);
 
 int latency_config_copy(latency_config_t *dst, const latency_config_t src);
 
index b5dc5af..55a3287 100644 (file)
@@ -43,13 +43,11 @@ struct cu_tail_s {
 
 static int cu_tail_reopen(cu_tail_t *obj) {
   int seek_end = 0;
-  FILE *fh;
   struct stat stat_buf = {0};
-  int status;
 
-  status = stat(obj->file, &stat_buf);
+  int status = stat(obj->file, &stat_buf);
   if (status != 0) {
-    ERROR("utils_tail: stat (%s) failed: %s", obj->file, STRERRNO);
+    P_ERROR("utils_tail: stat (%s) failed: %s", obj->file, STRERRNO);
     return -1;
   }
 
@@ -57,10 +55,10 @@ static int cu_tail_reopen(cu_tail_t *obj) {
   if ((obj->fh != NULL) && (stat_buf.st_ino == obj->stat.st_ino)) {
     /* Seek to the beginning if file was truncated */
     if (stat_buf.st_size < obj->stat.st_size) {
-      INFO("utils_tail: File `%s' was truncated.", obj->file);
+      P_INFO("utils_tail: File `%s' was truncated.", obj->file);
       status = fseek(obj->fh, 0, SEEK_SET);
       if (status != 0) {
-        ERROR("utils_tail: fseek (%s) failed: %s", obj->file, STRERRNO);
+        P_ERROR("utils_tail: fseek (%s) failed: %s", obj->file, STRERRNO);
         fclose(obj->fh);
         obj->fh = NULL;
         return -1;
@@ -75,16 +73,16 @@ static int cu_tail_reopen(cu_tail_t *obj) {
   if ((obj->stat.st_ino == 0) || (obj->stat.st_ino == stat_buf.st_ino))
     seek_end = 1;
 
-  fh = fopen(obj->file, "r");
+  FILE *fh = fopen(obj->file, "r");
   if (fh == NULL) {
-    ERROR("utils_tail: fopen (%s) failed: %s", obj->file, STRERRNO);
+    P_ERROR("utils_tail: fopen (%s) failed: %s", obj->file, STRERRNO);
     return -1;
   }
 
   if (seek_end != 0) {
     status = fseek(fh, 0, SEEK_END);
     if (status != 0) {
-      ERROR("utils_tail: fseek (%s) failed: %s", obj->file, STRERRNO);
+      P_ERROR("utils_tail: fseek (%s) failed: %s", obj->file, STRERRNO);
       fclose(fh);
       return -1;
     }