[Reconnoiter-devel] [reconnoiter commit] Reconnoiter branch, master, updated. c0606177e96ca2dd9ca395a81715892807816f5c

git at labs.omniti.com git at labs.omniti.com
Tue May 22 08:14:24 EDT 2012


Pushed by: jesus
The branch, master has been updated
       via  c0606177e96ca2dd9ca395a81715892807816f5c (commit)
      from  f22ed556234ab8522cbdd79c7fa6da2cf9d7b302 (commit)

Summary of changes:
 src/modules/statsd.c |   34 ++++++++++++++++++++++++----------
 src/noit.conf.in     |    1 +
 2 files changed, 25 insertions(+), 10 deletions(-)

Log:
commit c0606177e96ca2dd9ca395a81715892807816f5c
Author: Theo Schlossnagle <jesus at omniti.com>
Date:   Tue May 22 08:14:21 2012 -0400

    add a sample check. change atoi() to strtod(). Do in-place metrics updating for performance reasons.

diff --git a/src/modules/statsd.c b/src/modules/statsd.c
index f38280c..4409bd5 100644
--- a/src/modules/statsd.c
+++ b/src/modules/statsd.c
@@ -131,7 +131,7 @@ statsd_submit(noit_module_t *self, noit_check_t *check,
 static void
 update_check(noit_check_t *check, const char *key, char type,
              double diff, double sample) {
-  u_int32_t count = 1;
+  u_int32_t one = 1;
   char buff[256];
   statsd_closure_t *ccl;
   metric_t *m;
@@ -142,21 +142,35 @@ update_check(noit_check_t *check, const char *key, char type,
   /* First key counts */
   snprintf(buff, sizeof(buff), "%s`count", key);
   m = noit_stats_get_metric(check, &ccl->current, buff);
-  if(m && m->metric_type == METRIC_UINT32 && m->metric_value.I != NULL)
-    count = *m->metric_value.I + 1;
-  noit_stats_set_metric(check, &ccl->current, buff, METRIC_UINT32, &count);
+  if(!m) ccl->stats_count++;
+  if(m && m->metric_type == METRIC_UINT32 && m->metric_value.I != NULL) {
+    (*m->metric_value.I)++;
+    check_stats_set_metric_hook_invoke(check, &ccl->current, m);
+  }
+  else
+    noit_stats_set_metric(check, &ccl->current, buff, METRIC_UINT32, &one);
 
   /* Next the actual data */
-  m = noit_stats_get_metric(check, &ccl->current, key);
+  snprintf(buff, sizeof(buff), "%s`%s", key,
+           (type == 'c') ? "counter" : (type == 'g') ? "gauge" : "timing");
+  m = noit_stats_get_metric(check, &ccl->current, buff);
   if(type == 'c') {
     double v = diff * (1.0 / sample);
-    if(m && m->metric_type == METRIC_DOUBLE && m->metric_value.n != NULL)
-      v += (*m->metric_value.n);
-    noit_stats_set_metric(check, &ccl->current, key, METRIC_DOUBLE, &v);
+    if(m && m->metric_type == METRIC_DOUBLE && m->metric_value.n != NULL) {
+      (*m->metric_value.n) += v;
+      check_stats_set_metric_hook_invoke(check, &ccl->current, m);
+    }
+    else
+      noit_stats_set_metric(check, &ccl->current, buff, METRIC_DOUBLE, &v);
   }
   else if(type == 'g' || type == 'm') {
     double v = diff;
-    noit_stats_set_metric(check, &ccl->current, key, METRIC_DOUBLE, &v);
+    if(m && m->metric_type == METRIC_DOUBLE && m->metric_value.n != NULL) {
+      (*m->metric_value.n) = v;
+      check_stats_set_metric_hook_invoke(check, &ccl->current, m);
+    }
+    else
+      noit_stats_set_metric(check, &ccl->current, buff, METRIC_DOUBLE, &v);
   }
 }
 
@@ -217,7 +231,7 @@ statsd_handle_payload(noit_check_t *parent, noit_check_t *single,
             type = NULL;
           }
         }
-        diff = atoi(value);
+        diff = strtod(value, NULL);
       }
       if(type == NULL) type = COUNTER_STRING;
 
diff --git a/src/noit.conf.in b/src/noit.conf.in
index 90ae2f6..6c0039e 100644
--- a/src/noit.conf.in
+++ b/src/noit.conf.in
@@ -163,6 +163,7 @@
       </disk>
     </dc1>
     <check uuid="002d58ff-20ff-4db0-9420-782fc1748dc4" module="ssh2" target="10.80.117.2" period="60000" timeout="4000"/>
+    <check uuid="ff4f1de8-a405-11e1-8770-9347de0fce85" module="statsd" target="127.0.0.1" period="60000" timeout="59999"/>
   </checks>
   <filtersets>
     <filterset name="default">




hooks/post-receive
-- 
Reconnoiter


More information about the Reconnoiter-devel mailing list