]> arthur.barton.de Git - netdata.git/blobdiff - src/backends.c
replace `time_usec()` calls by `now_realtime_usec()`
[netdata.git] / src / backends.c
index 753959738979a8c5b74ca9ed1d5846c1540de0ee..69a61414445a143d57c26790a09e9844bae96e4e 100644 (file)
@@ -164,7 +164,7 @@ static inline int connect_to_one(const char *definition, int default_port, struc
     return fd;
 }
 
-static inline calculated_number backend_duration_average(RRDSET *st, RRDDIM *rd, time_t after, time_t before, uint32_t options) {
+static inline calculated_number backend_calculate_value_from_stored_data(RRDSET *st, RRDDIM *rd, time_t after, time_t before, uint32_t options) {
     time_t first_t = rrdset_first_entry_t(st);
     time_t last_t = rrdset_last_entry_t(st);
 
@@ -227,7 +227,7 @@ static inline int format_dimension_collected_graphite_plaintext(BUFFER *b, const
 
 static inline int format_dimension_stored_graphite_plaintext(BUFFER *b, const char *prefix, RRDHOST *host, const char *hostname, RRDSET *st, RRDDIM *rd, time_t after, time_t before, uint32_t options) {
     (void)host;
-    calculated_number value = backend_duration_average(st, rd, after, before, options);
+    calculated_number value = backend_calculate_value_from_stored_data(st, rd, after, before, options);
     if(!isnan(value)) {
         buffer_sprintf(b, "%s.%s.%s.%s " CALCULATED_NUMBER_FORMAT " %u\n", prefix, hostname, st->id, rd->id, value, (uint32_t) before);
         return 1;
@@ -246,7 +246,7 @@ static inline int format_dimension_collected_opentsdb_telnet(BUFFER *b, const ch
 
 static inline int format_dimension_stored_opentsdb_telnet(BUFFER *b, const char *prefix, RRDHOST *host, const char *hostname, RRDSET *st, RRDDIM *rd, time_t after, time_t before, uint32_t options) {
     (void)host;
-    calculated_number value = backend_duration_average(st, rd, after, before, options);
+    calculated_number value = backend_calculate_value_from_stored_data(st, rd, after, before, options);
     if(!isnan(value)) {
         buffer_sprintf(b, "put %s.%s.%s %u " CALCULATED_NUMBER_FORMAT " host=%s\n", prefix, st->id, rd->id, (uint32_t) before, value, hostname);
         return 1;
@@ -278,7 +278,7 @@ void *backends_main(void *ptr) {
     int default_port = 0;
     int sock = -1;
     uint32_t options;
-    int enabled = config_get_boolean("backend", "enable", 0);
+    int enabled = config_get_boolean("backend", "enabled", 0);
     const char *source = config_get("backend", "data source", "average");
     const char *type = config_get("backend", "type", "graphite");
     const char *destination = config_get("backend", "destination", "localhost");
@@ -396,8 +396,8 @@ void *backends_main(void *ptr) {
     info("BACKEND configured ('%s' on '%s' sending '%s' data, every %d seconds, as host '%s', with prefix '%s')", type, destination, source, frequency, hostname, prefix);
 
     unsigned long long step_ut = frequency * 1000000ULL;
-    unsigned long long random_ut = time_usec() % (step_ut / 2);
-    time_t before = (time_t)((time_usec() - step_ut) / 10000000ULL);
+    unsigned long long random_ut = now_realtime_usec() % (step_ut / 2);
+    time_t before = (time_t)((now_realtime_usec() - step_ut) / 10000000ULL);
     time_t after = before;
     int failures = 0;
 
@@ -405,7 +405,7 @@ void *backends_main(void *ptr) {
         // ------------------------------------------------------------------------
         // wait for the next iteration point
 
-        unsigned long long now_ut = time_usec();
+        unsigned long long now_ut = now_realtime_usec();
         unsigned long long next_ut = now_ut - (now_ut % step_ut) + step_ut;
         before = (time_t)(next_ut / 1000000ULL);
 
@@ -414,7 +414,7 @@ void *backends_main(void *ptr) {
 
         while(now_ut < next_ut) {
             sleep_usec(next_ut - now_ut);
-            now_ut = time_usec();
+            now_ut = now_realtime_usec();
         }
 
         // ------------------------------------------------------------------------
@@ -465,7 +465,7 @@ void *backends_main(void *ptr) {
         // connect to a backend server
 
         if(unlikely(sock == -1)) {
-            unsigned long long start_ut = time_usec();
+            unsigned long long start_ut = now_realtime_usec();
             const char *s = destination;
             while(*s) {
                 const char *e = s;
@@ -486,7 +486,7 @@ void *backends_main(void *ptr) {
                 if(sock != -1) break;
                 s = e;
             }
-            chart_backend_latency += time_usec() - start_ut;
+            chart_backend_latency += now_realtime_usec() - start_ut;
         }
 
         if(unlikely(netdata_exit)) break;
@@ -496,13 +496,13 @@ void *backends_main(void *ptr) {
 
         if(likely(sock != -1)) {
             size_t len = buffer_strlen(b);
-            unsigned long long start_ut = time_usec();
+            unsigned long long start_ut = now_realtime_usec();
             int flags = 0;
 #ifdef MSG_NOSIGNAL
             flags += MSG_NOSIGNAL;
 #endif
             ssize_t written = send(sock, buffer_tostring(b), len, flags);
-            chart_backend_latency += time_usec() - start_ut;
+            chart_backend_latency += now_realtime_usec() - start_ut;
             if(written != -1 && (size_t)written == len) {
                 // we sent the data successfully
                 chart_transmission_successes++;