]> arthur.barton.de Git - netdata.git/blobdiff - src/proc_softirqs.c
fixed typo in sizeof()
[netdata.git] / src / proc_softirqs.c
index 5da7155fc26657bb4e43442e197dda7e89ce843d..560e2acb2d9dd1ab67c3e14f88cfd399e0df205b 100644 (file)
@@ -23,9 +23,9 @@ struct interrupt {
 // given a base, get a pointer to each record
 #define irrindex(base, line, cpus) ((struct interrupt *)&((char *)(base))[line * recordsize(cpus)])
 
-static inline struct interrupt *get_interrupts_array(uint32_t lines, int cpus) {
+static inline struct interrupt *get_interrupts_array(size_t lines, int cpus) {
     static struct interrupt *irrs = NULL;
-    static uint32_t allocated = 0;
+    static size_t allocated = 0;
 
     if(unlikely(lines != allocated)) {
         uint32_t l;
@@ -58,7 +58,7 @@ int do_proc_softirqs(int update_every, usec_t dt) {
 
     if(unlikely(!ff)) {
         char filename[FILENAME_MAX + 1];
-        snprintfz(filename, FILENAME_MAX, "%s%s", global_host_prefix, "/proc/softirqs");
+        snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/proc/softirqs");
         ff = procfile_open(config_get("plugin:proc:/proc/softirqs", "filename to monitor", filename), " \t", PROCFILE_FLAG_DEFAULT);
         if(unlikely(!ff)) return 1;
     }
@@ -66,8 +66,8 @@ int do_proc_softirqs(int update_every, usec_t dt) {
     ff = procfile_readall(ff);
     if(unlikely(!ff)) return 0; // we return 0, so that we will retry to open it next time
 
-    uint32_t lines = procfile_lines(ff), l;
-    uint32_t words = procfile_linewords(ff, 0);
+    size_t lines = procfile_lines(ff), l;
+    size_t words = procfile_linewords(ff, 0);
 
     if(unlikely(!lines)) {
         error("Cannot read /proc/softirqs, zero lines reported.");
@@ -105,8 +105,8 @@ int do_proc_softirqs(int update_every, usec_t dt) {
         irr->id = procfile_lineword(ff, l, 0);
         if(unlikely(!irr->id || !irr->id[0])) continue;
 
-        int idlen = strlen(irr->id);
-        if(unlikely(irr->id[idlen - 1] == ':'))
+        size_t idlen = strlen(irr->id);
+        if(unlikely(idlen && irr->id[idlen - 1] == ':'))
             irr->id[idlen - 1] = '\0';
 
         int c;
@@ -128,8 +128,9 @@ int do_proc_softirqs(int update_every, usec_t dt) {
 
     // --------------------------------------------------------------------
 
-    st = rrdset_find_bytype("system", "softirqs");
-    if(unlikely(!st)) st = rrdset_create("system", "softirqs", NULL, "softirqs", NULL, "System softirqs", "softirqs/s", 950, update_every, RRDSET_TYPE_STACKED);
+    st = rrdset_find_bytype_localhost("system", "softirqs");
+    if(unlikely(!st)) st = rrdset_create_localhost("system", "softirqs", NULL, "softirqs", NULL, "System softirqs"
+                                                   , "softirqs/s", 950, update_every, RRDSET_TYPE_STACKED);
     else rrdset_next(st);
 
     for(l = 0; l < lines ;l++) {
@@ -141,7 +142,7 @@ int do_proc_softirqs(int update_every, usec_t dt) {
         if(unlikely(!irr->rd || strncmp(irr->name, irr->rd->name, MAX_INTERRUPT_NAME) != 0)) {
             irr->rd = rrddim_find(st, irr->id);
             if(unlikely(!irr->rd))
-                irr->rd = rrddim_add(st, irr->id, irr->name, 1, 1, RRDDIM_INCREMENTAL);
+                irr->rd = rrddim_add(st, irr->id, irr->name, 1, 1, RRD_ALGORITHM_INCREMENTAL);
             else
                 rrddim_set_name(st, irr->rd, irr->name);
 
@@ -163,7 +164,7 @@ int do_proc_softirqs(int update_every, usec_t dt) {
             char id[50+1];
             snprintfz(id, 50, "cpu%d_softirqs", c);
 
-            st = rrdset_find_bytype("cpu", id);
+            st = rrdset_find_bytype_localhost("cpu", id);
             if(unlikely(!st)) {
                 // find if everything is zero
                 unsigned long long core_sum = 0 ;
@@ -176,7 +177,8 @@ int do_proc_softirqs(int update_every, usec_t dt) {
 
                 char title[100+1];
                 snprintfz(title, 100, "CPU%d softirqs", c);
-                st = rrdset_create("cpu", id, NULL, "softirqs", "cpu.softirqs", title, "softirqs/s", 3000 + c, update_every, RRDSET_TYPE_STACKED);
+                st = rrdset_create_localhost("cpu", id, NULL, "softirqs", "cpu.softirqs", title, "softirqs/s", 3000 + c
+                                             , update_every, RRDSET_TYPE_STACKED);
             }
             else rrdset_next(st);
 
@@ -186,7 +188,7 @@ int do_proc_softirqs(int update_every, usec_t dt) {
                 if(unlikely(!irr->cpu[c].rd)) {
                     irr->cpu[c].rd = rrddim_find(st, irr->id);
                     if(unlikely(!irr->cpu[c].rd))
-                        irr->cpu[c].rd = rrddim_add(st, irr->id, irr->name, 1, 1, RRDDIM_INCREMENTAL);
+                        irr->cpu[c].rd = rrddim_add(st, irr->id, irr->name, 1, 1, RRD_ALGORITHM_INCREMENTAL);
                     else
                         rrddim_set_name(st, irr->cpu[c].rd, irr->name);
                 }