]> arthur.barton.de Git - netdata.git/blobdiff - src/plugin_idlejitter.c
global statistics now also report max API response time; global statistics implemente...
[netdata.git] / src / plugin_idlejitter.c
old mode 100755 (executable)
new mode 100644 (file)
index f18ebb3..d0a9181
@@ -1,15 +1,4 @@
-#include <pthread.h>
-#include <sys/time.h>
-#include <sys/resource.h>
-#include <strings.h>
-#include <unistd.h>
-
-#include "global_statistics.h"
 #include "common.h"
-#include "config.h"
-#include "log.h"
-#include "rrd.h"
-#include "plugin_idlejitter.h"
 
 #define CPU_IDLEJITTER_SLEEP_TIME_MS 20
 
@@ -17,13 +6,15 @@ void *cpuidlejitter_main(void *ptr)
 {
        if(ptr) { ; }
 
+       info("CPU Idle Jitter thread created with task id %d", gettid());
+
        if(pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL) != 0)
                error("Cannot set pthread cancel type to DEFERRED.");
 
        if(pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL) != 0)
                error("Cannot set pthread cancel state to ENABLE.");
 
-       int sleep_ms = config_get_number("plugin:idlejitter", "loop time in ms", CPU_IDLEJITTER_SLEEP_TIME_MS);
+       int sleep_ms = (int) config_get_number("plugin:idlejitter", "loop time in ms", CPU_IDLEJITTER_SLEEP_TIME_MS);
        if(sleep_ms <= 0) {
                config_set_number("plugin:idlejitter", "loop time in ms", CPU_IDLEJITTER_SLEEP_TIME_MS);
                sleep_ms = CPU_IDLEJITTER_SLEEP_TIME_MS;
@@ -31,7 +22,7 @@ void *cpuidlejitter_main(void *ptr)
 
        RRDSET *st = rrdset_find("system.idlejitter");
        if(!st) {
-               st = rrdset_create("system", "idlejitter", NULL, "cpu", "CPU Idle Jitter", "microseconds lost/s", 9999, rrd_update_every, RRDSET_TYPE_LINE);
+               st = rrdset_create("system", "idlejitter", NULL, "processes", NULL, "CPU Idle Jitter", "microseconds lost/s", 9999, rrd_update_every, RRDSET_TYPE_LINE);
                rrddim_add(st, "jitter", NULL, 1, 1, RRDDIM_ABSOLUTE);
        }
 
@@ -47,16 +38,17 @@ void *cpuidlejitter_main(void *ptr)
                        gettimeofday(&after, NULL);
 
                        // calculate the time it took for a full loop
-                       usec = usecdiff(&after, &before);
+                       usec = usec_dt(&after, &before);
                        susec += usec;
                }
                usec -= (sleep_ms * 1000);
 
-               if(counter) rrdset_next_usec(st, susec);
+               if(counter) rrdset_next(st);
                rrddim_set(st, "jitter", usec);
                rrdset_done(st);
        }
 
+       pthread_exit(NULL);
        return NULL;
 }