]> arthur.barton.de Git - netdata.git/blobdiff - src/global_statistics.c
locks abstraction, error reporting, debugging
[netdata.git] / src / global_statistics.c
index 90f0699f7ff033d93a1d3eca7edd5afa941e1a55..2ccdf6801480d2064390513bf0616be47c71a7f7 100644 (file)
@@ -10,14 +10,14 @@ volatile struct global_statistics global_statistics = {
         .compressed_content_size = 0
 };
 
-pthread_mutex_t global_statistics_mutex = PTHREAD_MUTEX_INITIALIZER;
+netdata_mutex_t global_statistics_mutex = NETDATA_MUTEX_INITIALIZER;
 
 inline void global_statistics_lock(void) {
-    pthread_mutex_lock(&global_statistics_mutex);
+    netdata_mutex_lock(&global_statistics_mutex);
 }
 
 inline void global_statistics_unlock(void) {
-    pthread_mutex_unlock(&global_statistics_mutex);
+    netdata_mutex_unlock(&global_statistics_mutex);
 }
 
 void finished_web_request_statistics(uint64_t dt,
@@ -131,9 +131,9 @@ void global_statistics_charts(void) {
 
     if (!stcpu_thread) stcpu_thread = rrdset_find_localhost("netdata.plugin_proc_cpu");
     if (!stcpu_thread) {
-        stcpu_thread = rrdset_create("netdata", "plugin_proc_cpu", NULL, "proc", NULL,
-                                     "NetData Proc Plugin CPU usage", "milliseconds/s", 132000, rrd_update_every,
-                                     RRDSET_TYPE_STACKED);
+        stcpu_thread = rrdset_create_localhost("netdata", "plugin_proc_cpu", NULL, "proc", NULL
+                                               , "NetData Proc Plugin CPU usage", "milliseconds/s", 132000
+                                               , localhost->rrd_update_every, RRDSET_TYPE_STACKED);
 
         rrddim_add(stcpu_thread, "user", NULL, 1, 1000, RRD_ALGORITHM_INCREMENTAL);
         rrddim_add(stcpu_thread, "system", NULL, 1, 1000, RRD_ALGORITHM_INCREMENTAL);
@@ -147,8 +147,8 @@ void global_statistics_charts(void) {
 
     if (!stcpu) stcpu = rrdset_find_localhost("netdata.server_cpu");
     if (!stcpu) {
-        stcpu = rrdset_create("netdata", "server_cpu", NULL, "netdata", NULL, "NetData CPU usage", "milliseconds/s",
-                              130000, rrd_update_every, RRDSET_TYPE_STACKED);
+        stcpu = rrdset_create_localhost("netdata", "server_cpu", NULL, "netdata", NULL, "NetData CPU usage"
+                                        , "milliseconds/s", 130000, localhost->rrd_update_every, RRDSET_TYPE_STACKED);
 
         rrddim_add(stcpu, "user", NULL, 1, 1000, RRD_ALGORITHM_INCREMENTAL);
         rrddim_add(stcpu, "system", NULL, 1, 1000, RRD_ALGORITHM_INCREMENTAL);
@@ -162,8 +162,8 @@ void global_statistics_charts(void) {
 
     if (!stclients) stclients = rrdset_find_localhost("netdata.clients");
     if (!stclients) {
-        stclients = rrdset_create("netdata", "clients", NULL, "netdata", NULL, "NetData Web Clients",
-                                  "connected clients", 130200, rrd_update_every, RRDSET_TYPE_LINE);
+        stclients = rrdset_create_localhost("netdata", "clients", NULL, "netdata", NULL, "NetData Web Clients"
+                                            , "connected clients", 130200, localhost->rrd_update_every, RRDSET_TYPE_LINE);
 
         rrddim_add(stclients, "clients", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
     } else rrdset_next(stclients);
@@ -175,8 +175,8 @@ void global_statistics_charts(void) {
 
     if (!streqs) streqs = rrdset_find_localhost("netdata.requests");
     if (!streqs) {
-        streqs = rrdset_create("netdata", "requests", NULL, "netdata", NULL, "NetData Web Requests", "requests/s",
-                               130300, rrd_update_every, RRDSET_TYPE_LINE);
+        streqs = rrdset_create_localhost("netdata", "requests", NULL, "netdata", NULL, "NetData Web Requests"
+                                         , "requests/s", 130300, localhost->rrd_update_every, RRDSET_TYPE_LINE);
 
         rrddim_add(streqs, "requests", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
     } else rrdset_next(streqs);
@@ -188,8 +188,8 @@ void global_statistics_charts(void) {
 
     if (!stbytes) stbytes = rrdset_find_localhost("netdata.net");
     if (!stbytes) {
-        stbytes = rrdset_create("netdata", "net", NULL, "netdata", NULL, "NetData Network Traffic", "kilobits/s",
-                                130000, rrd_update_every, RRDSET_TYPE_AREA);
+        stbytes = rrdset_create_localhost("netdata", "net", NULL, "netdata", NULL, "NetData Network Traffic"
+                                          , "kilobits/s", 130000, localhost->rrd_update_every, RRDSET_TYPE_AREA);
 
         rrddim_add(stbytes, "in", NULL, 8, 1024, RRD_ALGORITHM_INCREMENTAL);
         rrddim_add(stbytes, "out", NULL, -8, 1024, RRD_ALGORITHM_INCREMENTAL);
@@ -203,8 +203,9 @@ void global_statistics_charts(void) {
 
     if (!stduration) stduration = rrdset_find_localhost("netdata.response_time");
     if (!stduration) {
-        stduration = rrdset_create("netdata", "response_time", NULL, "netdata", NULL, "NetData API Response Time",
-                                   "ms/request", 130400, rrd_update_every, RRDSET_TYPE_LINE);
+        stduration = rrdset_create_localhost("netdata", "response_time", NULL, "netdata", NULL
+                                             , "NetData API Response Time", "ms/request", 130400, localhost->rrd_update_every
+                                             , RRDSET_TYPE_LINE);
 
         rrddim_add(stduration, "average", NULL, 1, 1000, RRD_ALGORITHM_ABSOLUTE);
         rrddim_add(stduration, "max", NULL, 1, 1000, RRD_ALGORITHM_ABSOLUTE);
@@ -234,9 +235,9 @@ void global_statistics_charts(void) {
 
     if (!stcompression) stcompression = rrdset_find_localhost("netdata.compression_ratio");
     if (!stcompression) {
-        stcompression = rrdset_create("netdata", "compression_ratio", NULL, "netdata", NULL,
-                                      "NetData API Responses Compression Savings Ratio", "percentage", 130500,
-                                      rrd_update_every, RRDSET_TYPE_LINE);
+        stcompression = rrdset_create_localhost("netdata", "compression_ratio", NULL, "netdata", NULL
+                                                , "NetData API Responses Compression Savings Ratio", "percentage"
+                                                , 130500, localhost->rrd_update_every, RRDSET_TYPE_LINE);
 
         rrddim_add(stcompression, "savings", NULL, 1, 1000, RRD_ALGORITHM_ABSOLUTE);
     } else rrdset_next(stcompression);