]> arthur.barton.de Git - netdata.git/commitdiff
several code optimizations
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Mon, 7 Nov 2016 21:07:51 +0000 (23:07 +0200)
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Mon, 7 Nov 2016 21:07:51 +0000 (23:07 +0200)
19 files changed:
src/plugin_tc.c
src/plugins_d.c
src/proc_diskstats.c
src/proc_interrupts.c
src/proc_loadavg.c
src/proc_meminfo.c
src/proc_net_netstat.c
src/proc_net_snmp.c
src/proc_net_snmp6.c
src/proc_net_softnet_stat.c
src/proc_net_stat_conntrack.c
src/proc_net_stat_synproxy.c
src/proc_self_mountinfo.c
src/proc_softirqs.c
src/proc_stat.c
src/proc_sys_kernel_random_entropy_avail.c
src/proc_vmstat.c
src/procfile.c
src/unit_test.c

index 399fcd6db458f5aa84992c99e2c33555d77f49bf..cecadf36036fa21a12033a59b4db691ca944f3ed 100644 (file)
@@ -306,7 +306,7 @@ static inline void tc_device_commit(struct tc_device *d) {
             }
             else {
                 debug(D_TC_LOOP, "TC: Updating chart for device '%s'", d->name?d->name:d->id);
-                rrdset_next_plugins(d->st_bytes);
+                rrdset_next(d->st_bytes);
 
                 if(unlikely(d->name_updated && d->name && strcmp(d->id, d->name) != 0)) {
                     rrdset_set_name(d->st_bytes, d->name);
@@ -367,7 +367,7 @@ static inline void tc_device_commit(struct tc_device *d) {
             }
             else {
                 debug(D_TC_LOOP, "TC: Updating _packets chart for device '%s'", d->name?d->name:d->id);
-                rrdset_next_plugins(d->st_packets);
+                rrdset_next(d->st_packets);
 
                 // FIXME
                 // update the family
@@ -421,7 +421,7 @@ static inline void tc_device_commit(struct tc_device *d) {
             }
             else {
                 debug(D_TC_LOOP, "TC: Updating _dropped chart for device '%s'", d->name?d->name:d->id);
-                rrdset_next_plugins(d->st_dropped);
+                rrdset_next(d->st_dropped);
 
                 // FIXME
                 // update the family
@@ -475,7 +475,7 @@ static inline void tc_device_commit(struct tc_device *d) {
             }
             else {
                 debug(D_TC_LOOP, "TC: Updating _tokens chart for device '%s'", d->name?d->name:d->id);
-                rrdset_next_plugins(d->st_tokens);
+                rrdset_next(d->st_tokens);
 
                 // FIXME
                 // update the family
@@ -529,7 +529,7 @@ static inline void tc_device_commit(struct tc_device *d) {
             }
             else {
                 debug(D_TC_LOOP, "TC: Updating _ctokens chart for device '%s'", d->name?d->name:d->id);
-                rrdset_next_plugins(d->st_ctokens);
+                rrdset_next(d->st_ctokens);
 
                 // FIXME
                 // update the family
index 627e18a384c6fbda2acdb197e726b48ed1cec478..6af9c21e0aad3e6790f9f40e5ed528fc42aba651 100644 (file)
@@ -189,7 +189,7 @@ void *pluginsd_worker_thread(void *arg)
                     unsigned long long microseconds = 0;
                     if(microseconds_txt && *microseconds_txt) microseconds = strtoull(microseconds_txt, NULL, 10);
                     if(microseconds) rrdset_next_usec(st, microseconds);
-                    else rrdset_next_plugins(st);
+                    else rrdset_next(st);
                 }
             }
             else if(likely(hash == END_HASH && !strcmp(s, "END"))) {
index 3330a830c3219ed9ab6f9636a6e3e2ecdf30fbe3..7ff857785edeba9cb240160b31e8e5bb766ed2e1 100644 (file)
@@ -111,7 +111,7 @@ static inline int is_mount_point_excluded(const char *mount_point) {
     for(m = excluded_mount_points; m ; m = m->next) {
         if(m->len <= len) {
             // fprintf(stderr, "SPACE: comparing '%s' with '%s'\n", mount_point, m->prefix);
-            if(strncmp(m->prefix, mount_point, m->len) == 0) {
+            if(unlikely(strncmp(m->prefix, mount_point, m->len) == 0)) {
                 // fprintf(stderr, "SPACE: excluded '%s'\n", mount_point);
                 return 1;
             }
@@ -130,6 +130,8 @@ struct mount_point_metadata {
 };
 
 static inline void do_disk_space_stats(struct disk *d, const char *mount_point, const char *mount_source, const char *disk, const char *family, int update_every, unsigned long long dt) {
+    (void)dt;
+
     static DICTIONARY *mount_points = NULL;
     int do_space, do_inodes;
 
@@ -142,11 +144,11 @@ static inline void do_disk_space_stats(struct disk *d, const char *mount_point,
         // if not the mountpoint has changed.
 
         struct stat buff_stat;
-        if(stat(mount_point, &buff_stat) == -1) {
+        if(unlikely(stat(mount_point, &buff_stat) == -1)) {
             error("Failed to stat() for '%s' (disk '%s')", mount_point, disk);
             return;
         }
-        else if(major(buff_stat.st_dev) != d->major || minor(buff_stat.st_dev) != d->minor) {
+        else if(unlikely(major(buff_stat.st_dev) != d->major || minor(buff_stat.st_dev) != d->minor)) {
             error("Disk '%s' (disk '%s') switched major:minor", mount_point, disk);
             freez(d->mount_point);
             d->mount_point = NULL;
@@ -159,14 +161,14 @@ static inline void do_disk_space_stats(struct disk *d, const char *mount_point,
     }
     else {
         struct mount_point_metadata *m = dictionary_get(mount_points, mount_point);
-        if(!m) {
+        if(unlikely(!m)) {
             char var_name[4096 + 1];
             snprintfz(var_name, 4096, "plugin:proc:/proc/diskstats:%s", mount_point);
 
             int def_space = config_get_boolean_ondemand("plugin:proc:/proc/diskstats", "space usage for all disks", CONFIG_ONDEMAND_ONDEMAND);
             int def_inodes = config_get_boolean_ondemand("plugin:proc:/proc/diskstats", "inodes usage for all disks", CONFIG_ONDEMAND_ONDEMAND);
 
-            if(is_mount_point_excluded(mount_point)) {
+            if(unlikely(is_mount_point_excluded(mount_point))) {
                 def_space = CONFIG_ONDEMAND_NO;
                 def_inodes = CONFIG_ONDEMAND_NO;
             }
@@ -187,7 +189,7 @@ static inline void do_disk_space_stats(struct disk *d, const char *mount_point,
         }
     }
 
-    if(do_space == CONFIG_ONDEMAND_NO && do_inodes == CONFIG_ONDEMAND_NO)
+    if(unlikely(do_space == CONFIG_ONDEMAND_NO && do_inodes == CONFIG_ONDEMAND_NO))
         return;
 
     struct statvfs buff_statvfs;
@@ -233,7 +235,7 @@ static inline void do_disk_space_stats(struct disk *d, const char *mount_point,
 
     if(do_space == CONFIG_ONDEMAND_YES || (do_space == CONFIG_ONDEMAND_ONDEMAND && (bavail || breserved_root || bused))) {
         st = rrdset_find_bytype("disk_space", disk);
-        if(!st) {
+        if(unlikely(!st)) {
             char title[4096 + 1];
             snprintfz(title, 4096, "Disk Space Usage for %s [%s]", family, mount_source);
             st = rrdset_create("disk_space", disk, NULL, family, "disk.space", title, "GB", 2023, update_every, RRDSET_TYPE_STACKED);
@@ -242,7 +244,7 @@ static inline void do_disk_space_stats(struct disk *d, const char *mount_point,
             rrddim_add(st, "used" , NULL, bsize, 1024*1024*1024, RRDDIM_ABSOLUTE);
             rrddim_add(st, "reserved_for_root", "reserved for root", bsize, 1024*1024*1024, RRDDIM_ABSOLUTE);
         }
-        else rrdset_next_usec(st, dt);
+        else rrdset_next(st);
 
         rrddim_set(st, "avail", bavail);
         rrddim_set(st, "used", bused);
@@ -254,7 +256,7 @@ static inline void do_disk_space_stats(struct disk *d, const char *mount_point,
 
     if(do_inodes == CONFIG_ONDEMAND_YES || (do_inodes == CONFIG_ONDEMAND_ONDEMAND && (favail || freserved_root || fused))) {
         st = rrdset_find_bytype("disk_inodes", disk);
-        if(!st) {
+        if(unlikely(!st)) {
             char title[4096 + 1];
             snprintfz(title, 4096, "Disk Files (inodes) Usage for %s [%s]", family, mount_source);
             st = rrdset_create("disk_inodes", disk, NULL, family, "disk.inodes", title, "Inodes", 2024, update_every, RRDSET_TYPE_STACKED);
@@ -263,7 +265,7 @@ static inline void do_disk_space_stats(struct disk *d, const char *mount_point,
             rrddim_add(st, "used" , NULL, 1, 1, RRDDIM_ABSOLUTE);
             rrddim_add(st, "reserved_for_root", "reserved for root", 1, 1, RRDDIM_ABSOLUTE);
         }
-        else rrdset_next_usec(st, dt);
+        else rrdset_next(st);
 
         rrddim_set(st, "avail", favail);
         rrddim_set(st, "used", fused);
@@ -303,7 +305,7 @@ static struct disk *get_disk(unsigned long major, unsigned long minor, char *dis
     d->next = NULL;
 
     // append it to the list
-    if(!disk_root)
+    if(unlikely(!disk_root))
         disk_root = d;
     else {
         struct disk *last;
@@ -325,18 +327,19 @@ static struct disk *get_disk(unsigned long major, unsigned long minor, char *dis
     // find if it is a partition
     // by checking if /sys/dev/block/MAJOR:MINOR/partition is readable.
     snprintfz(buffer, FILENAME_MAX, path_find_block_device, major, minor, "partition");
-    if(access(buffer, R_OK) == 0) {
+    if(likely(access(buffer, R_OK) == 0)) {
         d->type = DISK_TYPE_PARTITION;
-    } else {
+    }
+    else {
         // find if it is a container
         // by checking if /sys/dev/block/MAJOR:MINOR/slaves has entries
         snprintfz(buffer, FILENAME_MAX, path_find_block_device, major, minor, "slaves/");
-        DIR *dirp = opendir(buffer);    
-        if (dirp != NULL) {
+        DIR *dirp = opendir(buffer);
+        if(likely(dirp != NULL)) {
             struct dirent *dp;
             while( (dp = readdir(dirp)) ) {
                 // . and .. are also files in empty folders.
-                if(strcmp(dp->d_name, ".") == 0 || strcmp(dp->d_name, "..") == 0) {
+                if(unlikely(strcmp(dp->d_name, ".") == 0 || strcmp(dp->d_name, "..") == 0)) {
                     continue;
                 }
 
@@ -345,7 +348,7 @@ static struct disk *get_disk(unsigned long major, unsigned long minor, char *dis
                 // Stop the loop after we found one file.
                 break;
             }
-            if(closedir(dirp) == -1)
+            if(unlikely(closedir(dirp) == -1))
                 error("Unable to close dir %s", buffer);
         }
     }
@@ -362,7 +365,7 @@ static struct disk *get_disk(unsigned long major, unsigned long minor, char *dis
         mi = mountinfo_find(disk_mountinfo_root, d->major, d->minor);
     }
 */
-    if(mi) {
+    if(unlikely(mi)) {
         d->mount_point = strdupz(mi->mount_point);
         d->mount_point_hash = mi->mount_point_hash;
     }
@@ -374,11 +377,11 @@ static struct disk *get_disk(unsigned long major, unsigned long minor, char *dis
     // ------------------------------------------------------------------------
     // find the disk sector size
 
-    if(!path_to_get_hw_sector_size[0]) {
+    if(unlikely(!path_to_get_hw_sector_size[0])) {
         snprintfz(buffer, FILENAME_MAX, "%s%s", global_host_prefix, "/sys/block/%s/queue/hw_sector_size");
         snprintfz(path_to_get_hw_sector_size, FILENAME_MAX, "%s", config_get("plugin:proc:/proc/diskstats", "path to get h/w sector size", buffer));
     }
-    if(!path_to_get_hw_sector_size_partitions[0]) {
+    if(unlikely(!path_to_get_hw_sector_size_partitions[0])) {
         snprintfz(buffer, FILENAME_MAX, "%s%s", global_host_prefix, "/sys/dev/block/%lu:%lu/subsystem/%s/../queue/hw_sector_size");
         snprintfz(path_to_get_hw_sector_size_partitions, FILENAME_MAX, "%s", config_get("plugin:proc:/proc/diskstats", "path to get h/w sector size for partitions", buffer));
     }
@@ -389,21 +392,21 @@ static struct disk *get_disk(unsigned long major, unsigned long minor, char *dis
 
         // replace all / with !
         for(t = tf; *t ;t++)
-            if(*t == '/') *t = '!';
+            if(unlikely(*t == '/')) *t = '!';
 
-        if(d->type == DISK_TYPE_PARTITION)
+        if(likely(d->type == DISK_TYPE_PARTITION))
             snprintfz(buffer, FILENAME_MAX, path_to_get_hw_sector_size_partitions, d->major, d->minor, tf);
         else
             snprintfz(buffer, FILENAME_MAX, path_to_get_hw_sector_size, tf);
 
         FILE *fpss = fopen(buffer, "r");
-        if(fpss) {
+        if(likely(fpss)) {
             char buffer2[1024 + 1];
             char *tmp = fgets(buffer2, 1024, fpss);
 
-            if(tmp) {
+            if(likely(tmp)) {
                 d->sector_size = atoi(tmp);
-                if(d->sector_size <= 0) {
+                if(unlikely(d->sector_size <= 0)) {
                     error("Invalid sector size %d for device %s in %s. Assuming 512.", d->sector_size, d->disk, buffer);
                     d->sector_size = 512;
                 }
@@ -419,15 +422,17 @@ static struct disk *get_disk(unsigned long major, unsigned long minor, char *dis
 }
 
 static inline int select_positive_option(int option1, int option2) {
-    if(option1 == CONFIG_ONDEMAND_YES || option2 == CONFIG_ONDEMAND_YES)
+    if(unlikely(option1 == CONFIG_ONDEMAND_YES || option2 == CONFIG_ONDEMAND_YES))
         return CONFIG_ONDEMAND_YES;
-    else if(option1 == CONFIG_ONDEMAND_ONDEMAND || option2 == CONFIG_ONDEMAND_ONDEMAND)
+    else if(unlikely(option1 == CONFIG_ONDEMAND_ONDEMAND || option2 == CONFIG_ONDEMAND_ONDEMAND))
         return CONFIG_ONDEMAND_ONDEMAND;
 
     return CONFIG_ONDEMAND_NO;
 }
 
 int do_proc_diskstats(int update_every, unsigned long long dt) {
+    (void)dt;
+
     static procfile *ff = NULL;
     static int  global_enable_new_disks_detected_at_runtime = CONFIG_ONDEMAND_YES,
                 global_enable_performance_for_physical_disks = CONFIG_ONDEMAND_ONDEMAND,
@@ -464,15 +469,15 @@ int do_proc_diskstats(int update_every, unsigned long long dt) {
         globals_initialized = 1;
     }
 
-    if(!ff) {
+    if(unlikely(!ff)) {
         char filename[FILENAME_MAX + 1];
         snprintfz(filename, FILENAME_MAX, "%s%s", global_host_prefix, "/proc/diskstats");
         ff = procfile_open(config_get("plugin:proc:/proc/diskstats", "filename to monitor", filename), " \t", PROCFILE_FLAG_DEFAULT);
     }
-    if(!ff) return 1;
+    if(unlikely(!ff)) return 1;
 
     ff = procfile_readall(ff);
-    if(!ff) return 0; // we return 0, so that we will retry to open it next time
+    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;
@@ -496,7 +501,7 @@ int do_proc_diskstats(int update_every, unsigned long long dt) {
                             last_busy_ms = 0;
 
         words = procfile_linewords(ff, l);
-        if(words < 14) continue;
+        if(unlikely(words < 14)) continue;
 
         major           = strtoul(procfile_lineword(ff, l, 0), NULL, 10);
         minor           = strtoul(procfile_lineword(ff, l, 1), NULL, 10);
@@ -570,7 +575,7 @@ int do_proc_diskstats(int update_every, unsigned long long dt) {
             snprintfz(var_name, 4096, "plugin:proc:/proc/diskstats:%s", disk);
 
             int def_enable = config_get_boolean_ondemand(var_name, "enable", global_enable_new_disks_detected_at_runtime);
-            if(def_enable == CONFIG_ONDEMAND_NO) {
+            if(unlikely(def_enable == CONFIG_ONDEMAND_NO)) {
                 // the user does not want any metrics for this disk
                 d->do_io = CONFIG_ONDEMAND_NO;
                 d->do_ops = CONFIG_ONDEMAND_NO;
@@ -629,7 +634,7 @@ int do_proc_diskstats(int update_every, unsigned long long dt) {
                     ddo_backlog = CONFIG_ONDEMAND_NO;
 
                 // we enable individual performance charts only when def_performance is not disabled
-                if(def_performance != CONFIG_ONDEMAND_NO) {
+                if(unlikely(def_performance != CONFIG_ONDEMAND_NO)) {
                     ddo_io = global_do_io,
                     ddo_ops = global_do_ops,
                     ddo_mops = global_do_mops,
@@ -648,7 +653,7 @@ int do_proc_diskstats(int update_every, unsigned long long dt) {
                 d->do_backlog = config_get_boolean_ondemand(var_name, "backlog", ddo_backlog);
 
                 // def_space
-                if(d->mount_point) {
+                if(unlikely(d->mount_point)) {
                     // check the user configuration (this will also show our 'on demand' decision)
                     def_space = config_get_boolean_ondemand(var_name, "enable space metrics", def_space);
 
@@ -677,13 +682,13 @@ int do_proc_diskstats(int update_every, unsigned long long dt) {
             d->do_io = CONFIG_ONDEMAND_YES;
 
             st = rrdset_find_bytype(RRD_TYPE_DISK, disk);
-            if(!st) {
+            if(unlikely(!st)) {
                 st = rrdset_create(RRD_TYPE_DISK, disk, NULL, family, "disk.io", "Disk I/O Bandwidth", "kilobytes/s", 2000, update_every, RRDSET_TYPE_AREA);
 
                 rrddim_add(st, "reads", NULL, d->sector_size, 1024, RRDDIM_INCREMENTAL);
                 rrddim_add(st, "writes", NULL, d->sector_size * -1, 1024, RRDDIM_INCREMENTAL);
             }
-            else rrdset_next_usec(st, dt);
+            else rrdset_next(st);
 
             last_readsectors  = rrddim_set(st, "reads", readsectors);
             last_writesectors = rrddim_set(st, "writes", writesectors);
@@ -696,14 +701,14 @@ int do_proc_diskstats(int update_every, unsigned long long dt) {
             d->do_ops = CONFIG_ONDEMAND_YES;
 
             st = rrdset_find_bytype("disk_ops", disk);
-            if(!st) {
+            if(unlikely(!st)) {
                 st = rrdset_create("disk_ops", disk, NULL, family, "disk.ops", "Disk Completed I/O Operations", "operations/s", 2001, update_every, RRDSET_TYPE_LINE);
                 st->isdetail = 1;
 
                 rrddim_add(st, "reads", NULL, 1, 1, RRDDIM_INCREMENTAL);
                 rrddim_add(st, "writes", NULL, -1, 1, RRDDIM_INCREMENTAL);
             }
-            else rrdset_next_usec(st, dt);
+            else rrdset_next(st);
 
             last_reads  = rrddim_set(st, "reads", reads);
             last_writes = rrddim_set(st, "writes", writes);
@@ -716,13 +721,13 @@ int do_proc_diskstats(int update_every, unsigned long long dt) {
             d->do_qops = CONFIG_ONDEMAND_YES;
 
             st = rrdset_find_bytype("disk_qops", disk);
-            if(!st) {
+            if(unlikely(!st)) {
                 st = rrdset_create("disk_qops", disk, NULL, family, "disk.qops", "Disk Current I/O Operations", "operations", 2002, update_every, RRDSET_TYPE_LINE);
                 st->isdetail = 1;
 
                 rrddim_add(st, "operations", NULL, 1, 1, RRDDIM_ABSOLUTE);
             }
-            else rrdset_next_usec(st, dt);
+            else rrdset_next(st);
 
             rrddim_set(st, "operations", queued_ios);
             rrdset_done(st);
@@ -734,13 +739,13 @@ int do_proc_diskstats(int update_every, unsigned long long dt) {
             d->do_backlog = CONFIG_ONDEMAND_YES;
 
             st = rrdset_find_bytype("disk_backlog", disk);
-            if(!st) {
+            if(unlikely(!st)) {
                 st = rrdset_create("disk_backlog", disk, NULL, family, "disk.backlog", "Disk Backlog", "backlog (ms)", 2003, update_every, RRDSET_TYPE_AREA);
                 st->isdetail = 1;
 
                 rrddim_add(st, "backlog", NULL, 1, 10, RRDDIM_INCREMENTAL);
             }
-            else rrdset_next_usec(st, dt);
+            else rrdset_next(st);
 
             rrddim_set(st, "backlog", backlog_ms);
             rrdset_done(st);
@@ -752,13 +757,13 @@ int do_proc_diskstats(int update_every, unsigned long long dt) {
             d->do_util = CONFIG_ONDEMAND_YES;
 
             st = rrdset_find_bytype("disk_util", disk);
-            if(!st) {
+            if(unlikely(!st)) {
                 st = rrdset_create("disk_util", disk, NULL, family, "disk.util", "Disk Utilization Time", "% of time working", 2004, update_every, RRDSET_TYPE_AREA);
                 st->isdetail = 1;
 
                 rrddim_add(st, "utilization", NULL, 1, 10, RRDDIM_INCREMENTAL);
             }
-            else rrdset_next_usec(st, dt);
+            else rrdset_next(st);
 
             last_busy_ms = rrddim_set(st, "utilization", busy_ms);
             rrdset_done(st);
@@ -770,14 +775,14 @@ int do_proc_diskstats(int update_every, unsigned long long dt) {
             d->do_mops = CONFIG_ONDEMAND_YES;
 
             st = rrdset_find_bytype("disk_mops", disk);
-            if(!st) {
+            if(unlikely(!st)) {
                 st = rrdset_create("disk_mops", disk, NULL, family, "disk.mops", "Disk Merged Operations", "merged operations/s", 2021, update_every, RRDSET_TYPE_LINE);
                 st->isdetail = 1;
 
                 rrddim_add(st, "reads", NULL, 1, 1, RRDDIM_INCREMENTAL);
                 rrddim_add(st, "writes", NULL, -1, 1, RRDDIM_INCREMENTAL);
             }
-            else rrdset_next_usec(st, dt);
+            else rrdset_next(st);
 
             rrddim_set(st, "reads", mreads);
             rrddim_set(st, "writes", mwrites);
@@ -790,14 +795,14 @@ int do_proc_diskstats(int update_every, unsigned long long dt) {
             d->do_iotime = CONFIG_ONDEMAND_YES;
 
             st = rrdset_find_bytype("disk_iotime", disk);
-            if(!st) {
+            if(unlikely(!st)) {
                 st = rrdset_create("disk_iotime", disk, NULL, family, "disk.iotime", "Disk Total I/O Time", "milliseconds/s", 2022, update_every, RRDSET_TYPE_LINE);
                 st->isdetail = 1;
 
                 rrddim_add(st, "reads", NULL, 1, 1, RRDDIM_INCREMENTAL);
                 rrddim_add(st, "writes", NULL, -1, 1, RRDDIM_INCREMENTAL);
             }
-            else rrdset_next_usec(st, dt);
+            else rrdset_next(st);
 
             last_readms  = rrddim_set(st, "reads", readms);
             last_writems = rrddim_set(st, "writes", writems);
@@ -808,18 +813,18 @@ int do_proc_diskstats(int update_every, unsigned long long dt) {
         // calculate differential charts
         // only if this is not the first time we run
 
-        if(dt) {
+        if(likely(dt)) {
             if( (d->do_iotime == CONFIG_ONDEMAND_YES || (d->do_iotime == CONFIG_ONDEMAND_ONDEMAND && (readms || writems))) &&
                 (d->do_ops    == CONFIG_ONDEMAND_YES || (d->do_ops    == CONFIG_ONDEMAND_ONDEMAND && (reads || writes)))) {
                 st = rrdset_find_bytype("disk_await", disk);
-                if(!st) {
+                if(unlikely(!st)) {
                     st = rrdset_create("disk_await", disk, NULL, family, "disk.await", "Average Completed I/O Operation Time", "ms per operation", 2005, update_every, RRDSET_TYPE_LINE);
                     st->isdetail = 1;
 
                     rrddim_add(st, "reads", NULL, 1, 1, RRDDIM_ABSOLUTE);
                     rrddim_add(st, "writes", NULL, -1, 1, RRDDIM_ABSOLUTE);
                 }
-                else rrdset_next_usec(st, dt);
+                else rrdset_next(st);
 
                 rrddim_set(st, "reads", (reads - last_reads) ? (readms - last_readms) / (reads - last_reads) : 0);
                 rrddim_set(st, "writes", (writes - last_writes) ? (writems - last_writems) / (writes - last_writes) : 0);
@@ -829,14 +834,14 @@ int do_proc_diskstats(int update_every, unsigned long long dt) {
             if( (d->do_io  == CONFIG_ONDEMAND_YES || (d->do_io  == CONFIG_ONDEMAND_ONDEMAND && (readsectors || writesectors))) &&
                 (d->do_ops == CONFIG_ONDEMAND_YES || (d->do_ops == CONFIG_ONDEMAND_ONDEMAND && (reads || writes)))) {
                 st = rrdset_find_bytype("disk_avgsz", disk);
-                if(!st) {
+                if(unlikely(!st)) {
                     st = rrdset_create("disk_avgsz", disk, NULL, family, "disk.avgsz", "Average Completed I/O Operation Bandwidth", "kilobytes per operation", 2006, update_every, RRDSET_TYPE_AREA);
                     st->isdetail = 1;
 
                     rrddim_add(st, "reads", NULL, d->sector_size, 1024, RRDDIM_ABSOLUTE);
                     rrddim_add(st, "writes", NULL, d->sector_size * -1, 1024, RRDDIM_ABSOLUTE);
                 }
-                else rrdset_next_usec(st, dt);
+                else rrdset_next(st);
 
                 rrddim_set(st, "reads", (reads - last_reads) ? (readsectors - last_readsectors) / (reads - last_reads) : 0);
                 rrddim_set(st, "writes", (writes - last_writes) ? (writesectors - last_writesectors) / (writes - last_writes) : 0);
@@ -846,13 +851,13 @@ int do_proc_diskstats(int update_every, unsigned long long dt) {
             if( (d->do_util == CONFIG_ONDEMAND_YES || (d->do_util == CONFIG_ONDEMAND_ONDEMAND && busy_ms)) &&
                 (d->do_ops  == CONFIG_ONDEMAND_YES || (d->do_ops  == CONFIG_ONDEMAND_ONDEMAND && (reads || writes)))) {
                 st = rrdset_find_bytype("disk_svctm", disk);
-                if(!st) {
+                if(unlikely(!st)) {
                     st = rrdset_create("disk_svctm", disk, NULL, family, "disk.svctm", "Average Service Time", "ms per operation", 2007, update_every, RRDSET_TYPE_LINE);
                     st->isdetail = 1;
 
                     rrddim_add(st, "svctm", NULL, 1, 1, RRDDIM_ABSOLUTE);
                 }
-                else rrdset_next_usec(st, dt);
+                else rrdset_next(st);
 
                 rrddim_set(st, "svctm", ((reads - last_reads) + (writes - last_writes)) ? (busy_ms - last_busy_ms) / ((reads - last_reads) + (writes - last_writes)) : 0);
                 rrdset_done(st);
@@ -863,7 +868,7 @@ int do_proc_diskstats(int update_every, unsigned long long dt) {
         // --------------------------------------------------------------------------
         // space metrics
 
-        if(d->mount_point && (d->do_space || d->do_inodes) ) {
+        if(unlikely( d->mount_point && (d->do_space || d->do_inodes) )) {
             do_disk_space_stats(d, d->mount_point, disk, disk, family, update_every, dt);
         }
 */
index f277a5a905b774e5b4ba169d69814122bf346b32..c652693a7273af4174dc43264e559c04c224d787 100644 (file)
@@ -21,7 +21,7 @@ static inline struct interrupt *get_interrupts_array(int lines, int cpus) {
     static struct interrupt *irrs = NULL;
     static int allocated = 0;
 
-    if(lines > allocated) {
+    if(unlikely(lines > allocated)) {
         irrs = (struct interrupt *)reallocz(irrs, lines * recordsize(cpus));
         allocated = lines;
     }
@@ -30,42 +30,45 @@ static inline struct interrupt *get_interrupts_array(int lines, int cpus) {
 }
 
 int do_proc_interrupts(int update_every, unsigned long long dt) {
+    (void)dt;
+
     static procfile *ff = NULL;
     static int cpus = -1, do_per_core = -1;
     struct interrupt *irrs = NULL;
 
-    if(dt) {};
-
-    if(do_per_core == -1) do_per_core = config_get_boolean("plugin:proc:/proc/interrupts", "interrupts per core", 1);
+    if(unlikely(do_per_core == -1))
+        do_per_core = config_get_boolean("plugin:proc:/proc/interrupts", "interrupts per core", 1);
 
-    if(!ff) {
+    if(unlikely(!ff)) {
         char filename[FILENAME_MAX + 1];
         snprintfz(filename, FILENAME_MAX, "%s%s", global_host_prefix, "/proc/interrupts");
         ff = procfile_open(config_get("plugin:proc:/proc/interrupts", "filename to monitor", filename), " \t", PROCFILE_FLAG_DEFAULT);
     }
-    if(!ff) return 1;
+    if(unlikely(!ff))
+        return 1;
 
     ff = procfile_readall(ff);
-    if(!ff) return 0; // we return 0, so that we will retry to open it next time
+    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), w;
 
-    if(!lines) {
+    if(unlikely(!lines)) {
         error("Cannot read /proc/interrupts, zero lines reported.");
         return 1;
     }
 
     // find how many CPUs are there
-    if(cpus == -1) {
+    if(unlikely(cpus == -1)) {
         cpus = 0;
         for(w = 0; w < words ; w++) {
-            if(strncmp(procfile_lineword(ff, 0, w), "CPU", 3) == 0)
+            if(unlikely(strncmp(procfile_lineword(ff, 0, w), "CPU", 3) == 0))
                 cpus++;
         }
     }
 
-    if(!cpus) {
+    if(unlikely(!cpus)) {
         error("PLUGIN: PROC_INTERRUPTS: Cannot find the number of CPUs in /proc/interrupts");
         return 1;
     }
@@ -81,18 +84,18 @@ int do_proc_interrupts(int update_every, unsigned long long dt) {
         irr->total = 0;
 
         words = procfile_linewords(ff, l);
-        if(!words) continue;
+        if(unlikely(!words)) continue;
 
         irr->id = procfile_lineword(ff, l, 0);
-        if(!irr->id || !irr->id[0]) continue;
+        if(unlikely(!irr->id || !irr->id[0])) continue;
 
         int idlen = strlen(irr->id);
-        if(irr->id[idlen - 1] == ':')
+        if(unlikely(irr->id[idlen - 1] == ':'))
             irr->id[idlen - 1] = '\0';
 
         int c;
         for(c = 0; c < cpus ;c++) {
-            if((c + 1) < (int)words)
+            if(unlikely((c + 1) < (int)words))
                 irr->value[c] = strtoull(procfile_lineword(ff, l, (uint32_t)(c + 1)), NULL, 10);
             else
                 irr->value[c] = 0;
@@ -100,10 +103,10 @@ int do_proc_interrupts(int update_every, unsigned long long dt) {
             irr->total += irr->value[c];
         }
 
-        if(isdigit(irr->id[0]) && (uint32_t)(cpus + 2) < words) {
+        if(unlikely(isdigit(irr->id[0]) && (uint32_t)(cpus + 2) < words)) {
             strncpyz(irr->name, procfile_lineword(ff, l, words - 1), MAX_INTERRUPT_NAME);
             int nlen = strlen(irr->name);
-            if(nlen < (MAX_INTERRUPT_NAME-1)) {
+            if(unlikely(nlen < (MAX_INTERRUPT_NAME-1))) {
                 irr->name[nlen] = '_';
                 strncpyz(&irr->name[nlen + 1], irr->id, MAX_INTERRUPT_NAME - nlen);
             }
@@ -120,12 +123,12 @@ int do_proc_interrupts(int update_every, unsigned long long dt) {
     // --------------------------------------------------------------------
 
     st = rrdset_find_bytype("system", "interrupts");
-    if(!st) {
+    if(unlikely(!st)) {
         st = rrdset_create("system", "interrupts", NULL, "interrupts", NULL, "System interrupts", "interrupts/s", 1000, update_every, RRDSET_TYPE_STACKED);
 
         for(l = 0; l < lines ;l++) {
             struct interrupt *irr = irrindex(irrs, l, cpus);
-            if(!irr->used) continue;
+            if(unlikely(!irr->used)) continue;
             rrddim_add(st, irr->id, irr->name, 1, 1, RRDDIM_INCREMENTAL);
         }
     }
@@ -133,12 +136,12 @@ int do_proc_interrupts(int update_every, unsigned long long dt) {
 
     for(l = 0; l < lines ;l++) {
         struct interrupt *irr = irrindex(irrs, l, cpus);
-        if(!irr->used) continue;
+        if(unlikely(!irr->used)) continue;
         rrddim_set(st, irr->id, irr->total);
     }
     rrdset_done(st);
 
-    if(do_per_core) {
+    if(likely(do_per_core)) {
         int c;
 
         for(c = 0; c < cpus ; c++) {
@@ -146,14 +149,14 @@ int do_proc_interrupts(int update_every, unsigned long long dt) {
             snprintfz(id, 50, "cpu%d_interrupts", c);
 
             st = rrdset_find_bytype("cpu", id);
-            if(!st) {
+            if(unlikely(!st)) {
                 char title[100+1];
                 snprintfz(title, 100, "CPU%d Interrupts", c);
                 st = rrdset_create("cpu", id, NULL, "interrupts", "cpu.interrupts", title, "interrupts/s", 1100 + c, update_every, RRDSET_TYPE_STACKED);
 
                 for(l = 0; l < lines ;l++) {
                     struct interrupt *irr = irrindex(irrs, l, cpus);
-                    if(!irr->used) continue;
+                    if(unlikely(!irr->used)) continue;
                     rrddim_add(st, irr->id, irr->name, 1, 1, RRDDIM_INCREMENTAL);
                 }
             }
@@ -161,7 +164,7 @@ int do_proc_interrupts(int update_every, unsigned long long dt) {
 
             for(l = 0; l < lines ;l++) {
                 struct interrupt *irr = irrindex(irrs, l, cpus);
-                if(!irr->used) continue;
+                if(unlikely(!irr->used)) continue;
                 rrddim_set(st, irr->id, irr->value[c]);
             }
             rrdset_done(st);
index 44ea70191ee43a2244d1155d3f5d44967637cc5e..3e97dcdb6498e2cb4853ddfb4b15cb600e872e5f 100644 (file)
@@ -4,29 +4,31 @@
 #define MIN_LOADAVG_UPDATE_EVERY 5
 
 int do_proc_loadavg(int update_every, unsigned long long dt) {
+    (void)dt;
+
     static procfile *ff = NULL;
     static int do_loadavg = -1, do_all_processes = -1;
 
-    if(dt) {};
-
-    if(!ff) {
+    if(unlikely(!ff)) {
         char filename[FILENAME_MAX + 1];
         snprintfz(filename, FILENAME_MAX, "%s%s", global_host_prefix, "/proc/loadavg");
         ff = procfile_open(config_get("plugin:proc:/proc/loadavg", "filename to monitor", filename), " \t,:|/", PROCFILE_FLAG_DEFAULT);
     }
-    if(!ff) return 1;
+    if(unlikely(!ff))
+        return 1;
 
     ff = procfile_readall(ff);
-    if(!ff) return 0; // we return 0, so that we will retry to open it next time
+    if(unlikely(!ff))
+        return 0; // we return 0, so that we will retry to open it next time
 
-    if(do_loadavg == -1)        do_loadavg          = config_get_boolean("plugin:proc:/proc/loadavg", "enable load average", 1);
-    if(do_all_processes == -1)  do_all_processes    = config_get_boolean("plugin:proc:/proc/loadavg", "enable total processes", 1);
+    if(unlikely(do_loadavg == -1))        do_loadavg          = config_get_boolean("plugin:proc:/proc/loadavg", "enable load average", 1);
+    if(unlikely(do_all_processes == -1))  do_all_processes    = config_get_boolean("plugin:proc:/proc/loadavg", "enable total processes", 1);
 
-    if(procfile_lines(ff) < 1) {
+    if(unlikely(procfile_lines(ff) < 1)) {
         error("/proc/loadavg has no lines.");
         return 1;
     }
-    if(procfile_linewords(ff, 0) < 6) {
+    if(unlikely(procfile_linewords(ff, 0) < 6)) {
         error("/proc/loadavg has less than 6 words in it.");
         return 1;
     }
@@ -44,9 +46,9 @@ int do_proc_loadavg(int update_every, unsigned long long dt) {
 
     // --------------------------------------------------------------------
 
-    if(do_loadavg) {
+    if(likely(do_loadavg)) {
         st = rrdset_find_byname("system.load");
-        if(!st) {
+        if(unlikely(!st)) {
             st = rrdset_create("system", "load", NULL, "load", NULL, "System Load Average", "load", 100, (update_every < MIN_LOADAVG_UPDATE_EVERY)?MIN_LOADAVG_UPDATE_EVERY:update_every, RRDSET_TYPE_LINE);
 
             rrddim_add(st, "load1", NULL, 1, 1000, RRDDIM_ABSOLUTE);
@@ -55,17 +57,17 @@ int do_proc_loadavg(int update_every, unsigned long long dt) {
         }
         else rrdset_next(st);
 
-        rrddim_set(st, "load1", load1 * 1000);
-        rrddim_set(st, "load5", load5 * 1000);
-        rrddim_set(st, "load15", load15 * 1000);
+        rrddim_set(st, "load1", (collected_number)(load1 * 1000));
+        rrddim_set(st, "load5", (collected_number)(load5 * 1000));
+        rrddim_set(st, "load15", (collected_number)(load15 * 1000));
         rrdset_done(st);
     }
 
     // --------------------------------------------------------------------
 
-    if(do_all_processes) {
+    if(likely(do_all_processes)) {
         st = rrdset_find_byname("system.active_processes");
-        if(!st) {
+        if(unlikely(!st)) {
             st = rrdset_create("system", "active_processes", NULL, "processes", NULL, "System Active Processes", "processes", 750, update_every, RRDSET_TYPE_LINE);
 
             rrddim_add(st, "active", NULL, 1, 1, RRDDIM_ABSOLUTE);
index 999c9538dc59b64308fa83cad04bddc2872a30b8..0e5e14fd20e9d91b0015718a2552cac69fb812cf 100644 (file)
 #include "common.h"
 
-#define MAX_PROC_MEMINFO_LINE 4096
-#define MAX_PROC_MEMINFO_NAME 1024
-
 int do_proc_meminfo(int update_every, unsigned long long dt) {
-    static procfile *ff = NULL;
+    (void)dt;
 
+    static procfile *ff = NULL;
     static int do_ram = -1, do_swap = -1, do_hwcorrupt = -1, do_committed = -1, do_writeback = -1, do_kernel = -1, do_slab = -1;
+    static uint32_t MemTotal_hash = 0,
+            MemFree_hash = 0,
+            Buffers_hash = 0,
+            Cached_hash = 0,
+            //SwapCached_hash = 0,
+            //Active_hash = 0,
+            //Inactive_hash = 0,
+            //ActiveAnon_hash = 0,
+            //InactiveAnon_hash = 0,
+            //ActiveFile_hash = 0,
+            //InactiveFile_hash = 0,
+            //Unevictable_hash = 0,
+            //Mlocked_hash = 0,
+            SwapTotal_hash = 0,
+            SwapFree_hash = 0,
+            Dirty_hash = 0,
+            Writeback_hash = 0,
+            //AnonPages_hash = 0,
+            //Mapped_hash = 0,
+            //Shmem_hash = 0,
+            Slab_hash = 0,
+            SReclaimable_hash = 0,
+            SUnreclaim_hash = 0,
+            KernelStack_hash = 0,
+            PageTables_hash = 0,
+            NFS_Unstable_hash = 0,
+            Bounce_hash = 0,
+            WritebackTmp_hash = 0,
+            //CommitLimit_hash = 0,
+            Committed_AS_hash = 0,
+            //VmallocTotal_hash = 0,
+            VmallocUsed_hash = 0,
+            //VmallocChunk_hash = 0,
+            //AnonHugePages_hash = 0,
+            //HugePages_Total_hash = 0,
+            //HugePages_Free_hash = 0,
+            //HugePages_Rsvd_hash = 0,
+            //HugePages_Surp_hash = 0,
+            //Hugepagesize_hash = 0,
+            //DirectMap4k_hash = 0,
+            //DirectMap2M_hash = 0,
+            HardwareCorrupted_hash = 0;
+
+    if(unlikely(do_ram == -1)) {
+        do_ram          = config_get_boolean("plugin:proc:/proc/meminfo", "system ram", 1);
+        do_swap         = config_get_boolean_ondemand("plugin:proc:/proc/meminfo", "system swap", CONFIG_ONDEMAND_ONDEMAND);
+        do_hwcorrupt    = config_get_boolean_ondemand("plugin:proc:/proc/meminfo", "hardware corrupted ECC", CONFIG_ONDEMAND_ONDEMAND);
+        do_committed    = config_get_boolean("plugin:proc:/proc/meminfo", "committed memory", 1);
+        do_writeback    = config_get_boolean("plugin:proc:/proc/meminfo", "writeback memory", 1);
+        do_kernel       = config_get_boolean("plugin:proc:/proc/meminfo", "kernel memory", 1);
+        do_slab         = config_get_boolean("plugin:proc:/proc/meminfo", "slab memory", 1);
+
+        MemTotal_hash = simple_hash("MemTotal");
+        MemFree_hash = simple_hash("MemFree");
+        Buffers_hash = simple_hash("Buffers");
+        Cached_hash = simple_hash("Cached");
+        //SwapCached_hash = simple_hash("SwapCached");
+        //Active_hash = simple_hash("Active");
+        //Inactive_hash = simple_hash("Inactive");
+        //ActiveAnon_hash = simple_hash("ActiveAnon");
+        //InactiveAnon_hash = simple_hash("InactiveAnon");
+        //ActiveFile_hash = simple_hash("ActiveFile");
+        //InactiveFile_hash = simple_hash("InactiveFile");
+        //Unevictable_hash = simple_hash("Unevictable");
+        //Mlocked_hash = simple_hash("Mlocked");
+        SwapTotal_hash = simple_hash("SwapTotal");
+        SwapFree_hash = simple_hash("SwapFree");
+        Dirty_hash = simple_hash("Dirty");
+        Writeback_hash = simple_hash("Writeback");
+        //AnonPages_hash = simple_hash("AnonPages");
+        //Mapped_hash = simple_hash("Mapped");
+        //Shmem_hash = simple_hash("Shmem");
+        Slab_hash = simple_hash("Slab");
+        SReclaimable_hash = simple_hash("SReclaimable");
+        SUnreclaim_hash = simple_hash("SUnreclaim");
+        KernelStack_hash = simple_hash("KernelStack");
+        PageTables_hash = simple_hash("PageTables");
+        NFS_Unstable_hash = simple_hash("NFS_Unstable");
+        Bounce_hash = simple_hash("Bounce");
+        WritebackTmp_hash = simple_hash("WritebackTmp");
+        //CommitLimit_hash = simple_hash("CommitLimit");
+        Committed_AS_hash = simple_hash("Committed_AS");
+        //VmallocTotal_hash = simple_hash("VmallocTotal");
+        VmallocUsed_hash = simple_hash("VmallocUsed");
+        //VmallocChunk_hash = simple_hash("VmallocChunk");
+        HardwareCorrupted_hash = simple_hash("HardwareCorrupted");
+        //AnonHugePages_hash = simple_hash("AnonHugePages");
+        //HugePages_Total_hash = simple_hash("HugePages_Total");
+        //HugePages_Free_hash = simple_hash("HugePages_Free");
+        //HugePages_Rsvd_hash = simple_hash("HugePages_Rsvd");
+        //HugePages_Surp_hash = simple_hash("HugePages_Surp");
+        //Hugepagesize_hash = simple_hash("Hugepagesize");
+        //DirectMap4k_hash = simple_hash("DirectMap4k");
+        //DirectMap2M_hash = simple_hash("DirectMap2M");
+    }
 
-    if(do_ram == -1)        do_ram          = config_get_boolean("plugin:proc:/proc/meminfo", "system ram", 1);
-    if(do_swap == -1)       do_swap         = config_get_boolean_ondemand("plugin:proc:/proc/meminfo", "system swap", CONFIG_ONDEMAND_ONDEMAND);
-    if(do_hwcorrupt == -1)  do_hwcorrupt    = config_get_boolean_ondemand("plugin:proc:/proc/meminfo", "hardware corrupted ECC", CONFIG_ONDEMAND_ONDEMAND);
-    if(do_committed == -1)  do_committed    = config_get_boolean("plugin:proc:/proc/meminfo", "committed memory", 1);
-    if(do_writeback == -1)  do_writeback    = config_get_boolean("plugin:proc:/proc/meminfo", "writeback memory", 1);
-    if(do_kernel == -1)     do_kernel       = config_get_boolean("plugin:proc:/proc/meminfo", "kernel memory", 1);
-    if(do_slab == -1)       do_slab         = config_get_boolean("plugin:proc:/proc/meminfo", "slab memory", 1);
-
-    (void)dt;
-
-    if(!ff) {
+    if(unlikely(!ff)) {
         char filename[FILENAME_MAX + 1];
         snprintfz(filename, FILENAME_MAX, "%s%s", global_host_prefix, "/proc/meminfo");
         ff = procfile_open(config_get("plugin:proc:/proc/meminfo", "filename to monitor", filename), " \t:", PROCFILE_FLAG_DEFAULT);
+        if(unlikely(!ff))
+            return 1;
     }
-    if(!ff) return 1;
 
     ff = procfile_readall(ff);
-    if(!ff) return 0; // we return 0, so that we will retry to open it next time
+    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;
 
     int hwcorrupted = 0;
 
-    unsigned long long MemTotal = 0, MemFree = 0, Buffers = 0, Cached = 0, SwapCached = 0,
-        Active = 0, Inactive = 0, ActiveAnon = 0, InactiveAnon = 0, ActiveFile = 0, InactiveFile = 0,
-        Unevictable = 0, Mlocked = 0, SwapTotal = 0, SwapFree = 0, Dirty = 0, Writeback = 0, AnonPages = 0,
-        Mapped = 0, Shmem = 0, Slab = 0, SReclaimable = 0, SUnreclaim = 0, KernelStack = 0, PageTables = 0,
-        NFS_Unstable = 0, Bounce = 0, WritebackTmp = 0, CommitLimit = 0, Committed_AS = 0,
-        VmallocTotal = 0, VmallocUsed = 0, VmallocChunk = 0,
-        AnonHugePages = 0, HugePages_Total = 0, HugePages_Free = 0, HugePages_Rsvd = 0, HugePages_Surp = 0, Hugepagesize = 0,
-        DirectMap4k = 0, DirectMap2M = 0, HardwareCorrupted = 0;
+    unsigned long long MemTotal = 0,
+            MemFree = 0,
+            Buffers = 0,
+            Cached = 0,
+            //SwapCached = 0,
+            //Active = 0,
+            //Inactive = 0,
+            //ActiveAnon = 0,
+            //InactiveAnon = 0,
+            //ActiveFile = 0,
+            //InactiveFile = 0,
+            //Unevictable = 0,
+            //Mlocked = 0,
+            SwapTotal = 0,
+            SwapFree = 0,
+            Dirty = 0,
+            Writeback = 0,
+            //AnonPages = 0,
+            //Mapped = 0,
+            //Shmem = 0,
+            Slab = 0,
+            SReclaimable = 0,
+            SUnreclaim = 0,
+            KernelStack = 0,
+            PageTables = 0,
+            NFS_Unstable = 0,
+            Bounce = 0,
+            WritebackTmp = 0,
+            //CommitLimit = 0,
+            Committed_AS = 0,
+            //VmallocTotal = 0,
+            VmallocUsed = 0,
+            //VmallocChunk = 0,
+            //AnonHugePages = 0,
+            //HugePages_Total = 0,
+            //HugePages_Free = 0,
+            //HugePages_Rsvd = 0,
+            //HugePages_Surp = 0,
+            //Hugepagesize = 0,
+            //DirectMap4k = 0,
+            //DirectMap2M = 0,
+            HardwareCorrupted = 0;
 
     for(l = 0; l < lines ;l++) {
         words = procfile_linewords(ff, l);
-        if(words < 2) continue;
+        if(unlikely(words < 2)) continue;
 
         char *name = procfile_lineword(ff, l, 0);
+        uint32_t hash = simple_hash(name);
         unsigned long long value = strtoull(procfile_lineword(ff, l, 1), NULL, 10);
 
-             if(!MemTotal && strcmp(name, "MemTotal") == 0) MemTotal = value;
-        else if(!MemFree && strcmp(name, "MemFree") == 0) MemFree = value;
-        else if(!Buffers && strcmp(name, "Buffers") == 0) Buffers = value;
-        else if(!Cached && strcmp(name, "Cached") == 0) Cached = value;
-        else if(!SwapCached && strcmp(name, "SwapCached") == 0) SwapCached = value;
-        else if(!Active && strcmp(name, "Active") == 0) Active = value;
-        else if(!Inactive && strcmp(name, "Inactive") == 0) Inactive = value;
-        else if(!ActiveAnon && strcmp(name, "ActiveAnon") == 0) ActiveAnon = value;
-        else if(!InactiveAnon && strcmp(name, "InactiveAnon") == 0) InactiveAnon = value;
-        else if(!ActiveFile && strcmp(name, "ActiveFile") == 0) ActiveFile = value;
-        else if(!InactiveFile && strcmp(name, "InactiveFile") == 0) InactiveFile = value;
-        else if(!Unevictable && strcmp(name, "Unevictable") == 0) Unevictable = value;
-        else if(!Mlocked && strcmp(name, "Mlocked") == 0) Mlocked = value;
-        else if(!SwapTotal && strcmp(name, "SwapTotal") == 0) SwapTotal = value;
-        else if(!SwapFree && strcmp(name, "SwapFree") == 0) SwapFree = value;
-        else if(!Dirty && strcmp(name, "Dirty") == 0) Dirty = value;
-        else if(!Writeback && strcmp(name, "Writeback") == 0) Writeback = value;
-        else if(!AnonPages && strcmp(name, "AnonPages") == 0) AnonPages = value;
-        else if(!Mapped && strcmp(name, "Mapped") == 0) Mapped = value;
-        else if(!Shmem && strcmp(name, "Shmem") == 0) Shmem = value;
-        else if(!Slab && strcmp(name, "Slab") == 0) Slab = value;
-        else if(!SReclaimable && strcmp(name, "SReclaimable") == 0) SReclaimable = value;
-        else if(!SUnreclaim && strcmp(name, "SUnreclaim") == 0) SUnreclaim = value;
-        else if(!KernelStack && strcmp(name, "KernelStack") == 0) KernelStack = value;
-        else if(!PageTables && strcmp(name, "PageTables") == 0) PageTables = value;
-        else if(!NFS_Unstable && strcmp(name, "NFS_Unstable") == 0) NFS_Unstable = value;
-        else if(!Bounce && strcmp(name, "Bounce") == 0) Bounce = value;
-        else if(!WritebackTmp && strcmp(name, "WritebackTmp") == 0) WritebackTmp = value;
-        else if(!CommitLimit && strcmp(name, "CommitLimit") == 0) CommitLimit = value;
-        else if(!Committed_AS && strcmp(name, "Committed_AS") == 0) Committed_AS = value;
-        else if(!VmallocTotal && strcmp(name, "VmallocTotal") == 0) VmallocTotal = value;
-        else if(!VmallocUsed && strcmp(name, "VmallocUsed") == 0) VmallocUsed = value;
-        else if(!VmallocChunk && strcmp(name, "VmallocChunk") == 0) VmallocChunk = value;
-        else if(!HardwareCorrupted && strcmp(name, "HardwareCorrupted") == 0) { HardwareCorrupted = value; hwcorrupted = 1; }
-        else if(!AnonHugePages && strcmp(name, "AnonHugePages") == 0) AnonHugePages = value;
-        else if(!HugePages_Total && strcmp(name, "HugePages_Total") == 0) HugePages_Total = value;
-        else if(!HugePages_Free && strcmp(name, "HugePages_Free") == 0) HugePages_Free = value;
-        else if(!HugePages_Rsvd && strcmp(name, "HugePages_Rsvd") == 0) HugePages_Rsvd = value;
-        else if(!HugePages_Surp && strcmp(name, "HugePages_Surp") == 0) HugePages_Surp = value;
-        else if(!Hugepagesize && strcmp(name, "Hugepagesize") == 0) Hugepagesize = value;
-        else if(!DirectMap4k && strcmp(name, "DirectMap4k") == 0) DirectMap4k = value;
-        else if(!DirectMap2M && strcmp(name, "DirectMap2M") == 0) DirectMap2M = value;
+             if(hash == MemTotal_hash && strcmp(name, "MemTotal") == 0) MemTotal = value;
+        else if(hash == MemFree_hash && strcmp(name, "MemFree") == 0) MemFree = value;
+        else if(hash == Buffers_hash && strcmp(name, "Buffers") == 0) Buffers = value;
+        else if(hash == Cached_hash && strcmp(name, "Cached") == 0) Cached = value;
+        //else if(hash == SwapCached_hash && strcmp(name, "SwapCached") == 0) SwapCached = value;
+        //else if(hash == Active_hash && strcmp(name, "Active") == 0) Active = value;
+        //else if(hash == Inactive_hash && strcmp(name, "Inactive") == 0) Inactive = value;
+        //else if(hash == ActiveAnon_hash && strcmp(name, "ActiveAnon") == 0) ActiveAnon = value;
+        //else if(hash == InactiveAnon_hash && strcmp(name, "InactiveAnon") == 0) InactiveAnon = value;
+        //else if(hash == ActiveFile_hash && strcmp(name, "ActiveFile") == 0) ActiveFile = value;
+        //else if(hash == InactiveFile_hash && strcmp(name, "InactiveFile") == 0) InactiveFile = value;
+        //else if(hash == Unevictable_hash && strcmp(name, "Unevictable") == 0) Unevictable = value;
+        //else if(hash == Mlocked_hash && strcmp(name, "Mlocked") == 0) Mlocked = value;
+        else if(hash == SwapTotal_hash && strcmp(name, "SwapTotal") == 0) SwapTotal = value;
+        else if(hash == SwapFree_hash && strcmp(name, "SwapFree") == 0) SwapFree = value;
+        else if(hash == Dirty_hash && strcmp(name, "Dirty") == 0) Dirty = value;
+        else if(hash == Writeback_hash && strcmp(name, "Writeback") == 0) Writeback = value;
+        //else if(hash == AnonPages_hash && strcmp(name, "AnonPages") == 0) AnonPages = value;
+        //else if(hash == Mapped_hash && strcmp(name, "Mapped") == 0) Mapped = value;
+        //else if(hash == Shmem_hash && strcmp(name, "Shmem") == 0) Shmem = value;
+        else if(hash == Slab_hash && strcmp(name, "Slab") == 0) Slab = value;
+        else if(hash == SReclaimable_hash && strcmp(name, "SReclaimable") == 0) SReclaimable = value;
+        else if(hash == SUnreclaim_hash && strcmp(name, "SUnreclaim") == 0) SUnreclaim = value;
+        else if(hash == KernelStack_hash && strcmp(name, "KernelStack") == 0) KernelStack = value;
+        else if(hash == PageTables_hash && strcmp(name, "PageTables") == 0) PageTables = value;
+        else if(hash == NFS_Unstable_hash && strcmp(name, "NFS_Unstable") == 0) NFS_Unstable = value;
+        else if(hash == Bounce_hash && strcmp(name, "Bounce") == 0) Bounce = value;
+        else if(hash == WritebackTmp_hash && strcmp(name, "WritebackTmp") == 0) WritebackTmp = value;
+        //else if(hash == CommitLimit_hash && strcmp(name, "CommitLimit") == 0) CommitLimit = value;
+        else if(hash == Committed_AS_hash && strcmp(name, "Committed_AS") == 0) Committed_AS = value;
+        //else if(hash == VmallocTotal_hash && strcmp(name, "VmallocTotal") == 0) VmallocTotal = value;
+        else if(hash == VmallocUsed_hash && strcmp(name, "VmallocUsed") == 0) VmallocUsed = value;
+        //else if(hash == VmallocChunk_hash && strcmp(name, "VmallocChunk") == 0) VmallocChunk = value;
+        else if(hash == HardwareCorrupted_hash && strcmp(name, "HardwareCorrupted") == 0) { HardwareCorrupted = value; hwcorrupted = 1; }
+        //else if(hash == AnonHugePages_hash && strcmp(name, "AnonHugePages") == 0) AnonHugePages = value;
+        //else if(hash == HugePages_Total_hash && strcmp(name, "HugePages_Total") == 0) HugePages_Total = value;
+        //else if(hash == HugePages_Free_hash && strcmp(name, "HugePages_Free") == 0) HugePages_Free = value;
+        //else if(hash == HugePages_Rsvd_hash && strcmp(name, "HugePages_Rsvd") == 0) HugePages_Rsvd = value;
+        //else if(hash == HugePages_Surp_hash && strcmp(name, "HugePages_Surp") == 0) HugePages_Surp = value;
+        //else if(hash == Hugepagesize_hash && strcmp(name, "Hugepagesize") == 0) Hugepagesize = value;
+        //else if(hash == DirectMap4k_hash && strcmp(name, "DirectMap4k") == 0) DirectMap4k = value;
+        //else if(hash == DirectMap2M_hash && strcmp(name, "DirectMap2M") == 0) DirectMap2M = value;
     }
 
     RRDSET *st;
index ea38acf291df5459e42346c8b7e36e1717157412..00d26635f90c7e9e00e3b1cc1aa447a4636bdb98 100644 (file)
@@ -543,8 +543,8 @@ int do_proc_net_netstat(int update_every, unsigned long long dt) {
         char filename[FILENAME_MAX + 1];
         snprintfz(filename, FILENAME_MAX, "%s%s", global_host_prefix, "/proc/net/netstat");
         ff = procfile_open(config_get("plugin:proc:/proc/net/netstat", "filename to monitor", filename), " \t:", PROCFILE_FLAG_DEFAULT);
+        if(unlikely(!ff)) return 1;
     }
-    if(unlikely(!ff)) return 1;
 
     ff = procfile_readall(ff);
     if(unlikely(!ff)) return 0; // we return 0, so that we will retry to open it next time
@@ -559,12 +559,12 @@ int do_proc_net_netstat(int update_every, unsigned long long dt) {
         if(unlikely(hash == hash_ipext && strcmp(key, "IpExt") == 0)) {
             uint32_t h = l++;
 
-            if(strcmp(procfile_lineword(ff, l, 0), "IpExt") != 0) {
+            if(unlikely(strcmp(procfile_lineword(ff, l, 0), "IpExt") != 0)) {
                 error("Cannot read IpExt line from /proc/net/netstat.");
                 break;
             }
             words = procfile_linewords(ff, l);
-            if(words < 2) {
+            if(unlikely(words < 2)) {
                 error("Cannot read /proc/net/netstat IpExt line. Expected 2+ params, read %u.", words);
                 continue;
             }
@@ -578,7 +578,7 @@ int do_proc_net_netstat(int update_every, unsigned long long dt) {
             if(do_bandwidth == CONFIG_ONDEMAND_YES || (do_bandwidth == CONFIG_ONDEMAND_ONDEMAND && (*ipext_InOctets || *ipext_OutOctets))) {
                 do_bandwidth = CONFIG_ONDEMAND_YES;
                 st = rrdset_find("system.ipv4");
-                if(!st) {
+                if(unlikely(!st)) {
                     st = rrdset_create("system", "ipv4", NULL, "network", NULL, "IPv4 Bandwidth", "kilobits/s", 500, update_every, RRDSET_TYPE_AREA);
 
                     rrddim_add(st, "InOctets", "received", 8, 1024, RRDDIM_INCREMENTAL);
@@ -596,7 +596,7 @@ int do_proc_net_netstat(int update_every, unsigned long long dt) {
             if(do_inerrors == CONFIG_ONDEMAND_YES || (do_inerrors == CONFIG_ONDEMAND_ONDEMAND && (*ipext_InNoRoutes || *ipext_InTruncatedPkts))) {
                 do_inerrors = CONFIG_ONDEMAND_YES;
                 st = rrdset_find("ipv4.inerrors");
-                if(!st) {
+                if(unlikely(!st)) {
                     st = rrdset_create("ipv4", "inerrors", NULL, "errors", NULL, "IPv4 Input Errors", "packets/s", 4000, update_every, RRDSET_TYPE_LINE);
                     st->isdetail = 1;
 
@@ -617,7 +617,7 @@ int do_proc_net_netstat(int update_every, unsigned long long dt) {
             if(do_mcast == CONFIG_ONDEMAND_YES || (do_mcast == CONFIG_ONDEMAND_ONDEMAND && (*ipext_InMcastOctets || *ipext_OutMcastOctets))) {
                 do_mcast = CONFIG_ONDEMAND_YES;
                 st = rrdset_find("ipv4.mcast");
-                if(!st) {
+                if(unlikely(!st)) {
                     st = rrdset_create("ipv4", "mcast", NULL, "multicast", NULL, "IPv4 Multicast Bandwidth", "kilobits/s", 9000, update_every, RRDSET_TYPE_AREA);
                     st->isdetail = 1;
 
@@ -636,7 +636,7 @@ int do_proc_net_netstat(int update_every, unsigned long long dt) {
             if(do_bcast == CONFIG_ONDEMAND_YES || (do_bcast == CONFIG_ONDEMAND_ONDEMAND && (*ipext_InBcastOctets || *ipext_OutBcastOctets))) {
                 do_bcast = CONFIG_ONDEMAND_YES;
                 st = rrdset_find("ipv4.bcast");
-                if(!st) {
+                if(unlikely(!st)) {
                     st = rrdset_create("ipv4", "bcast", NULL, "broadcast", NULL, "IPv4 Broadcast Bandwidth", "kilobits/s", 8000, update_every, RRDSET_TYPE_AREA);
                     st->isdetail = 1;
 
@@ -655,7 +655,7 @@ int do_proc_net_netstat(int update_every, unsigned long long dt) {
             if(do_mcast_p == CONFIG_ONDEMAND_YES || (do_mcast_p == CONFIG_ONDEMAND_ONDEMAND && (*ipext_InMcastPkts || *ipext_OutMcastPkts))) {
                 do_mcast_p = CONFIG_ONDEMAND_YES;
                 st = rrdset_find("ipv4.mcastpkts");
-                if(!st) {
+                if(unlikely(!st)) {
                     st = rrdset_create("ipv4", "mcastpkts", NULL, "multicast", NULL, "IPv4 Multicast Packets", "packets/s", 8600, update_every, RRDSET_TYPE_LINE);
                     st->isdetail = 1;
 
@@ -674,7 +674,7 @@ int do_proc_net_netstat(int update_every, unsigned long long dt) {
             if(do_bcast_p == CONFIG_ONDEMAND_YES || (do_bcast_p == CONFIG_ONDEMAND_ONDEMAND && (*ipext_InBcastPkts || *ipext_OutBcastPkts))) {
                 do_bcast_p = CONFIG_ONDEMAND_YES;
                 st = rrdset_find("ipv4.bcastpkts");
-                if(!st) {
+                if(unlikely(!st)) {
                     st = rrdset_create("ipv4", "bcastpkts", NULL, "broadcast", NULL, "IPv4 Broadcast Packets", "packets/s", 8500, update_every, RRDSET_TYPE_LINE);
                     st->isdetail = 1;
 
@@ -693,7 +693,7 @@ int do_proc_net_netstat(int update_every, unsigned long long dt) {
             if(do_ecn == CONFIG_ONDEMAND_YES || (do_ecn == CONFIG_ONDEMAND_ONDEMAND && (*ipext_InCEPkts || *ipext_InECT0Pkts || *ipext_InECT1Pkts || *ipext_InNoECTPkts))) {
                 do_ecn = CONFIG_ONDEMAND_YES;
                 st = rrdset_find("ipv4.ecnpkts");
-                if(!st) {
+                if(unlikely(!st)) {
                     st = rrdset_create("ipv4", "ecnpkts", NULL, "ecn", NULL, "IPv4 ECN Statistics", "packets/s", 8700, update_every, RRDSET_TYPE_LINE);
                     st->isdetail = 1;
 
@@ -714,12 +714,12 @@ int do_proc_net_netstat(int update_every, unsigned long long dt) {
         else if(unlikely(hash == hash_tcpext && strcmp(key, "TcpExt") == 0)) {
             uint32_t h = l++;
 
-            if(strcmp(procfile_lineword(ff, l, 0), "TcpExt") != 0) {
+            if(unlikely(strcmp(procfile_lineword(ff, l, 0), "TcpExt") != 0)) {
                 error("Cannot read TcpExt line from /proc/net/netstat.");
                 break;
             }
             words = procfile_linewords(ff, l);
-            if(words < 2) {
+            if(unlikely(words < 2)) {
                 error("Cannot read /proc/net/netstat TcpExt line. Expected 2+ params, read %u.", words);
                 continue;
             }
@@ -733,7 +733,7 @@ int do_proc_net_netstat(int update_every, unsigned long long dt) {
             if(do_tcpext_memory == CONFIG_ONDEMAND_YES || (do_tcpext_memory == CONFIG_ONDEMAND_ONDEMAND && (*tcpext_TCPMemoryPressures))) {
                 do_tcpext_memory = CONFIG_ONDEMAND_YES;
                 st = rrdset_find("ipv4.tcpmemorypressures");
-                if(!st) {
+                if(unlikely(!st)) {
                     st = rrdset_create("ipv4", "tcpmemorypressures", NULL, "tcp", NULL, "TCP Memory Pressures", "events/s", 3000, update_every, RRDSET_TYPE_LINE);
 
                     rrddim_add(st, "TCPMemoryPressures",   "pressures",  1, 1, RRDDIM_INCREMENTAL);
@@ -749,7 +749,7 @@ int do_proc_net_netstat(int update_every, unsigned long long dt) {
             if(do_tcpext_connaborts == CONFIG_ONDEMAND_YES || (do_tcpext_connaborts == CONFIG_ONDEMAND_ONDEMAND && (*tcpext_TCPAbortOnData || *tcpext_TCPAbortOnClose || *tcpext_TCPAbortOnMemory || *tcpext_TCPAbortOnTimeout || *tcpext_TCPAbortOnLinger || *tcpext_TCPAbortFailed))) {
                 do_tcpext_connaborts = CONFIG_ONDEMAND_YES;
                 st = rrdset_find("ipv4.tcpconnaborts");
-                if(!st) {
+                if(unlikely(!st)) {
                     st = rrdset_create("ipv4", "tcpconnaborts", NULL, "tcp", NULL, "TCP Connection Aborts", "connections/s", 3010, update_every, RRDSET_TYPE_LINE);
 
                     rrddim_add(st, "TCPAbortOnData",    "baddata",     1, 1, RRDDIM_INCREMENTAL);
@@ -774,7 +774,7 @@ int do_proc_net_netstat(int update_every, unsigned long long dt) {
             if(do_tcpext_reorder == CONFIG_ONDEMAND_YES || (do_tcpext_reorder == CONFIG_ONDEMAND_ONDEMAND && (*tcpext_TCPRenoReorder || *tcpext_TCPFACKReorder || *tcpext_TCPSACKReorder || *tcpext_TCPTSReorder))) {
                 do_tcpext_reorder = CONFIG_ONDEMAND_YES;
                 st = rrdset_find("ipv4.tcpreorders");
-                if(!st) {
+                if(unlikely(!st)) {
                     st = rrdset_create("ipv4", "tcpreorders", NULL, "tcp", NULL, "TCP Reordered Packets by Detection Method", "packets/s", 3020, update_every, RRDSET_TYPE_LINE);
 
                     rrddim_add(st, "TCPTSReorder",   "timestamp",   1, 1, RRDDIM_INCREMENTAL);
@@ -796,7 +796,7 @@ int do_proc_net_netstat(int update_every, unsigned long long dt) {
             if(do_tcpext_ofo == CONFIG_ONDEMAND_YES || (do_tcpext_ofo == CONFIG_ONDEMAND_ONDEMAND && (*tcpext_TCPOFOQueue || *tcpext_TCPOFODrop || *tcpext_TCPOFOMerge))) {
                 do_tcpext_ofo = CONFIG_ONDEMAND_YES;
                 st = rrdset_find("ipv4.tcpofo");
-                if(!st) {
+                if(unlikely(!st)) {
                     st = rrdset_create("ipv4", "tcpofo", NULL, "tcp", NULL, "TCP Out-Of-Order Queue", "packets/s", 3050, update_every, RRDSET_TYPE_LINE);
 
                     rrddim_add(st, "TCPOFOQueue", "inqueue",  1, 1, RRDDIM_INCREMENTAL);
@@ -818,7 +818,7 @@ int do_proc_net_netstat(int update_every, unsigned long long dt) {
             if(do_tcpext_syscookies == CONFIG_ONDEMAND_YES || (do_tcpext_syscookies == CONFIG_ONDEMAND_ONDEMAND && (*tcpext_SyncookiesSent || *tcpext_SyncookiesRecv || *tcpext_SyncookiesFailed))) {
                 do_tcpext_syscookies = CONFIG_ONDEMAND_YES;
                 st = rrdset_find("ipv4.tcpsyncookies");
-                if(!st) {
+                if(unlikely(!st)) {
                     st = rrdset_create("ipv4", "tcpsyncookies", NULL, "tcp", NULL, "TCP SYN Cookies", "packets/s", 3100, update_every, RRDSET_TYPE_LINE);
 
                     rrddim_add(st, "SyncookiesRecv",   "received",  1, 1, RRDDIM_INCREMENTAL);
index a75c0a96a334621240e1cd0a0bc5f70fb0764016..3ef111ba89e398471b68d0018f2c859f88dc0276 100644 (file)
@@ -360,8 +360,8 @@ int do_proc_net_snmp(int update_every, unsigned long long dt) {
         char filename[FILENAME_MAX + 1];
         snprintfz(filename, FILENAME_MAX, "%s%s", global_host_prefix, "/proc/net/snmp");
         ff = procfile_open(config_get("plugin:proc:/proc/net/snmp", "filename to monitor", filename), " \t:", PROCFILE_FLAG_DEFAULT);
+        if(unlikely(!ff)) return 1;
     }
-    if(unlikely(!ff)) return 1;
 
     ff = procfile_readall(ff);
     if(unlikely(!ff)) return 0; // we return 0, so that we will retry to open it next time
index 97dc20edd27ad7f23c4350d60092085cf158a6a4..34c01a2f9c23b94d746cb333ab61788be6036d59 100644 (file)
@@ -4,8 +4,10 @@
 #define RRD_TYPE_NET_SNMP6_LEN      strlen(RRD_TYPE_NET_SNMP6)
 
 int do_proc_net_snmp6(int update_every, unsigned long long dt) {
+    (void)dt;
+
     static procfile *ff = NULL;
-    static int gen_hashes = -1;
+    static int initialized = 0;
 
     static int do_ip_packets = -1, do_ip_fragsout = -1, do_ip_fragsin = -1, do_ip_errors = -1,
         do_udplite_packets = -1, do_udplite_errors = -1,
@@ -14,112 +16,113 @@ int do_proc_net_snmp6(int update_every, unsigned long long dt) {
         do_icmp = -1, do_icmp_redir = -1, do_icmp_errors = -1, do_icmp_echos = -1, do_icmp_groupmemb = -1,
         do_icmp_router = -1, do_icmp_neighbor = -1, do_icmp_mldv2 = -1, do_icmp_types = -1, do_ect = -1;
 
-    static uint32_t hash_Ip6InReceives = -1;
-
-    static uint32_t hash_Ip6InHdrErrors = -1;
-    static uint32_t hash_Ip6InTooBigErrors = -1;
-    static uint32_t hash_Ip6InNoRoutes = -1;
-    static uint32_t hash_Ip6InAddrErrors = -1;
-    static uint32_t hash_Ip6InUnknownProtos = -1;
-    static uint32_t hash_Ip6InTruncatedPkts = -1;
-    static uint32_t hash_Ip6InDiscards = -1;
-    static uint32_t hash_Ip6InDelivers = -1;
-
-    static uint32_t hash_Ip6OutForwDatagrams = -1;
-    static uint32_t hash_Ip6OutRequests = -1;
-    static uint32_t hash_Ip6OutDiscards = -1;
-    static uint32_t hash_Ip6OutNoRoutes = -1;
-
-    static uint32_t hash_Ip6ReasmTimeout = -1;
-    static uint32_t hash_Ip6ReasmReqds = -1;
-    static uint32_t hash_Ip6ReasmOKs = -1;
-    static uint32_t hash_Ip6ReasmFails = -1;
-
-    static uint32_t hash_Ip6FragOKs = -1;
-    static uint32_t hash_Ip6FragFails = -1;
-    static uint32_t hash_Ip6FragCreates = -1;
-
-    static uint32_t hash_Ip6InMcastPkts = -1;
-    static uint32_t hash_Ip6OutMcastPkts = -1;
-
-    static uint32_t hash_Ip6InOctets = -1;
-    static uint32_t hash_Ip6OutOctets = -1;
-
-    static uint32_t hash_Ip6InMcastOctets = -1;
-    static uint32_t hash_Ip6OutMcastOctets = -1;
-    static uint32_t hash_Ip6InBcastOctets = -1;
-    static uint32_t hash_Ip6OutBcastOctets = -1;
-
-    static uint32_t hash_Ip6InNoECTPkts = -1;
-    static uint32_t hash_Ip6InECT1Pkts = -1;
-    static uint32_t hash_Ip6InECT0Pkts = -1;
-    static uint32_t hash_Ip6InCEPkts = -1;
-
-    static uint32_t hash_Icmp6InMsgs = -1;
-    static uint32_t hash_Icmp6InErrors = -1;
-    static uint32_t hash_Icmp6OutMsgs = -1;
-    static uint32_t hash_Icmp6OutErrors = -1;
-    static uint32_t hash_Icmp6InCsumErrors = -1;
-    static uint32_t hash_Icmp6InDestUnreachs = -1;
-    static uint32_t hash_Icmp6InPktTooBigs = -1;
-    static uint32_t hash_Icmp6InTimeExcds = -1;
-    static uint32_t hash_Icmp6InParmProblems = -1;
-    static uint32_t hash_Icmp6InEchos = -1;
-    static uint32_t hash_Icmp6InEchoReplies = -1;
-    static uint32_t hash_Icmp6InGroupMembQueries = -1;
-    static uint32_t hash_Icmp6InGroupMembResponses = -1;
-    static uint32_t hash_Icmp6InGroupMembReductions = -1;
-    static uint32_t hash_Icmp6InRouterSolicits = -1;
-    static uint32_t hash_Icmp6InRouterAdvertisements = -1;
-    static uint32_t hash_Icmp6InNeighborSolicits = -1;
-    static uint32_t hash_Icmp6InNeighborAdvertisements = -1;
-    static uint32_t hash_Icmp6InRedirects = -1;
-    static uint32_t hash_Icmp6InMLDv2Reports = -1;
-    static uint32_t hash_Icmp6OutDestUnreachs = -1;
-    static uint32_t hash_Icmp6OutPktTooBigs = -1;
-    static uint32_t hash_Icmp6OutTimeExcds = -1;
-    static uint32_t hash_Icmp6OutParmProblems = -1;
-    static uint32_t hash_Icmp6OutEchos = -1;
-    static uint32_t hash_Icmp6OutEchoReplies = -1;
-    static uint32_t hash_Icmp6OutGroupMembQueries = -1;
-    static uint32_t hash_Icmp6OutGroupMembResponses = -1;
-    static uint32_t hash_Icmp6OutGroupMembReductions = -1;
-    static uint32_t hash_Icmp6OutRouterSolicits = -1;
-    static uint32_t hash_Icmp6OutRouterAdvertisements = -1;
-    static uint32_t hash_Icmp6OutNeighborSolicits = -1;
-    static uint32_t hash_Icmp6OutNeighborAdvertisements = -1;
-    static uint32_t hash_Icmp6OutRedirects = -1;
-    static uint32_t hash_Icmp6OutMLDv2Reports = -1;
-    static uint32_t hash_Icmp6InType1 = -1;
-    static uint32_t hash_Icmp6InType128 = -1;
-    static uint32_t hash_Icmp6InType129 = -1;
-    static uint32_t hash_Icmp6InType136 = -1;
-    static uint32_t hash_Icmp6OutType1 = -1;
-    static uint32_t hash_Icmp6OutType128 = -1;
-    static uint32_t hash_Icmp6OutType129 = -1;
-    static uint32_t hash_Icmp6OutType133 = -1;
-    static uint32_t hash_Icmp6OutType135 = -1;
-    static uint32_t hash_Icmp6OutType143 = -1;
-
-    static uint32_t hash_Udp6InDatagrams = -1;
-    static uint32_t hash_Udp6NoPorts = -1;
-    static uint32_t hash_Udp6InErrors = -1;
-    static uint32_t hash_Udp6OutDatagrams = -1;
-    static uint32_t hash_Udp6RcvbufErrors = -1;
-    static uint32_t hash_Udp6SndbufErrors = -1;
-    static uint32_t hash_Udp6InCsumErrors = -1;
-    static uint32_t hash_Udp6IgnoredMulti = -1;
-
-    static uint32_t hash_UdpLite6InDatagrams = -1;
-    static uint32_t hash_UdpLite6NoPorts = -1;
-    static uint32_t hash_UdpLite6InErrors = -1;
-    static uint32_t hash_UdpLite6OutDatagrams = -1;
-    static uint32_t hash_UdpLite6RcvbufErrors = -1;
-    static uint32_t hash_UdpLite6SndbufErrors = -1;
-    static uint32_t hash_UdpLite6InCsumErrors = -1;
-
-    if(gen_hashes != 1) {
-        gen_hashes = 1;
+    static uint32_t hash_Ip6InReceives = 0;
+
+    static uint32_t hash_Ip6InHdrErrors = 0;
+    static uint32_t hash_Ip6InTooBigErrors = 0;
+    static uint32_t hash_Ip6InNoRoutes = 0;
+    static uint32_t hash_Ip6InAddrErrors = 0;
+    static uint32_t hash_Ip6InUnknownProtos = 0;
+    static uint32_t hash_Ip6InTruncatedPkts = 0;
+    static uint32_t hash_Ip6InDiscards = 0;
+    static uint32_t hash_Ip6InDelivers = 0;
+
+    static uint32_t hash_Ip6OutForwDatagrams = 0;
+    static uint32_t hash_Ip6OutRequests = 0;
+    static uint32_t hash_Ip6OutDiscards = 0;
+    static uint32_t hash_Ip6OutNoRoutes = 0;
+
+    static uint32_t hash_Ip6ReasmTimeout = 0;
+    static uint32_t hash_Ip6ReasmReqds = 0;
+    static uint32_t hash_Ip6ReasmOKs = 0;
+    static uint32_t hash_Ip6ReasmFails = 0;
+
+    static uint32_t hash_Ip6FragOKs = 0;
+    static uint32_t hash_Ip6FragFails = 0;
+    static uint32_t hash_Ip6FragCreates = 0;
+
+    static uint32_t hash_Ip6InMcastPkts = 0;
+    static uint32_t hash_Ip6OutMcastPkts = 0;
+
+    static uint32_t hash_Ip6InOctets = 0;
+    static uint32_t hash_Ip6OutOctets = 0;
+
+    static uint32_t hash_Ip6InMcastOctets = 0;
+    static uint32_t hash_Ip6OutMcastOctets = 0;
+    static uint32_t hash_Ip6InBcastOctets = 0;
+    static uint32_t hash_Ip6OutBcastOctets = 0;
+
+    static uint32_t hash_Ip6InNoECTPkts = 0;
+    static uint32_t hash_Ip6InECT1Pkts = 0;
+    static uint32_t hash_Ip6InECT0Pkts = 0;
+    static uint32_t hash_Ip6InCEPkts = 0;
+
+    static uint32_t hash_Icmp6InMsgs = 0;
+    static uint32_t hash_Icmp6InErrors = 0;
+    static uint32_t hash_Icmp6OutMsgs = 0;
+    static uint32_t hash_Icmp6OutErrors = 0;
+    static uint32_t hash_Icmp6InCsumErrors = 0;
+    static uint32_t hash_Icmp6InDestUnreachs = 0;
+    static uint32_t hash_Icmp6InPktTooBigs = 0;
+    static uint32_t hash_Icmp6InTimeExcds = 0;
+    static uint32_t hash_Icmp6InParmProblems = 0;
+    static uint32_t hash_Icmp6InEchos = 0;
+    static uint32_t hash_Icmp6InEchoReplies = 0;
+    static uint32_t hash_Icmp6InGroupMembQueries = 0;
+    static uint32_t hash_Icmp6InGroupMembResponses = 0;
+    static uint32_t hash_Icmp6InGroupMembReductions = 0;
+    static uint32_t hash_Icmp6InRouterSolicits = 0;
+    static uint32_t hash_Icmp6InRouterAdvertisements = 0;
+    static uint32_t hash_Icmp6InNeighborSolicits = 0;
+    static uint32_t hash_Icmp6InNeighborAdvertisements = 0;
+    static uint32_t hash_Icmp6InRedirects = 0;
+    static uint32_t hash_Icmp6InMLDv2Reports = 0;
+    static uint32_t hash_Icmp6OutDestUnreachs = 0;
+    static uint32_t hash_Icmp6OutPktTooBigs = 0;
+    static uint32_t hash_Icmp6OutTimeExcds = 0;
+    static uint32_t hash_Icmp6OutParmProblems = 0;
+    static uint32_t hash_Icmp6OutEchos = 0;
+    static uint32_t hash_Icmp6OutEchoReplies = 0;
+    static uint32_t hash_Icmp6OutGroupMembQueries = 0;
+    static uint32_t hash_Icmp6OutGroupMembResponses = 0;
+    static uint32_t hash_Icmp6OutGroupMembReductions = 0;
+    static uint32_t hash_Icmp6OutRouterSolicits = 0;
+    static uint32_t hash_Icmp6OutRouterAdvertisements = 0;
+    static uint32_t hash_Icmp6OutNeighborSolicits = 0;
+    static uint32_t hash_Icmp6OutNeighborAdvertisements = 0;
+    static uint32_t hash_Icmp6OutRedirects = 0;
+    static uint32_t hash_Icmp6OutMLDv2Reports = 0;
+    static uint32_t hash_Icmp6InType1 = 0;
+    static uint32_t hash_Icmp6InType128 = 0;
+    static uint32_t hash_Icmp6InType129 = 0;
+    static uint32_t hash_Icmp6InType136 = 0;
+    static uint32_t hash_Icmp6OutType1 = 0;
+    static uint32_t hash_Icmp6OutType128 = 0;
+    static uint32_t hash_Icmp6OutType129 = 0;
+    static uint32_t hash_Icmp6OutType133 = 0;
+    static uint32_t hash_Icmp6OutType135 = 0;
+    static uint32_t hash_Icmp6OutType143 = 0;
+
+    static uint32_t hash_Udp6InDatagrams = 0;
+    static uint32_t hash_Udp6NoPorts = 0;
+    static uint32_t hash_Udp6InErrors = 0;
+    static uint32_t hash_Udp6OutDatagrams = 0;
+    static uint32_t hash_Udp6RcvbufErrors = 0;
+    static uint32_t hash_Udp6SndbufErrors = 0;
+    static uint32_t hash_Udp6InCsumErrors = 0;
+    static uint32_t hash_Udp6IgnoredMulti = 0;
+
+    static uint32_t hash_UdpLite6InDatagrams = 0;
+    static uint32_t hash_UdpLite6NoPorts = 0;
+    static uint32_t hash_UdpLite6InErrors = 0;
+    static uint32_t hash_UdpLite6OutDatagrams = 0;
+    static uint32_t hash_UdpLite6RcvbufErrors = 0;
+    static uint32_t hash_UdpLite6SndbufErrors = 0;
+    static uint32_t hash_UdpLite6InCsumErrors = 0;
+
+    if(unlikely(!initialized)) {
+        initialized = 1;
+
         hash_Ip6InReceives = simple_hash("Ip6InReceives");
         hash_Ip6InHdrErrors = simple_hash("Ip6InHdrErrors");
         hash_Ip6InTooBigErrors = simple_hash("Ip6InTooBigErrors");
@@ -212,42 +215,42 @@ int do_proc_net_snmp6(int update_every, unsigned long long dt) {
         hash_UdpLite6RcvbufErrors = simple_hash("UdpLite6RcvbufErrors");
         hash_UdpLite6SndbufErrors = simple_hash("UdpLite6SndbufErrors");
         hash_UdpLite6InCsumErrors = simple_hash("UdpLite6InCsumErrors");
+
+        do_ip_packets       = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "ipv6 packets", CONFIG_ONDEMAND_ONDEMAND);
+        do_ip_fragsout      = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "ipv6 fragments sent", CONFIG_ONDEMAND_ONDEMAND);
+        do_ip_fragsin       = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "ipv6 fragments assembly", CONFIG_ONDEMAND_ONDEMAND);
+        do_ip_errors        = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "ipv6 errors", CONFIG_ONDEMAND_ONDEMAND);
+        do_udp_packets      = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "ipv6 UDP packets", CONFIG_ONDEMAND_ONDEMAND);
+        do_udp_errors       = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "ipv6 UDP errors", CONFIG_ONDEMAND_ONDEMAND);
+        do_udplite_packets  = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "ipv6 UDPlite packets", CONFIG_ONDEMAND_ONDEMAND);
+        do_udplite_errors   = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "ipv6 UDPlite errors", CONFIG_ONDEMAND_ONDEMAND);
+        do_bandwidth        = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "bandwidth", CONFIG_ONDEMAND_ONDEMAND);
+        do_mcast            = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "multicast bandwidth", CONFIG_ONDEMAND_ONDEMAND);
+        do_bcast            = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "broadcast bandwidth", CONFIG_ONDEMAND_ONDEMAND);
+        do_mcast_p          = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "multicast packets", CONFIG_ONDEMAND_ONDEMAND);
+        do_icmp             = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "icmp", CONFIG_ONDEMAND_ONDEMAND);
+        do_icmp_redir       = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "icmp redirects", CONFIG_ONDEMAND_ONDEMAND);
+        do_icmp_errors      = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "icmp errors", CONFIG_ONDEMAND_ONDEMAND);
+        do_icmp_echos       = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "icmp echos", CONFIG_ONDEMAND_ONDEMAND);
+        do_icmp_groupmemb   = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "icmp group membership", CONFIG_ONDEMAND_ONDEMAND);
+        do_icmp_router      = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "icmp router", CONFIG_ONDEMAND_ONDEMAND);
+        do_icmp_neighbor    = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "icmp neighbor", CONFIG_ONDEMAND_ONDEMAND);
+        do_icmp_mldv2       = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "icmp mldv2", CONFIG_ONDEMAND_ONDEMAND);
+        do_icmp_types       = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "icmp types", CONFIG_ONDEMAND_ONDEMAND);
+        do_ect              = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "ect", CONFIG_ONDEMAND_ONDEMAND);
     }
 
-    if(do_ip_packets == -1)         do_ip_packets       = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "ipv6 packets", CONFIG_ONDEMAND_ONDEMAND);
-    if(do_ip_fragsout == -1)        do_ip_fragsout      = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "ipv6 fragments sent", CONFIG_ONDEMAND_ONDEMAND);
-    if(do_ip_fragsin == -1)         do_ip_fragsin       = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "ipv6 fragments assembly", CONFIG_ONDEMAND_ONDEMAND);
-    if(do_ip_errors == -1)          do_ip_errors        = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "ipv6 errors", CONFIG_ONDEMAND_ONDEMAND);
-    if(do_udp_packets == -1)        do_udp_packets      = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "ipv6 UDP packets", CONFIG_ONDEMAND_ONDEMAND);
-    if(do_udp_errors == -1)         do_udp_errors       = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "ipv6 UDP errors", CONFIG_ONDEMAND_ONDEMAND);
-    if(do_udplite_packets == -1)    do_udplite_packets  = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "ipv6 UDPlite packets", CONFIG_ONDEMAND_ONDEMAND);
-    if(do_udplite_errors == -1)     do_udplite_errors   = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "ipv6 UDPlite errors", CONFIG_ONDEMAND_ONDEMAND);
-    if(do_bandwidth == -1)          do_bandwidth        = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "bandwidth", CONFIG_ONDEMAND_ONDEMAND);
-    if(do_mcast == -1)              do_mcast            = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "multicast bandwidth", CONFIG_ONDEMAND_ONDEMAND);
-    if(do_bcast == -1)              do_bcast            = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "broadcast bandwidth", CONFIG_ONDEMAND_ONDEMAND);
-    if(do_mcast_p == -1)            do_mcast_p          = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "multicast packets", CONFIG_ONDEMAND_ONDEMAND);
-    if(do_icmp == -1)               do_icmp             = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "icmp", CONFIG_ONDEMAND_ONDEMAND);
-    if(do_icmp_redir == -1)         do_icmp_redir       = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "icmp redirects", CONFIG_ONDEMAND_ONDEMAND);
-    if(do_icmp_errors == -1)        do_icmp_errors      = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "icmp errors", CONFIG_ONDEMAND_ONDEMAND);
-    if(do_icmp_echos == -1)         do_icmp_echos       = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "icmp echos", CONFIG_ONDEMAND_ONDEMAND);
-    if(do_icmp_groupmemb == -1)     do_icmp_groupmemb   = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "icmp group membership", CONFIG_ONDEMAND_ONDEMAND);
-    if(do_icmp_router == -1)        do_icmp_router      = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "icmp router", CONFIG_ONDEMAND_ONDEMAND);
-    if(do_icmp_neighbor == -1)      do_icmp_neighbor    = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "icmp neighbor", CONFIG_ONDEMAND_ONDEMAND);
-    if(do_icmp_mldv2 == -1)         do_icmp_mldv2       = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "icmp mldv2", CONFIG_ONDEMAND_ONDEMAND);
-    if(do_icmp_types == -1)         do_icmp_types       = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "icmp types", CONFIG_ONDEMAND_ONDEMAND);
-    if(do_ect == -1)                do_ect              = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "ect", CONFIG_ONDEMAND_ONDEMAND);
-
-    if(dt) {};
-
-    if(!ff) {
+    if(unlikely(!ff)) {
         char filename[FILENAME_MAX + 1];
         snprintfz(filename, FILENAME_MAX, "%s%s", global_host_prefix, "/proc/net/snmp6");
         ff = procfile_open(config_get("plugin:proc:/proc/net/snmp6", "filename to monitor", filename), " \t:", PROCFILE_FLAG_DEFAULT);
+        if(unlikely(!ff))
+            return 1;
     }
-    if(!ff) return 1;
 
     ff = procfile_readall(ff);
-    if(!ff) return 0; // we return 0, so that we will retry to open it next time
+    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;
@@ -347,110 +350,110 @@ int do_proc_net_snmp6(int update_every, unsigned long long dt) {
 
     for(l = 0; l < lines ;l++) {
         words = procfile_linewords(ff, l);
-        if(words < 2) {
-            if(words) error("Cannot read /proc/net/snmp6 line %u. Expected 2 params, read %u.", l, words);
+        if(unlikely(words < 2)) {
+            if(unlikely(words)) error("Cannot read /proc/net/snmp6 line %u. Expected 2 params, read %u.", l, words);
             continue;
         }
 
         char *name = procfile_lineword(ff, l, 0);
         char * value = procfile_lineword(ff, l, 1);
-        if(!name || !*name || !value || !*value) continue;
+        if(unlikely(!name || !*name || !value || !*value))
+            continue;
 
         uint32_t hash = simple_hash(name);
 
-        if(0) ;
-        else if(hash == hash_Ip6InReceives && strcmp(name, "Ip6InReceives") == 0) Ip6InReceives = strtoull(value, NULL, 10);
-        else if(hash == hash_Ip6InHdrErrors && strcmp(name, "Ip6InHdrErrors") == 0) Ip6InHdrErrors = strtoull(value, NULL, 10);
-        else if(hash == hash_Ip6InTooBigErrors && strcmp(name, "Ip6InTooBigErrors") == 0) Ip6InTooBigErrors = strtoull(value, NULL, 10);
-        else if(hash == hash_Ip6InNoRoutes && strcmp(name, "Ip6InNoRoutes") == 0) Ip6InNoRoutes = strtoull(value, NULL, 10);
-        else if(hash == hash_Ip6InAddrErrors && strcmp(name, "Ip6InAddrErrors") == 0) Ip6InAddrErrors = strtoull(value, NULL, 10);
-        else if(hash == hash_Ip6InUnknownProtos && strcmp(name, "Ip6InUnknownProtos") == 0) Ip6InUnknownProtos = strtoull(value, NULL, 10);
-        else if(hash == hash_Ip6InTruncatedPkts && strcmp(name, "Ip6InTruncatedPkts") == 0) Ip6InTruncatedPkts = strtoull(value, NULL, 10);
-        else if(hash == hash_Ip6InDiscards && strcmp(name, "Ip6InDiscards") == 0) Ip6InDiscards = strtoull(value, NULL, 10);
-        else if(hash == hash_Ip6InDelivers && strcmp(name, "Ip6InDelivers") == 0) Ip6InDelivers = strtoull(value, NULL, 10);
-        else if(hash == hash_Ip6OutForwDatagrams && strcmp(name, "Ip6OutForwDatagrams") == 0) Ip6OutForwDatagrams = strtoull(value, NULL, 10);
-        else if(hash == hash_Ip6OutRequests && strcmp(name, "Ip6OutRequests") == 0) Ip6OutRequests = strtoull(value, NULL, 10);
-        else if(hash == hash_Ip6OutDiscards && strcmp(name, "Ip6OutDiscards") == 0) Ip6OutDiscards = strtoull(value, NULL, 10);
-        else if(hash == hash_Ip6OutNoRoutes && strcmp(name, "Ip6OutNoRoutes") == 0) Ip6OutNoRoutes = strtoull(value, NULL, 10);
-        else if(hash == hash_Ip6ReasmTimeout && strcmp(name, "Ip6ReasmTimeout") == 0) Ip6ReasmTimeout = strtoull(value, NULL, 10);
-        else if(hash == hash_Ip6ReasmReqds && strcmp(name, "Ip6ReasmReqds") == 0) Ip6ReasmReqds = strtoull(value, NULL, 10);
-        else if(hash == hash_Ip6ReasmOKs && strcmp(name, "Ip6ReasmOKs") == 0) Ip6ReasmOKs = strtoull(value, NULL, 10);
-        else if(hash == hash_Ip6ReasmFails && strcmp(name, "Ip6ReasmFails") == 0) Ip6ReasmFails = strtoull(value, NULL, 10);
-        else if(hash == hash_Ip6FragOKs && strcmp(name, "Ip6FragOKs") == 0) Ip6FragOKs = strtoull(value, NULL, 10);
-        else if(hash == hash_Ip6FragFails && strcmp(name, "Ip6FragFails") == 0) Ip6FragFails = strtoull(value, NULL, 10);
-        else if(hash == hash_Ip6FragCreates && strcmp(name, "Ip6FragCreates") == 0) Ip6FragCreates = strtoull(value, NULL, 10);
-        else if(hash == hash_Ip6InMcastPkts && strcmp(name, "Ip6InMcastPkts") == 0) Ip6InMcastPkts = strtoull(value, NULL, 10);
-        else if(hash == hash_Ip6OutMcastPkts && strcmp(name, "Ip6OutMcastPkts") == 0) Ip6OutMcastPkts = strtoull(value, NULL, 10);
-        else if(hash == hash_Ip6InOctets && strcmp(name, "Ip6InOctets") == 0) Ip6InOctets = strtoull(value, NULL, 10);
-        else if(hash == hash_Ip6OutOctets && strcmp(name, "Ip6OutOctets") == 0) Ip6OutOctets = strtoull(value, NULL, 10);
-        else if(hash == hash_Ip6InMcastOctets && strcmp(name, "Ip6InMcastOctets") == 0) Ip6InMcastOctets = strtoull(value, NULL, 10);
-        else if(hash == hash_Ip6OutMcastOctets && strcmp(name, "Ip6OutMcastOctets") == 0) Ip6OutMcastOctets = strtoull(value, NULL, 10);
-        else if(hash == hash_Ip6InBcastOctets && strcmp(name, "Ip6InBcastOctets") == 0) Ip6InBcastOctets = strtoull(value, NULL, 10);
-        else if(hash == hash_Ip6OutBcastOctets && strcmp(name, "Ip6OutBcastOctets") == 0) Ip6OutBcastOctets = strtoull(value, NULL, 10);
-        else if(hash == hash_Ip6InNoECTPkts && strcmp(name, "Ip6InNoECTPkts") == 0) Ip6InNoECTPkts = strtoull(value, NULL, 10);
-        else if(hash == hash_Ip6InECT1Pkts && strcmp(name, "Ip6InECT1Pkts") == 0) Ip6InECT1Pkts = strtoull(value, NULL, 10);
-        else if(hash == hash_Ip6InECT0Pkts && strcmp(name, "Ip6InECT0Pkts") == 0) Ip6InECT0Pkts = strtoull(value, NULL, 10);
-        else if(hash == hash_Ip6InCEPkts && strcmp(name, "Ip6InCEPkts") == 0) Ip6InCEPkts = strtoull(value, NULL, 10);
-        else if(hash == hash_Icmp6InMsgs && strcmp(name, "Icmp6InMsgs") == 0) Icmp6InMsgs = strtoull(value, NULL, 10);
-        else if(hash == hash_Icmp6InErrors && strcmp(name, "Icmp6InErrors") == 0) Icmp6InErrors = strtoull(value, NULL, 10);
-        else if(hash == hash_Icmp6OutMsgs && strcmp(name, "Icmp6OutMsgs") == 0) Icmp6OutMsgs = strtoull(value, NULL, 10);
-        else if(hash == hash_Icmp6OutErrors && strcmp(name, "Icmp6OutErrors") == 0) Icmp6OutErrors = strtoull(value, NULL, 10);
-        else if(hash == hash_Icmp6InCsumErrors && strcmp(name, "Icmp6InCsumErrors") == 0) Icmp6InCsumErrors = strtoull(value, NULL, 10);
-        else if(hash == hash_Icmp6InDestUnreachs && strcmp(name, "Icmp6InDestUnreachs") == 0) Icmp6InDestUnreachs = strtoull(value, NULL, 10);
-        else if(hash == hash_Icmp6InPktTooBigs && strcmp(name, "Icmp6InPktTooBigs") == 0) Icmp6InPktTooBigs = strtoull(value, NULL, 10);
-        else if(hash == hash_Icmp6InTimeExcds && strcmp(name, "Icmp6InTimeExcds") == 0) Icmp6InTimeExcds = strtoull(value, NULL, 10);
-        else if(hash == hash_Icmp6InParmProblems && strcmp(name, "Icmp6InParmProblems") == 0) Icmp6InParmProblems = strtoull(value, NULL, 10);
-        else if(hash == hash_Icmp6InEchos && strcmp(name, "Icmp6InEchos") == 0) Icmp6InEchos = strtoull(value, NULL, 10);
-        else if(hash == hash_Icmp6InEchoReplies && strcmp(name, "Icmp6InEchoReplies") == 0) Icmp6InEchoReplies = strtoull(value, NULL, 10);
-        else if(hash == hash_Icmp6InGroupMembQueries && strcmp(name, "Icmp6InGroupMembQueries") == 0) Icmp6InGroupMembQueries = strtoull(value, NULL, 10);
-        else if(hash == hash_Icmp6InGroupMembResponses && strcmp(name, "Icmp6InGroupMembResponses") == 0) Icmp6InGroupMembResponses = strtoull(value, NULL, 10);
-        else if(hash == hash_Icmp6InGroupMembReductions && strcmp(name, "Icmp6InGroupMembReductions") == 0) Icmp6InGroupMembReductions = strtoull(value, NULL, 10);
-        else if(hash == hash_Icmp6InRouterSolicits && strcmp(name, "Icmp6InRouterSolicits") == 0) Icmp6InRouterSolicits = strtoull(value, NULL, 10);
-        else if(hash == hash_Icmp6InRouterAdvertisements && strcmp(name, "Icmp6InRouterAdvertisements") == 0) Icmp6InRouterAdvertisements = strtoull(value, NULL, 10);
-        else if(hash == hash_Icmp6InNeighborSolicits && strcmp(name, "Icmp6InNeighborSolicits") == 0) Icmp6InNeighborSolicits = strtoull(value, NULL, 10);
-        else if(hash == hash_Icmp6InNeighborAdvertisements && strcmp(name, "Icmp6InNeighborAdvertisements") == 0) Icmp6InNeighborAdvertisements = strtoull(value, NULL, 10);
-        else if(hash == hash_Icmp6InRedirects && strcmp(name, "Icmp6InRedirects") == 0) Icmp6InRedirects = strtoull(value, NULL, 10);
-        else if(hash == hash_Icmp6InMLDv2Reports && strcmp(name, "Icmp6InMLDv2Reports") == 0) Icmp6InMLDv2Reports = strtoull(value, NULL, 10);
-        else if(hash == hash_Icmp6OutDestUnreachs && strcmp(name, "Icmp6OutDestUnreachs") == 0) Icmp6OutDestUnreachs = strtoull(value, NULL, 10);
-        else if(hash == hash_Icmp6OutPktTooBigs && strcmp(name, "Icmp6OutPktTooBigs") == 0) Icmp6OutPktTooBigs = strtoull(value, NULL, 10);
-        else if(hash == hash_Icmp6OutTimeExcds && strcmp(name, "Icmp6OutTimeExcds") == 0) Icmp6OutTimeExcds = strtoull(value, NULL, 10);
-        else if(hash == hash_Icmp6OutParmProblems && strcmp(name, "Icmp6OutParmProblems") == 0) Icmp6OutParmProblems = strtoull(value, NULL, 10);
-        else if(hash == hash_Icmp6OutEchos && strcmp(name, "Icmp6OutEchos") == 0) Icmp6OutEchos = strtoull(value, NULL, 10);
-        else if(hash == hash_Icmp6OutEchoReplies && strcmp(name, "Icmp6OutEchoReplies") == 0) Icmp6OutEchoReplies = strtoull(value, NULL, 10);
-        else if(hash == hash_Icmp6OutGroupMembQueries && strcmp(name, "Icmp6OutGroupMembQueries") == 0) Icmp6OutGroupMembQueries = strtoull(value, NULL, 10);
-        else if(hash == hash_Icmp6OutGroupMembResponses && strcmp(name, "Icmp6OutGroupMembResponses") == 0) Icmp6OutGroupMembResponses = strtoull(value, NULL, 10);
-        else if(hash == hash_Icmp6OutGroupMembReductions && strcmp(name, "Icmp6OutGroupMembReductions") == 0) Icmp6OutGroupMembReductions = strtoull(value, NULL, 10);
-        else if(hash == hash_Icmp6OutRouterSolicits && strcmp(name, "Icmp6OutRouterSolicits") == 0) Icmp6OutRouterSolicits = strtoull(value, NULL, 10);
-        else if(hash == hash_Icmp6OutRouterAdvertisements && strcmp(name, "Icmp6OutRouterAdvertisements") == 0) Icmp6OutRouterAdvertisements = strtoull(value, NULL, 10);
-        else if(hash == hash_Icmp6OutNeighborSolicits && strcmp(name, "Icmp6OutNeighborSolicits") == 0) Icmp6OutNeighborSolicits = strtoull(value, NULL, 10);
-        else if(hash == hash_Icmp6OutNeighborAdvertisements && strcmp(name, "Icmp6OutNeighborAdvertisements") == 0) Icmp6OutNeighborAdvertisements = strtoull(value, NULL, 10);
-        else if(hash == hash_Icmp6OutRedirects && strcmp(name, "Icmp6OutRedirects") == 0) Icmp6OutRedirects = strtoull(value, NULL, 10);
-        else if(hash == hash_Icmp6OutMLDv2Reports && strcmp(name, "Icmp6OutMLDv2Reports") == 0) Icmp6OutMLDv2Reports = strtoull(value, NULL, 10);
-        else if(hash == hash_Icmp6InType1 && strcmp(name, "Icmp6InType1") == 0) Icmp6InType1 = strtoull(value, NULL, 10);
-        else if(hash == hash_Icmp6InType128 && strcmp(name, "Icmp6InType128") == 0) Icmp6InType128 = strtoull(value, NULL, 10);
-        else if(hash == hash_Icmp6InType129 && strcmp(name, "Icmp6InType129") == 0) Icmp6InType129 = strtoull(value, NULL, 10);
-        else if(hash == hash_Icmp6InType136 && strcmp(name, "Icmp6InType136") == 0) Icmp6InType136 = strtoull(value, NULL, 10);
-        else if(hash == hash_Icmp6OutType1 && strcmp(name, "Icmp6OutType1") == 0) Icmp6OutType1 = strtoull(value, NULL, 10);
-        else if(hash == hash_Icmp6OutType128 && strcmp(name, "Icmp6OutType128") == 0) Icmp6OutType128 = strtoull(value, NULL, 10);
-        else if(hash == hash_Icmp6OutType129 && strcmp(name, "Icmp6OutType129") == 0) Icmp6OutType129 = strtoull(value, NULL, 10);
-        else if(hash == hash_Icmp6OutType133 && strcmp(name, "Icmp6OutType133") == 0) Icmp6OutType133 = strtoull(value, NULL, 10);
-        else if(hash == hash_Icmp6OutType135 && strcmp(name, "Icmp6OutType135") == 0) Icmp6OutType135 = strtoull(value, NULL, 10);
-        else if(hash == hash_Icmp6OutType143 && strcmp(name, "Icmp6OutType143") == 0) Icmp6OutType143 = strtoull(value, NULL, 10);
-        else if(hash == hash_Udp6InDatagrams && strcmp(name, "Udp6InDatagrams") == 0) Udp6InDatagrams = strtoull(value, NULL, 10);
-        else if(hash == hash_Udp6NoPorts && strcmp(name, "Udp6NoPorts") == 0) Udp6NoPorts = strtoull(value, NULL, 10);
-        else if(hash == hash_Udp6InErrors && strcmp(name, "Udp6InErrors") == 0) Udp6InErrors = strtoull(value, NULL, 10);
-        else if(hash == hash_Udp6OutDatagrams && strcmp(name, "Udp6OutDatagrams") == 0) Udp6OutDatagrams = strtoull(value, NULL, 10);
-        else if(hash == hash_Udp6RcvbufErrors && strcmp(name, "Udp6RcvbufErrors") == 0) Udp6RcvbufErrors = strtoull(value, NULL, 10);
-        else if(hash == hash_Udp6SndbufErrors && strcmp(name, "Udp6SndbufErrors") == 0) Udp6SndbufErrors = strtoull(value, NULL, 10);
-        else if(hash == hash_Udp6InCsumErrors && strcmp(name, "Udp6InCsumErrors") == 0) Udp6InCsumErrors = strtoull(value, NULL, 10);
-        else if(hash == hash_Udp6IgnoredMulti && strcmp(name, "Udp6IgnoredMulti") == 0) Udp6IgnoredMulti = strtoull(value, NULL, 10);
-        else if(hash == hash_UdpLite6InDatagrams && strcmp(name, "UdpLite6InDatagrams") == 0) UdpLite6InDatagrams = strtoull(value, NULL, 10);
-        else if(hash == hash_UdpLite6NoPorts && strcmp(name, "UdpLite6NoPorts") == 0) UdpLite6NoPorts = strtoull(value, NULL, 10);
-        else if(hash == hash_UdpLite6InErrors && strcmp(name, "UdpLite6InErrors") == 0) UdpLite6InErrors = strtoull(value, NULL, 10);
-        else if(hash == hash_UdpLite6OutDatagrams && strcmp(name, "UdpLite6OutDatagrams") == 0) UdpLite6OutDatagrams = strtoull(value, NULL, 10);
-        else if(hash == hash_UdpLite6RcvbufErrors && strcmp(name, "UdpLite6RcvbufErrors") == 0) UdpLite6RcvbufErrors = strtoull(value, NULL, 10);
-        else if(hash == hash_UdpLite6SndbufErrors && strcmp(name, "UdpLite6SndbufErrors") == 0) UdpLite6SndbufErrors = strtoull(value, NULL, 10);
-        else if(hash == hash_UdpLite6InCsumErrors && strcmp(name, "UdpLite6InCsumErrors") == 0) UdpLite6InCsumErrors = strtoull(value, NULL, 10);
+             if(unlikely(hash == hash_Ip6InReceives && strcmp(name, "Ip6InReceives") == 0)) Ip6InReceives = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Ip6InHdrErrors && strcmp(name, "Ip6InHdrErrors") == 0)) Ip6InHdrErrors = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Ip6InTooBigErrors && strcmp(name, "Ip6InTooBigErrors") == 0)) Ip6InTooBigErrors = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Ip6InNoRoutes && strcmp(name, "Ip6InNoRoutes") == 0)) Ip6InNoRoutes = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Ip6InAddrErrors && strcmp(name, "Ip6InAddrErrors") == 0)) Ip6InAddrErrors = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Ip6InUnknownProtos && strcmp(name, "Ip6InUnknownProtos") == 0)) Ip6InUnknownProtos = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Ip6InTruncatedPkts && strcmp(name, "Ip6InTruncatedPkts") == 0)) Ip6InTruncatedPkts = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Ip6InDiscards && strcmp(name, "Ip6InDiscards") == 0)) Ip6InDiscards = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Ip6InDelivers && strcmp(name, "Ip6InDelivers") == 0)) Ip6InDelivers = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Ip6OutForwDatagrams && strcmp(name, "Ip6OutForwDatagrams") == 0)) Ip6OutForwDatagrams = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Ip6OutRequests && strcmp(name, "Ip6OutRequests") == 0)) Ip6OutRequests = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Ip6OutDiscards && strcmp(name, "Ip6OutDiscards") == 0)) Ip6OutDiscards = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Ip6OutNoRoutes && strcmp(name, "Ip6OutNoRoutes") == 0)) Ip6OutNoRoutes = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Ip6ReasmTimeout && strcmp(name, "Ip6ReasmTimeout") == 0)) Ip6ReasmTimeout = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Ip6ReasmReqds && strcmp(name, "Ip6ReasmReqds") == 0)) Ip6ReasmReqds = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Ip6ReasmOKs && strcmp(name, "Ip6ReasmOKs") == 0)) Ip6ReasmOKs = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Ip6ReasmFails && strcmp(name, "Ip6ReasmFails") == 0)) Ip6ReasmFails = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Ip6FragOKs && strcmp(name, "Ip6FragOKs") == 0)) Ip6FragOKs = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Ip6FragFails && strcmp(name, "Ip6FragFails") == 0)) Ip6FragFails = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Ip6FragCreates && strcmp(name, "Ip6FragCreates") == 0)) Ip6FragCreates = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Ip6InMcastPkts && strcmp(name, "Ip6InMcastPkts") == 0)) Ip6InMcastPkts = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Ip6OutMcastPkts && strcmp(name, "Ip6OutMcastPkts") == 0)) Ip6OutMcastPkts = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Ip6InOctets && strcmp(name, "Ip6InOctets") == 0)) Ip6InOctets = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Ip6OutOctets && strcmp(name, "Ip6OutOctets") == 0)) Ip6OutOctets = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Ip6InMcastOctets && strcmp(name, "Ip6InMcastOctets") == 0)) Ip6InMcastOctets = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Ip6OutMcastOctets && strcmp(name, "Ip6OutMcastOctets") == 0)) Ip6OutMcastOctets = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Ip6InBcastOctets && strcmp(name, "Ip6InBcastOctets") == 0)) Ip6InBcastOctets = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Ip6OutBcastOctets && strcmp(name, "Ip6OutBcastOctets") == 0)) Ip6OutBcastOctets = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Ip6InNoECTPkts && strcmp(name, "Ip6InNoECTPkts") == 0)) Ip6InNoECTPkts = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Ip6InECT1Pkts && strcmp(name, "Ip6InECT1Pkts") == 0)) Ip6InECT1Pkts = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Ip6InECT0Pkts && strcmp(name, "Ip6InECT0Pkts") == 0)) Ip6InECT0Pkts = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Ip6InCEPkts && strcmp(name, "Ip6InCEPkts") == 0)) Ip6InCEPkts = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Icmp6InMsgs && strcmp(name, "Icmp6InMsgs") == 0)) Icmp6InMsgs = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Icmp6InErrors && strcmp(name, "Icmp6InErrors") == 0)) Icmp6InErrors = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Icmp6OutMsgs && strcmp(name, "Icmp6OutMsgs") == 0)) Icmp6OutMsgs = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Icmp6OutErrors && strcmp(name, "Icmp6OutErrors") == 0)) Icmp6OutErrors = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Icmp6InCsumErrors && strcmp(name, "Icmp6InCsumErrors") == 0)) Icmp6InCsumErrors = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Icmp6InDestUnreachs && strcmp(name, "Icmp6InDestUnreachs") == 0)) Icmp6InDestUnreachs = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Icmp6InPktTooBigs && strcmp(name, "Icmp6InPktTooBigs") == 0)) Icmp6InPktTooBigs = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Icmp6InTimeExcds && strcmp(name, "Icmp6InTimeExcds") == 0)) Icmp6InTimeExcds = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Icmp6InParmProblems && strcmp(name, "Icmp6InParmProblems") == 0)) Icmp6InParmProblems = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Icmp6InEchos && strcmp(name, "Icmp6InEchos") == 0)) Icmp6InEchos = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Icmp6InEchoReplies && strcmp(name, "Icmp6InEchoReplies") == 0)) Icmp6InEchoReplies = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Icmp6InGroupMembQueries && strcmp(name, "Icmp6InGroupMembQueries") == 0)) Icmp6InGroupMembQueries = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Icmp6InGroupMembResponses && strcmp(name, "Icmp6InGroupMembResponses") == 0)) Icmp6InGroupMembResponses = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Icmp6InGroupMembReductions && strcmp(name, "Icmp6InGroupMembReductions") == 0)) Icmp6InGroupMembReductions = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Icmp6InRouterSolicits && strcmp(name, "Icmp6InRouterSolicits") == 0)) Icmp6InRouterSolicits = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Icmp6InRouterAdvertisements && strcmp(name, "Icmp6InRouterAdvertisements") == 0)) Icmp6InRouterAdvertisements = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Icmp6InNeighborSolicits && strcmp(name, "Icmp6InNeighborSolicits") == 0)) Icmp6InNeighborSolicits = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Icmp6InNeighborAdvertisements && strcmp(name, "Icmp6InNeighborAdvertisements") == 0)) Icmp6InNeighborAdvertisements = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Icmp6InRedirects && strcmp(name, "Icmp6InRedirects") == 0)) Icmp6InRedirects = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Icmp6InMLDv2Reports && strcmp(name, "Icmp6InMLDv2Reports") == 0)) Icmp6InMLDv2Reports = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Icmp6OutDestUnreachs && strcmp(name, "Icmp6OutDestUnreachs") == 0)) Icmp6OutDestUnreachs = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Icmp6OutPktTooBigs && strcmp(name, "Icmp6OutPktTooBigs") == 0)) Icmp6OutPktTooBigs = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Icmp6OutTimeExcds && strcmp(name, "Icmp6OutTimeExcds") == 0)) Icmp6OutTimeExcds = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Icmp6OutParmProblems && strcmp(name, "Icmp6OutParmProblems") == 0)) Icmp6OutParmProblems = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Icmp6OutEchos && strcmp(name, "Icmp6OutEchos") == 0)) Icmp6OutEchos = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Icmp6OutEchoReplies && strcmp(name, "Icmp6OutEchoReplies") == 0)) Icmp6OutEchoReplies = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Icmp6OutGroupMembQueries && strcmp(name, "Icmp6OutGroupMembQueries") == 0)) Icmp6OutGroupMembQueries = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Icmp6OutGroupMembResponses && strcmp(name, "Icmp6OutGroupMembResponses") == 0)) Icmp6OutGroupMembResponses = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Icmp6OutGroupMembReductions && strcmp(name, "Icmp6OutGroupMembReductions") == 0)) Icmp6OutGroupMembReductions = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Icmp6OutRouterSolicits && strcmp(name, "Icmp6OutRouterSolicits") == 0)) Icmp6OutRouterSolicits = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Icmp6OutRouterAdvertisements && strcmp(name, "Icmp6OutRouterAdvertisements") == 0)) Icmp6OutRouterAdvertisements = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Icmp6OutNeighborSolicits && strcmp(name, "Icmp6OutNeighborSolicits") == 0)) Icmp6OutNeighborSolicits = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Icmp6OutNeighborAdvertisements && strcmp(name, "Icmp6OutNeighborAdvertisements") == 0)) Icmp6OutNeighborAdvertisements = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Icmp6OutRedirects && strcmp(name, "Icmp6OutRedirects") == 0)) Icmp6OutRedirects = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Icmp6OutMLDv2Reports && strcmp(name, "Icmp6OutMLDv2Reports") == 0)) Icmp6OutMLDv2Reports = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Icmp6InType1 && strcmp(name, "Icmp6InType1") == 0)) Icmp6InType1 = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Icmp6InType128 && strcmp(name, "Icmp6InType128") == 0)) Icmp6InType128 = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Icmp6InType129 && strcmp(name, "Icmp6InType129") == 0)) Icmp6InType129 = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Icmp6InType136 && strcmp(name, "Icmp6InType136") == 0)) Icmp6InType136 = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Icmp6OutType1 && strcmp(name, "Icmp6OutType1") == 0)) Icmp6OutType1 = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Icmp6OutType128 && strcmp(name, "Icmp6OutType128") == 0)) Icmp6OutType128 = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Icmp6OutType129 && strcmp(name, "Icmp6OutType129") == 0)) Icmp6OutType129 = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Icmp6OutType133 && strcmp(name, "Icmp6OutType133") == 0)) Icmp6OutType133 = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Icmp6OutType135 && strcmp(name, "Icmp6OutType135") == 0)) Icmp6OutType135 = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Icmp6OutType143 && strcmp(name, "Icmp6OutType143") == 0)) Icmp6OutType143 = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Udp6InDatagrams && strcmp(name, "Udp6InDatagrams") == 0)) Udp6InDatagrams = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Udp6NoPorts && strcmp(name, "Udp6NoPorts") == 0)) Udp6NoPorts = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Udp6InErrors && strcmp(name, "Udp6InErrors") == 0)) Udp6InErrors = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Udp6OutDatagrams && strcmp(name, "Udp6OutDatagrams") == 0)) Udp6OutDatagrams = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Udp6RcvbufErrors && strcmp(name, "Udp6RcvbufErrors") == 0)) Udp6RcvbufErrors = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Udp6SndbufErrors && strcmp(name, "Udp6SndbufErrors") == 0)) Udp6SndbufErrors = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Udp6InCsumErrors && strcmp(name, "Udp6InCsumErrors") == 0)) Udp6InCsumErrors = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_Udp6IgnoredMulti && strcmp(name, "Udp6IgnoredMulti") == 0)) Udp6IgnoredMulti = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_UdpLite6InDatagrams && strcmp(name, "UdpLite6InDatagrams") == 0)) UdpLite6InDatagrams = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_UdpLite6NoPorts && strcmp(name, "UdpLite6NoPorts") == 0)) UdpLite6NoPorts = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_UdpLite6InErrors && strcmp(name, "UdpLite6InErrors") == 0)) UdpLite6InErrors = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_UdpLite6OutDatagrams && strcmp(name, "UdpLite6OutDatagrams") == 0)) UdpLite6OutDatagrams = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_UdpLite6RcvbufErrors && strcmp(name, "UdpLite6RcvbufErrors") == 0)) UdpLite6RcvbufErrors = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_UdpLite6SndbufErrors && strcmp(name, "UdpLite6SndbufErrors") == 0)) UdpLite6SndbufErrors = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_UdpLite6InCsumErrors && strcmp(name, "UdpLite6InCsumErrors") == 0)) UdpLite6InCsumErrors = strtoull(value, NULL, 10);
     }
 
     RRDSET *st;
@@ -460,7 +463,7 @@ int do_proc_net_snmp6(int update_every, unsigned long long dt) {
     if(do_bandwidth == CONFIG_ONDEMAND_YES || (do_bandwidth == CONFIG_ONDEMAND_ONDEMAND && (Ip6InOctets || Ip6OutOctets))) {
         do_bandwidth = CONFIG_ONDEMAND_YES;
         st = rrdset_find("system.ipv6");
-        if(!st) {
+        if(unlikely(!st)) {
             st = rrdset_create("system", "ipv6", NULL, "network", NULL, "IPv6 Bandwidth", "kilobits/s", 500, update_every, RRDSET_TYPE_AREA);
 
             rrddim_add(st, "received", NULL, 8, 1024, RRDDIM_INCREMENTAL);
@@ -478,7 +481,7 @@ int do_proc_net_snmp6(int update_every, unsigned long long dt) {
     if(do_ip_packets == CONFIG_ONDEMAND_YES || (do_ip_packets == CONFIG_ONDEMAND_ONDEMAND && (Ip6InReceives || Ip6OutRequests || Ip6InDelivers || Ip6OutForwDatagrams))) {
         do_ip_packets = CONFIG_ONDEMAND_YES;
         st = rrdset_find(RRD_TYPE_NET_SNMP6 ".packets");
-        if(!st) {
+        if(unlikely(!st)) {
             st = rrdset_create(RRD_TYPE_NET_SNMP6, "packets", NULL, "packets", NULL, "IPv6 Packets", "packets/s", 3000, update_every, RRDSET_TYPE_LINE);
 
             rrddim_add(st, "received", NULL, 1, 1, RRDDIM_INCREMENTAL);
@@ -500,7 +503,7 @@ int do_proc_net_snmp6(int update_every, unsigned long long dt) {
     if(do_ip_fragsout == CONFIG_ONDEMAND_YES || (do_ip_fragsout == CONFIG_ONDEMAND_ONDEMAND && (Ip6FragOKs || Ip6FragFails || Ip6FragCreates))) {
         do_ip_fragsout = CONFIG_ONDEMAND_YES;
         st = rrdset_find(RRD_TYPE_NET_SNMP6 ".fragsout");
-        if(!st) {
+        if(unlikely(!st)) {
             st = rrdset_create(RRD_TYPE_NET_SNMP6, "fragsout", NULL, "fragments", NULL, "IPv6 Fragments Sent", "packets/s", 3010, update_every, RRDSET_TYPE_LINE);
             st->isdetail = 1;
 
@@ -527,7 +530,7 @@ int do_proc_net_snmp6(int update_every, unsigned long long dt) {
             ))) {
         do_ip_fragsin = CONFIG_ONDEMAND_YES;
         st = rrdset_find(RRD_TYPE_NET_SNMP6 ".fragsin");
-        if(!st) {
+        if(unlikely(!st)) {
             st = rrdset_create(RRD_TYPE_NET_SNMP6, "fragsin", NULL, "fragments", NULL, "IPv6 Fragments Reassembly", "packets/s", 3011, update_every, RRDSET_TYPE_LINE);
             st->isdetail = 1;
 
@@ -560,7 +563,7 @@ int do_proc_net_snmp6(int update_every, unsigned long long dt) {
         ))) {
         do_ip_errors = CONFIG_ONDEMAND_YES;
         st = rrdset_find(RRD_TYPE_NET_SNMP6 ".errors");
-        if(!st) {
+        if(unlikely(!st)) {
             st = rrdset_create(RRD_TYPE_NET_SNMP6, "errors", NULL, "errors", NULL, "IPv6 Errors", "packets/s", 3002, update_every, RRDSET_TYPE_LINE);
             st->isdetail = 1;
 
@@ -597,7 +600,7 @@ int do_proc_net_snmp6(int update_every, unsigned long long dt) {
     if(do_udp_packets == CONFIG_ONDEMAND_YES || (do_udp_packets == CONFIG_ONDEMAND_ONDEMAND && (Udp6InDatagrams || Udp6OutDatagrams))) {
         do_udp_packets = CONFIG_ONDEMAND_YES;
         st = rrdset_find(RRD_TYPE_NET_SNMP6 ".udppackets");
-        if(!st) {
+        if(unlikely(!st)) {
             st = rrdset_create(RRD_TYPE_NET_SNMP6, "udppackets", NULL, "udp", NULL, "IPv6 UDP Packets", "packets/s", 3601, update_every, RRDSET_TYPE_LINE);
 
             rrddim_add(st, "received", NULL, 1, 1, RRDDIM_INCREMENTAL);
@@ -623,7 +626,7 @@ int do_proc_net_snmp6(int update_every, unsigned long long dt) {
         ))) {
         do_udp_errors = CONFIG_ONDEMAND_YES;
         st = rrdset_find(RRD_TYPE_NET_SNMP6 ".udperrors");
-        if(!st) {
+        if(unlikely(!st)) {
             st = rrdset_create(RRD_TYPE_NET_SNMP6, "udperrors", NULL, "udp", NULL, "IPv6 UDP Errors", "events/s", 3701, update_every, RRDSET_TYPE_LINE);
             st->isdetail = 1;
 
@@ -650,7 +653,7 @@ int do_proc_net_snmp6(int update_every, unsigned long long dt) {
     if(do_udplite_packets == CONFIG_ONDEMAND_YES || (do_udplite_packets == CONFIG_ONDEMAND_ONDEMAND && (UdpLite6InDatagrams || UdpLite6OutDatagrams))) {
         do_udplite_packets = CONFIG_ONDEMAND_YES;
         st = rrdset_find(RRD_TYPE_NET_SNMP6 ".udplitepackets");
-        if(!st) {
+        if(unlikely(!st)) {
             st = rrdset_create(RRD_TYPE_NET_SNMP6, "udplitepackets", NULL, "udplite", NULL, "IPv6 UDPlite Packets", "packets/s", 3601, update_every, RRDSET_TYPE_LINE);
 
             rrddim_add(st, "received", NULL, 1, 1, RRDDIM_INCREMENTAL);
@@ -676,7 +679,7 @@ int do_proc_net_snmp6(int update_every, unsigned long long dt) {
         ))) {
         do_udplite_errors = CONFIG_ONDEMAND_YES;
         st = rrdset_find(RRD_TYPE_NET_SNMP6 ".udpliteerrors");
-        if(!st) {
+        if(unlikely(!st)) {
             st = rrdset_create(RRD_TYPE_NET_SNMP6, "udpliteerrors", NULL, "udplite", NULL, "IPv6 UDP Lite Errors", "events/s", 3701, update_every, RRDSET_TYPE_LINE);
             st->isdetail = 1;
 
@@ -701,7 +704,7 @@ int do_proc_net_snmp6(int update_every, unsigned long long dt) {
     if(do_mcast == CONFIG_ONDEMAND_YES || (do_mcast == CONFIG_ONDEMAND_ONDEMAND && (Ip6OutMcastOctets || Ip6InMcastOctets))) {
         do_mcast = CONFIG_ONDEMAND_YES;
         st = rrdset_find(RRD_TYPE_NET_SNMP6 ".mcast");
-        if(!st) {
+        if(unlikely(!st)) {
             st = rrdset_create(RRD_TYPE_NET_SNMP6, "mcast", NULL, "multicast", NULL, "IPv6 Multicast Bandwidth", "kilobits/s", 9000, update_every, RRDSET_TYPE_AREA);
             st->isdetail = 1;
 
@@ -720,7 +723,7 @@ int do_proc_net_snmp6(int update_every, unsigned long long dt) {
     if(do_bcast == CONFIG_ONDEMAND_YES || (do_bcast == CONFIG_ONDEMAND_ONDEMAND && (Ip6OutBcastOctets || Ip6InBcastOctets))) {
         do_bcast = CONFIG_ONDEMAND_YES;
         st = rrdset_find(RRD_TYPE_NET_SNMP6 ".bcast");
-        if(!st) {
+        if(unlikely(!st)) {
             st = rrdset_create(RRD_TYPE_NET_SNMP6, "bcast", NULL, "broadcast", NULL, "IPv6 Broadcast Bandwidth", "kilobits/s", 8000, update_every, RRDSET_TYPE_AREA);
             st->isdetail = 1;
 
@@ -739,7 +742,7 @@ int do_proc_net_snmp6(int update_every, unsigned long long dt) {
     if(do_mcast_p == CONFIG_ONDEMAND_YES || (do_mcast_p == CONFIG_ONDEMAND_ONDEMAND && (Ip6OutMcastPkts || Ip6InMcastPkts))) {
         do_mcast_p = CONFIG_ONDEMAND_YES;
         st = rrdset_find(RRD_TYPE_NET_SNMP6 ".mcastpkts");
-        if(!st) {
+        if(unlikely(!st)) {
             st = rrdset_create(RRD_TYPE_NET_SNMP6, "mcastpkts", NULL, "multicast", NULL, "IPv6 Multicast Packets", "packets/s", 9500, update_every, RRDSET_TYPE_LINE);
             st->isdetail = 1;
 
@@ -758,7 +761,7 @@ int do_proc_net_snmp6(int update_every, unsigned long long dt) {
     if(do_icmp == CONFIG_ONDEMAND_YES || (do_icmp == CONFIG_ONDEMAND_ONDEMAND && (Icmp6InMsgs || Icmp6OutMsgs))) {
         do_icmp = CONFIG_ONDEMAND_YES;
         st = rrdset_find(RRD_TYPE_NET_SNMP6 ".icmp");
-        if(!st) {
+        if(unlikely(!st)) {
             st = rrdset_create(RRD_TYPE_NET_SNMP6, "icmp", NULL, "icmp", NULL, "IPv6 ICMP Messages", "messages/s", 10000, update_every, RRDSET_TYPE_LINE);
 
             rrddim_add(st, "received", NULL, 1, 1, RRDDIM_INCREMENTAL);
@@ -776,7 +779,7 @@ int do_proc_net_snmp6(int update_every, unsigned long long dt) {
     if(do_icmp_redir == CONFIG_ONDEMAND_YES || (do_icmp_redir == CONFIG_ONDEMAND_ONDEMAND && (Icmp6InRedirects || Icmp6OutRedirects))) {
         do_icmp_redir = CONFIG_ONDEMAND_YES;
         st = rrdset_find(RRD_TYPE_NET_SNMP6 ".icmpredir");
-        if(!st) {
+        if(unlikely(!st)) {
             st = rrdset_create(RRD_TYPE_NET_SNMP6, "icmpredir", NULL, "icmp", NULL, "IPv6 ICMP Redirects", "redirects/s", 10050, update_every, RRDSET_TYPE_LINE);
 
             rrddim_add(st, "received", NULL, 1, 1, RRDDIM_INCREMENTAL);
@@ -807,7 +810,7 @@ int do_proc_net_snmp6(int update_every, unsigned long long dt) {
         ))) {
         do_icmp_errors = CONFIG_ONDEMAND_YES;
         st = rrdset_find(RRD_TYPE_NET_SNMP6 ".icmperrors");
-        if(!st) {
+        if(unlikely(!st)) {
             st = rrdset_create(RRD_TYPE_NET_SNMP6, "icmperrors", NULL, "icmp", NULL, "IPv6 ICMP Errors", "errors/s", 10100, update_every, RRDSET_TYPE_LINE);
 
             rrddim_add(st, "InErrors", NULL, 1, 1, RRDDIM_INCREMENTAL);
@@ -850,7 +853,7 @@ int do_proc_net_snmp6(int update_every, unsigned long long dt) {
         ))) {
         do_icmp_echos = CONFIG_ONDEMAND_YES;
         st = rrdset_find(RRD_TYPE_NET_SNMP6 ".icmpechos");
-        if(!st) {
+        if(unlikely(!st)) {
             st = rrdset_create(RRD_TYPE_NET_SNMP6, "icmpechos", NULL, "icmp", NULL, "IPv6 ICMP Echo", "messages/s", 10200, update_every, RRDSET_TYPE_LINE);
 
             rrddim_add(st, "InEchos", NULL, 1, 1, RRDDIM_INCREMENTAL);
@@ -880,7 +883,7 @@ int do_proc_net_snmp6(int update_every, unsigned long long dt) {
         ))) {
         do_icmp_groupmemb = CONFIG_ONDEMAND_YES;
         st = rrdset_find(RRD_TYPE_NET_SNMP6 ".groupmemb");
-        if(!st) {
+        if(unlikely(!st)) {
             st = rrdset_create(RRD_TYPE_NET_SNMP6, "groupmemb", NULL, "icmp", NULL, "IPv6 ICMP Group Membership", "messages/s", 10300, update_every, RRDSET_TYPE_LINE);
 
             rrddim_add(st, "InQueries", NULL, 1, 1, RRDDIM_INCREMENTAL);
@@ -912,7 +915,7 @@ int do_proc_net_snmp6(int update_every, unsigned long long dt) {
         ))) {
         do_icmp_router = CONFIG_ONDEMAND_YES;
         st = rrdset_find(RRD_TYPE_NET_SNMP6 ".icmprouter");
-        if(!st) {
+        if(unlikely(!st)) {
             st = rrdset_create(RRD_TYPE_NET_SNMP6, "icmprouter", NULL, "icmp", NULL, "IPv6 Router Messages", "messages/s", 10400, update_every, RRDSET_TYPE_LINE);
 
             rrddim_add(st, "InSolicits", NULL, 1, 1, RRDDIM_INCREMENTAL);
@@ -940,7 +943,7 @@ int do_proc_net_snmp6(int update_every, unsigned long long dt) {
         ))) {
         do_icmp_neighbor = CONFIG_ONDEMAND_YES;
         st = rrdset_find(RRD_TYPE_NET_SNMP6 ".icmpneighbor");
-        if(!st) {
+        if(unlikely(!st)) {
             st = rrdset_create(RRD_TYPE_NET_SNMP6, "icmpneighbor", NULL, "icmp", NULL, "IPv6 Neighbor Messages", "messages/s", 10500, update_every, RRDSET_TYPE_LINE);
 
             rrddim_add(st, "InSolicits", NULL, 1, 1, RRDDIM_INCREMENTAL);
@@ -962,7 +965,7 @@ int do_proc_net_snmp6(int update_every, unsigned long long dt) {
     if(do_icmp_mldv2 == CONFIG_ONDEMAND_YES || (do_icmp_mldv2 == CONFIG_ONDEMAND_ONDEMAND && (Icmp6InMLDv2Reports || Icmp6OutMLDv2Reports))) {
         do_icmp_mldv2 = CONFIG_ONDEMAND_YES;
         st = rrdset_find(RRD_TYPE_NET_SNMP6 ".icmpmldv2");
-        if(!st) {
+        if(unlikely(!st)) {
             st = rrdset_create(RRD_TYPE_NET_SNMP6, "icmpmldv2", NULL, "icmp", NULL, "IPv6 ICMP MLDv2 Reports", "reports/s", 10600, update_every, RRDSET_TYPE_LINE);
 
             rrddim_add(st, "received", NULL, 1, 1, RRDDIM_INCREMENTAL);
@@ -992,7 +995,7 @@ int do_proc_net_snmp6(int update_every, unsigned long long dt) {
         ))) {
         do_icmp_types = CONFIG_ONDEMAND_YES;
         st = rrdset_find(RRD_TYPE_NET_SNMP6 ".icmptypes");
-        if(!st) {
+        if(unlikely(!st)) {
             st = rrdset_create(RRD_TYPE_NET_SNMP6, "icmptypes", NULL, "icmp", NULL, "IPv6 ICMP Types", "messages/s", 10700, update_every, RRDSET_TYPE_LINE);
 
             rrddim_add(st, "InType1", NULL, 1, 1, RRDDIM_INCREMENTAL);
@@ -1032,7 +1035,7 @@ int do_proc_net_snmp6(int update_every, unsigned long long dt) {
         ))) {
         do_ect = CONFIG_ONDEMAND_YES;
         st = rrdset_find(RRD_TYPE_NET_SNMP6 ".ect");
-        if(!st) {
+        if(unlikely(!st)) {
             st = rrdset_create(RRD_TYPE_NET_SNMP6, "ect", NULL, "packets", NULL, "IPv6 ECT Packets", "packets/s", 10800, update_every, RRDSET_TYPE_LINE);
 
             rrddim_add(st, "InNoECTPkts", NULL, 1, 1, RRDDIM_INCREMENTAL);
index b013158639b8d2aa3f351b5ef0a81d19d213caf7..0187dbbc3f50a2936529f409aa716c4e4fa90497 100644 (file)
@@ -19,28 +19,28 @@ int do_proc_net_softnet_stat(int update_every, unsigned long long dt) {
     static int do_per_core = -1;
     static uint32_t allocated_lines = 0, allocated_columns = 0, *data = NULL;
 
-    if(do_per_core == -1) do_per_core = config_get_boolean("plugin:proc:/proc/net/softnet_stat", "softnet_stat per core", 1);
+    if(unlikely(do_per_core == -1)) do_per_core = config_get_boolean("plugin:proc:/proc/net/softnet_stat", "softnet_stat per core", 1);
 
-    if(!ff) {
+    if(unlikely(!ff)) {
         char filename[FILENAME_MAX + 1];
         snprintfz(filename, FILENAME_MAX, "%s%s", global_host_prefix, "/proc/net/softnet_stat");
         ff = procfile_open(config_get("plugin:proc:/proc/net/softnet_stat", "filename to monitor", filename), " \t", PROCFILE_FLAG_DEFAULT);
+        if(unlikely(!ff)) return 1;
     }
-    if(!ff) return 1;
 
     ff = procfile_readall(ff);
-    if(!ff) return 0; // we return 0, so that we will retry to open it next time
+    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), w;
 
-    if(!lines || !words) {
+    if(unlikely(!lines || !words)) {
         error("Cannot read /proc/net/softnet_stat, %u lines and %u columns reported.", lines, words);
         return 1;
     }
 
-    if(lines > 200) lines = 200;
-    if(words > 50) words = 50;
+    if(unlikely(lines > 200)) lines = 200;
+    if(unlikely(words > 50)) words = 50;
 
     if(unlikely(!data || lines > allocated_lines || words > allocated_columns)) {
         freez(data);
@@ -55,9 +55,10 @@ int do_proc_net_softnet_stat(int update_every, unsigned long long dt) {
     // parse the values
     for(l = 0; l < lines ;l++) {
         words = procfile_linewords(ff, l);
-        if(!words) continue;
+        if(unlikely(!words)) continue;
 
-        if(words > allocated_columns) words = allocated_columns;
+        if(unlikely(words > allocated_columns))
+            words = allocated_columns;
 
         for(w = 0; w < words ; w++) {
             if(unlikely(softnet_column_name(w))) {
@@ -68,7 +69,7 @@ int do_proc_net_softnet_stat(int update_every, unsigned long long dt) {
         }
     }
 
-    if(data[(lines * allocated_columns)] == 0)
+    if(unlikely(data[(lines * allocated_columns)] == 0))
         lines--;
 
     RRDSET *st;
@@ -76,7 +77,7 @@ int do_proc_net_softnet_stat(int update_every, unsigned long long dt) {
     // --------------------------------------------------------------------
 
     st = rrdset_find_bytype("system", "softnet_stat");
-    if(!st) {
+    if(unlikely(!st)) {
         st = rrdset_create("system", "softnet_stat", NULL, "softnet_stat", NULL, "System softnet_stat", "events/s", 955, update_every, RRDSET_TYPE_LINE);
         for(w = 0; w < allocated_columns ;w++)
             if(unlikely(softnet_column_name(w)))
@@ -96,7 +97,7 @@ int do_proc_net_softnet_stat(int update_every, unsigned long long dt) {
             snprintfz(id, 50, "cpu%u_softnet_stat", l);
 
             st = rrdset_find_bytype("cpu", id);
-            if(!st) {
+            if(unlikely(!st)) {
                 char title[100+1];
                 snprintfz(title, 100, "CPU%u softnet_stat", l);
 
index 54e250bf2f2ee7653f6d247a412d71830ea8f7d4..b1fc1f3313367509bdfc03018bfc2098a94bbece 100644 (file)
@@ -2,30 +2,33 @@
 
 #define RRD_TYPE_NET_STAT_NETFILTER     "netfilter"
 #define RRD_TYPE_NET_STAT_CONNTRACK     "conntrack"
-#define RRD_TYPE_NET_STAT_CONNTRACK_LEN strlen(RRD_TYPE_NET_STAT_CONNTRACK)
 
 int do_proc_net_stat_conntrack(int update_every, unsigned long long dt) {
+    (void)dt;
+
     static procfile *ff = NULL;
     static int do_sockets = -1, do_new = -1, do_changes = -1, do_expect = -1, do_search = -1, do_errors = -1;
 
-    if(do_sockets == -1)    do_sockets = config_get_boolean("plugin:proc:/proc/net/stat/nf_conntrack", "netfilter connections", 1);
-    if(do_new == -1)        do_new = config_get_boolean("plugin:proc:/proc/net/stat/nf_conntrack", "netfilter new connections", 1);
-    if(do_changes == -1)    do_changes = config_get_boolean("plugin:proc:/proc/net/stat/nf_conntrack", "netfilter connection changes", 1);
-    if(do_expect == -1)     do_expect = config_get_boolean("plugin:proc:/proc/net/stat/nf_conntrack", "netfilter connection expectations", 1);
-    if(do_search == -1)     do_search = config_get_boolean("plugin:proc:/proc/net/stat/nf_conntrack", "netfilter connection searches", 1);
-    if(do_errors == -1)     do_errors = config_get_boolean("plugin:proc:/proc/net/stat/nf_conntrack", "netfilter errors", 1);
-
-    if(dt) {};
+    if(unlikely(do_sockets == -1)) {
+        do_sockets = config_get_boolean("plugin:proc:/proc/net/stat/nf_conntrack", "netfilter connections", 1);
+        do_new = config_get_boolean("plugin:proc:/proc/net/stat/nf_conntrack", "netfilter new connections", 1);
+        do_changes = config_get_boolean("plugin:proc:/proc/net/stat/nf_conntrack", "netfilter connection changes", 1);
+        do_expect = config_get_boolean("plugin:proc:/proc/net/stat/nf_conntrack", "netfilter connection expectations", 1);
+        do_search = config_get_boolean("plugin:proc:/proc/net/stat/nf_conntrack", "netfilter connection searches", 1);
+        do_errors = config_get_boolean("plugin:proc:/proc/net/stat/nf_conntrack", "netfilter errors", 1);
+    }
 
-    if(!ff) {
+    if(unlikely(!ff)) {
         char filename[FILENAME_MAX + 1];
         snprintfz(filename, FILENAME_MAX, "%s%s", global_host_prefix, "/proc/net/stat/nf_conntrack");
         ff = procfile_open(config_get("plugin:proc:/proc/net/stat/nf_conntrack", "filename to monitor", filename), " \t:", PROCFILE_FLAG_DEFAULT);
+        if(unlikely(!ff))
+            return 1;
     }
-    if(!ff) return 1;
 
     ff = procfile_readall(ff);
-    if(!ff) return 0; // we return 0, so that we will retry to open it next time
+    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;
@@ -35,8 +38,8 @@ int do_proc_net_stat_conntrack(int update_every, unsigned long long dt) {
 
     for(l = 1; l < lines ;l++) {
         words = procfile_linewords(ff, l);
-        if(words < 17) {
-            if(words) error("Cannot read /proc/net/stat/nf_conntrack line. Expected 17 params, read %u.", words);
+        if(unlikely(words < 17)) {
+            if(unlikely(words)) error("Cannot read /proc/net/stat/nf_conntrack line. Expected 17 params, read %u.", words);
             continue;
         }
 
@@ -60,7 +63,7 @@ int do_proc_net_stat_conntrack(int update_every, unsigned long long dt) {
         texpect_delete  = strtoull(procfile_lineword(ff, l, 15), NULL, 16);
         tsearch_restart = strtoull(procfile_lineword(ff, l, 16), NULL, 16);
 
-        if(!aentries) aentries =  tentries;
+        if(unlikely(!aentries)) aentries =  tentries;
 
         // sum all the cpus together
         asearched           += tsearched;       // conntrack.search
@@ -87,7 +90,7 @@ int do_proc_net_stat_conntrack(int update_every, unsigned long long dt) {
 
     if(do_sockets) {
         st = rrdset_find(RRD_TYPE_NET_STAT_NETFILTER "." RRD_TYPE_NET_STAT_CONNTRACK "_sockets");
-        if(!st) {
+        if(unlikely(!st)) {
             st = rrdset_create(RRD_TYPE_NET_STAT_NETFILTER, RRD_TYPE_NET_STAT_CONNTRACK "_sockets", NULL, RRD_TYPE_NET_STAT_CONNTRACK, NULL, "Connection Tracker Connections", "active connections", 3000, update_every, RRDSET_TYPE_LINE);
 
             rrddim_add(st, "connections", NULL, 1, 1, RRDDIM_ABSOLUTE);
@@ -102,7 +105,7 @@ int do_proc_net_stat_conntrack(int update_every, unsigned long long dt) {
 
     if(do_new) {
         st = rrdset_find(RRD_TYPE_NET_STAT_NETFILTER "." RRD_TYPE_NET_STAT_CONNTRACK "_new");
-        if(!st) {
+        if(unlikely(!st)) {
             st = rrdset_create(RRD_TYPE_NET_STAT_NETFILTER, RRD_TYPE_NET_STAT_CONNTRACK "_new", NULL, RRD_TYPE_NET_STAT_CONNTRACK, NULL, "Connection Tracker New Connections", "connections/s", 3001, update_every, RRDSET_TYPE_LINE);
 
             rrddim_add(st, "new", NULL, 1, 1, RRDDIM_INCREMENTAL);
@@ -121,7 +124,7 @@ int do_proc_net_stat_conntrack(int update_every, unsigned long long dt) {
 
     if(do_changes) {
         st = rrdset_find(RRD_TYPE_NET_STAT_NETFILTER "." RRD_TYPE_NET_STAT_CONNTRACK "_changes");
-        if(!st) {
+        if(unlikely(!st)) {
             st = rrdset_create(RRD_TYPE_NET_STAT_NETFILTER, RRD_TYPE_NET_STAT_CONNTRACK "_changes", NULL, RRD_TYPE_NET_STAT_CONNTRACK, NULL, "Connection Tracker Changes", "changes/s", 3002, update_every, RRDSET_TYPE_LINE);
             st->isdetail = 1;
 
@@ -141,7 +144,7 @@ int do_proc_net_stat_conntrack(int update_every, unsigned long long dt) {
 
     if(do_expect) {
         st = rrdset_find(RRD_TYPE_NET_STAT_NETFILTER "." RRD_TYPE_NET_STAT_CONNTRACK "_expect");
-        if(!st) {
+        if(unlikely(!st)) {
             st = rrdset_create(RRD_TYPE_NET_STAT_NETFILTER, RRD_TYPE_NET_STAT_CONNTRACK "_expect", NULL, RRD_TYPE_NET_STAT_CONNTRACK, NULL, "Connection Tracker Expectations", "expectations/s", 3003, update_every, RRDSET_TYPE_LINE);
             st->isdetail = 1;
 
@@ -161,7 +164,7 @@ int do_proc_net_stat_conntrack(int update_every, unsigned long long dt) {
 
     if(do_search) {
         st = rrdset_find(RRD_TYPE_NET_STAT_NETFILTER "." RRD_TYPE_NET_STAT_CONNTRACK "_search");
-        if(!st) {
+        if(unlikely(!st)) {
             st = rrdset_create(RRD_TYPE_NET_STAT_NETFILTER, RRD_TYPE_NET_STAT_CONNTRACK "_search", NULL, RRD_TYPE_NET_STAT_CONNTRACK, NULL, "Connection Tracker Searches", "searches/s", 3010, update_every, RRDSET_TYPE_LINE);
             st->isdetail = 1;
 
@@ -181,7 +184,7 @@ int do_proc_net_stat_conntrack(int update_every, unsigned long long dt) {
 
     if(do_errors) {
         st = rrdset_find(RRD_TYPE_NET_STAT_NETFILTER "." RRD_TYPE_NET_STAT_CONNTRACK "_errors");
-        if(!st) {
+        if(unlikely(!st)) {
             st = rrdset_create(RRD_TYPE_NET_STAT_NETFILTER, RRD_TYPE_NET_STAT_CONNTRACK "_errors", NULL, RRD_TYPE_NET_STAT_CONNTRACK, NULL, "Connection Tracker Errors", "events/s", 3005, update_every, RRDSET_TYPE_LINE);
             st->isdetail = 1;
 
index 102805f7048a6dbf89ab13677242fdfd499f153a..01c91978b50d31424080548935522da806d1f304 100644 (file)
@@ -2,32 +2,35 @@
 
 #define RRD_TYPE_NET_STAT_NETFILTER         "netfilter"
 #define RRD_TYPE_NET_STAT_SYNPROXY          "synproxy"
-#define RRD_TYPE_NET_STAT_SYNPROXY_LEN      strlen(RRD_TYPE_NET_STAT_SYNPROXY)
 
 int do_proc_net_stat_synproxy(int update_every, unsigned long long dt) {
+    (void)dt;
+
     static int do_entries = -1, do_cookies = -1, do_syns = -1, do_reopened = -1;
     static procfile *ff = NULL;
 
-    if(do_entries == -1)    do_entries  = config_get_boolean_ondemand("plugin:proc:/proc/net/stat/synproxy", "SYNPROXY entries", CONFIG_ONDEMAND_ONDEMAND);
-    if(do_cookies == -1)    do_cookies  = config_get_boolean_ondemand("plugin:proc:/proc/net/stat/synproxy", "SYNPROXY cookies", CONFIG_ONDEMAND_ONDEMAND);
-    if(do_syns == -1)       do_syns     = config_get_boolean_ondemand("plugin:proc:/proc/net/stat/synproxy", "SYNPROXY SYN received", CONFIG_ONDEMAND_ONDEMAND);
-    if(do_reopened == -1)   do_reopened = config_get_boolean_ondemand("plugin:proc:/proc/net/stat/synproxy", "SYNPROXY connections reopened", CONFIG_ONDEMAND_ONDEMAND);
-
-    if(dt) {};
+    if(unlikely(do_entries == -1)) {
+        do_entries  = config_get_boolean_ondemand("plugin:proc:/proc/net/stat/synproxy", "SYNPROXY entries", CONFIG_ONDEMAND_ONDEMAND);
+        do_cookies  = config_get_boolean_ondemand("plugin:proc:/proc/net/stat/synproxy", "SYNPROXY cookies", CONFIG_ONDEMAND_ONDEMAND);
+        do_syns     = config_get_boolean_ondemand("plugin:proc:/proc/net/stat/synproxy", "SYNPROXY SYN received", CONFIG_ONDEMAND_ONDEMAND);
+        do_reopened = config_get_boolean_ondemand("plugin:proc:/proc/net/stat/synproxy", "SYNPROXY connections reopened", CONFIG_ONDEMAND_ONDEMAND);
+    }
 
-    if(!ff) {
+    if(unlikely(!ff)) {
         char filename[FILENAME_MAX + 1];
         snprintfz(filename, FILENAME_MAX, "%s%s", global_host_prefix, "/proc/net/stat/synproxy");
         ff = procfile_open(config_get("plugin:proc:/proc/net/stat/synproxy", "filename to monitor", filename), " \t,:|", PROCFILE_FLAG_DEFAULT);
+        if(unlikely(!ff))
+            return 1;
     }
-    if(!ff) return 1;
 
     ff = procfile_readall(ff);
-    if(!ff) return 0; // we return 0, so that we will retry to open it next time
+    if(unlikely(!ff))
+        return 0; // we return 0, so that we will retry to open it next time
 
     // make sure we have 3 lines
     size_t lines = procfile_lines(ff), l;
-    if(lines < 2) {
+    if(unlikely(lines < 2)) {
         error("/proc/net/stat/synproxy has %zu lines, expected no less than 2. Disabling it.", lines);
         return 1;
     }
@@ -37,7 +40,8 @@ int do_proc_net_stat_synproxy(int update_every, unsigned long long dt) {
     // synproxy gives its values per CPU
     for(l = 1; l < lines ;l++) {
         int words = procfile_linewords(ff, l);
-        if(words < 6) continue;
+        if(unlikely(words < 6))
+            continue;
 
         entries         += strtoull(procfile_lineword(ff, l, 0), NULL, 16);
         syn_received    += strtoull(procfile_lineword(ff, l, 1), NULL, 16);
@@ -57,7 +61,7 @@ int do_proc_net_stat_synproxy(int update_every, unsigned long long dt) {
         do_entries = CONFIG_ONDEMAND_YES;
 
         st = rrdset_find(RRD_TYPE_NET_STAT_NETFILTER "." RRD_TYPE_NET_STAT_SYNPROXY "_entries");
-        if(!st) {
+        if(unlikely(!st)) {
             st = rrdset_create(RRD_TYPE_NET_STAT_NETFILTER, RRD_TYPE_NET_STAT_SYNPROXY "_entries", NULL, RRD_TYPE_NET_STAT_SYNPROXY, NULL, "SYNPROXY Entries Used", "entries", 3304, update_every, RRDSET_TYPE_LINE);
 
             rrddim_add(st, "entries", NULL, 1, 1, RRDDIM_ABSOLUTE);
@@ -74,7 +78,7 @@ int do_proc_net_stat_synproxy(int update_every, unsigned long long dt) {
         do_syns = CONFIG_ONDEMAND_YES;
 
         st = rrdset_find(RRD_TYPE_NET_STAT_NETFILTER "." RRD_TYPE_NET_STAT_SYNPROXY "_syn_received");
-        if(!st) {
+        if(unlikely(!st)) {
             st = rrdset_create(RRD_TYPE_NET_STAT_NETFILTER, RRD_TYPE_NET_STAT_SYNPROXY "_syn_received", NULL, RRD_TYPE_NET_STAT_SYNPROXY, NULL, "SYNPROXY SYN Packets received", "SYN/s", 3301, update_every, RRDSET_TYPE_LINE);
 
             rrddim_add(st, "received", NULL, 1, 1, RRDDIM_INCREMENTAL);
@@ -91,7 +95,7 @@ int do_proc_net_stat_synproxy(int update_every, unsigned long long dt) {
         do_reopened = CONFIG_ONDEMAND_YES;
 
         st = rrdset_find(RRD_TYPE_NET_STAT_NETFILTER "." RRD_TYPE_NET_STAT_SYNPROXY "_conn_reopened");
-        if(!st) {
+        if(unlikely(!st)) {
             st = rrdset_create(RRD_TYPE_NET_STAT_NETFILTER, RRD_TYPE_NET_STAT_SYNPROXY "_conn_reopened", NULL, RRD_TYPE_NET_STAT_SYNPROXY, NULL, "SYNPROXY Connections Reopened", "connections/s", 3303, update_every, RRDSET_TYPE_LINE);
 
             rrddim_add(st, "reopened", NULL, 1, 1, RRDDIM_INCREMENTAL);
@@ -108,7 +112,7 @@ int do_proc_net_stat_synproxy(int update_every, unsigned long long dt) {
         do_cookies = CONFIG_ONDEMAND_YES;
 
         st = rrdset_find(RRD_TYPE_NET_STAT_NETFILTER "." RRD_TYPE_NET_STAT_SYNPROXY "_cookies");
-        if(!st) {
+        if(unlikely(!st)) {
             st = rrdset_create(RRD_TYPE_NET_STAT_NETFILTER, RRD_TYPE_NET_STAT_SYNPROXY "_cookies", NULL, RRD_TYPE_NET_STAT_SYNPROXY, NULL, "SYNPROXY TCP Cookies", "cookies/s", 3302, update_every, RRDSET_TYPE_LINE);
 
             rrddim_add(st, "valid", NULL, 1, 1, RRDDIM_INCREMENTAL);
index 22be1aa630a51718bf49b8d5f1aa608afae620e1..3b1ecded3cf92316f70704f1911abb6d0beeebef 100644 (file)
@@ -49,7 +49,7 @@ struct mountinfo *mountinfo_find(struct mountinfo *root, unsigned long major, un
     struct mountinfo *mi;
 
     for(mi = root; mi ; mi = mi->next)
-        if(mi->major == major && mi->minor == minor)
+        if(unlikely(mi->major == major && mi->minor == minor))
             return mi;
 
     return NULL;
@@ -62,12 +62,12 @@ struct mountinfo *mountinfo_find_by_filesystem_mount_source(struct mountinfo *ro
     uint32_t filesystem_hash = simple_hash(filesystem), mount_source_hash = simple_hash(mount_source);
 
     for(mi = root; mi ; mi = mi->next)
-        if(mi->filesystem
+        if(unlikely(mi->filesystem
                 && mi->mount_source
                 && mi->filesystem_hash == filesystem_hash
                 && mi->mount_source_hash == mount_source_hash
                 && !strcmp(mi->filesystem, filesystem)
-                && !strcmp(mi->mount_source, mount_source))
+                && !strcmp(mi->mount_source, mount_source)))
             return mi;
 
     return NULL;
@@ -80,10 +80,10 @@ struct mountinfo *mountinfo_find_by_filesystem_super_option(struct mountinfo *ro
     size_t solen = strlen(super_options);
 
     for(mi = root; mi ; mi = mi->next)
-        if(mi->filesystem
+        if(unlikely(mi->filesystem
                 && mi->super_options
                 && mi->filesystem_hash == filesystem_hash
-                && !strcmp(mi->filesystem, filesystem)) {
+                && !strcmp(mi->filesystem, filesystem))) {
 
             // super_options is a comma separated list
             char *s = mi->super_options, *e;
@@ -92,7 +92,7 @@ struct mountinfo *mountinfo_find_by_filesystem_super_option(struct mountinfo *ro
                 while(*e && *e != ',') e++;
 
                 size_t len = e - s;
-                if(len == solen && !strncmp(s, super_options, len))
+                if(unlikely(len == solen && !strncmp(s, super_options, len)))
                     return mi;
 
                 if(*e == ',') s = ++e;
@@ -164,20 +164,21 @@ struct mountinfo *mountinfo_read() {
     char filename[FILENAME_MAX + 1];
     snprintfz(filename, FILENAME_MAX, "%s/proc/self/mountinfo", global_host_prefix);
     ff = procfile_open(filename, " \t", PROCFILE_FLAG_DEFAULT);
-    if(!ff) {
+    if(unlikely(!ff)) {
         snprintfz(filename, FILENAME_MAX, "%s/proc/1/mountinfo", global_host_prefix);
         ff = procfile_open(filename, " \t", PROCFILE_FLAG_DEFAULT);
-        if(!ff) return NULL;
+        if(unlikely(!ff)) return NULL;
     }
 
     ff = procfile_readall(ff);
-    if(!ff) return NULL;
+    if(unlikely(!ff))
+        return NULL;
 
     struct mountinfo *root = NULL, *last = NULL, *mi = NULL;
 
     unsigned long l, lines = procfile_lines(ff);
     for(l = 0; l < lines ;l++) {
-        if(procfile_linewords(ff, l) < 5)
+        if(unlikely(procfile_linewords(ff, l) < 5))
             continue;
 
         mi = mallocz(sizeof(struct mountinfo));
@@ -189,7 +190,7 @@ struct mountinfo *mountinfo_read() {
         char *major = procfile_lineword(ff, l, w), *minor; w++;
         for(minor = major; *minor && *minor != ':' ;minor++) ;
 
-        if(!*minor) {
+        if(unlikely(!*minor)) {
             error("Cannot parse major:minor on '%s' at line %lu of '%s'", major, l + 1, filename);
             freez(mi);
             continue;
@@ -232,14 +233,11 @@ struct mountinfo *mountinfo_read() {
             // we have some optional fields
             // read them into a new array of pointers;
 
-            mi->optional_fields = malloc(mi->optional_fields_count * sizeof(char *));
-            if(unlikely(!mi->optional_fields))
-                fatal("Cannot allocate memory for %d mountinfo optional fields", mi->optional_fields_count);
+            mi->optional_fields = mallocz(mi->optional_fields_count * sizeof(char *));
 
             int i;
             for(i = 0; i < mi->optional_fields_count ; i++) {
-                *mi->optional_fields[wo] = strdup(procfile_lineword(ff, l, w));
-                if(!mi->optional_fields[wo]) fatal("Cannot allocate memory");
+                *mi->optional_fields[wo] = strdupz(procfile_lineword(ff, l, w));
                 wo++;
             }
         }
@@ -258,10 +256,10 @@ struct mountinfo *mountinfo_read() {
 
             mi->super_options = strdupz(procfile_lineword(ff, l, w)); w++;
 
-            if(ME_DUMMY(mi->mount_source, mi->filesystem))
+            if(unlikely(ME_DUMMY(mi->mount_source, mi->filesystem)))
                 mi->flags |= MOUNTINFO_IS_DUMMY;
 
-            if(ME_REMOTE(mi->mount_source, mi->filesystem))
+            if(unlikely(ME_REMOTE(mi->mount_source, mi->filesystem)))
                 mi->flags |= MOUNTINFO_IS_REMOTE;
 
             // mark as BIND the duplicates (i.e. same filesystem + same source)
@@ -301,10 +299,10 @@ struct mountinfo *mountinfo_read() {
         // check if it has size
         {
             struct statvfs buff_statvfs;
-            if(statvfs(mi->mount_point, &buff_statvfs) < 0) {
+            if(unlikely(statvfs(mi->mount_point, &buff_statvfs) < 0)) {
                 mi->flags |= MOUNTINFO_NO_STAT;
             }
-            else if(!buff_statvfs.f_blocks /* || !buff_statvfs.f_files */) {
+            else if(unlikely(!buff_statvfs.f_blocks /* || !buff_statvfs.f_files */)) {
                 mi->flags |= MOUNTINFO_NO_SIZE;
             }
         }
@@ -353,10 +351,10 @@ struct mountinfo *mountinfo_read() {
 
             while ((mnt = getmntent_r(fp, &mntbuf, buf, 4096))) {
                 char *bind = hasmntopt(mnt, "bind");
-                if(bind) {
+                if(unlikely(bind)) {
                     struct mountinfo *mi;
                     for(mi = root; mi ; mi = mi->next) {
-                        if(strcmp(mnt->mnt_dir, mi->mount_point) == 0) {
+                        if(unlikely(strcmp(mnt->mnt_dir, mi->mount_point) == 0)) {
                             fprintf(stderr, "Mount point '%s' is BIND\n", mi->mount_point);
                             mi->flags |= MOUNTINFO_IS_BIND;
                             break;
@@ -364,7 +362,7 @@ struct mountinfo *mountinfo_read() {
                     }
 
 #ifdef NETDATA_INTERNAL_CHECKS
-                    if(!mi) {
+                    if(unlikely(!mi)) {
                         error("Mount point '%s' not found in /proc/self/mountinfo", mnt->mnt_dir);
                     }
 #endif
index ebbbf2aeb5f0ee6a023ed05e7a09a2c9b84c3ab4..5346026c9e825c1ec329ad50bca94e626aff722e 100644 (file)
@@ -21,7 +21,7 @@ static inline struct interrupt *get_interrupts_array(int lines, int cpus) {
     static struct interrupt *irrs = NULL;
     static int allocated = 0;
 
-    if(lines > allocated) {
+    if(unlikely(lines > allocated)) {
         irrs = (struct interrupt *)reallocz(irrs, lines * recordsize(cpus));
         allocated = lines;
     }
@@ -30,43 +30,43 @@ static inline struct interrupt *get_interrupts_array(int lines, int cpus) {
 }
 
 int do_proc_softirqs(int update_every, unsigned long long dt) {
+    (void)dt;
+
     static procfile *ff = NULL;
     static int cpus = -1, do_per_core = -1;
 
     struct interrupt *irrs = NULL;
 
-    if(dt) {};
-
-    if(do_per_core == -1) do_per_core = config_get_boolean("plugin:proc:/proc/softirqs", "interrupts per core", 1);
+    if(unlikely(do_per_core == -1)) do_per_core = config_get_boolean("plugin:proc:/proc/softirqs", "interrupts per core", 1);
 
-    if(!ff) {
+    if(unlikely(!ff)) {
         char filename[FILENAME_MAX + 1];
         snprintfz(filename, FILENAME_MAX, "%s%s", global_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;
     }
-    if(!ff) return 1;
 
     ff = procfile_readall(ff);
-    if(!ff) return 0; // we return 0, so that we will retry to open it next time
+    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), w;
 
-    if(!lines) {
+    if(unlikely(!lines)) {
         error("Cannot read /proc/softirqs, zero lines reported.");
         return 1;
     }
 
     // find how many CPUs are there
-    if(cpus == -1) {
+    if(unlikely(cpus == -1)) {
         cpus = 0;
         for(w = 0; w < words ; w++) {
-            if(strncmp(procfile_lineword(ff, 0, w), "CPU", 3) == 0)
+            if(unlikely(strncmp(procfile_lineword(ff, 0, w), "CPU", 3) == 0))
                 cpus++;
         }
     }
 
-    if(!cpus) {
+    if(unlikely(!cpus)) {
         error("PLUGIN: PROC_SOFTIRQS: Cannot find the number of CPUs in /proc/softirqs");
         return 1;
     }
@@ -82,18 +82,18 @@ int do_proc_softirqs(int update_every, unsigned long long dt) {
         irr->total = 0;
 
         words = procfile_linewords(ff, l);
-        if(!words) continue;
+        if(unlikely(!words)) continue;
 
         irr->id = procfile_lineword(ff, l, 0);
-        if(!irr->id || !irr->id[0]) continue;
+        if(unlikely(!irr->id || !irr->id[0])) continue;
 
         int idlen = strlen(irr->id);
-        if(irr->id[idlen - 1] == ':')
+        if(unlikely(irr->id[idlen - 1] == ':'))
             irr->id[idlen - 1] = '\0';
 
         int c;
         for(c = 0; c < cpus ;c++) {
-            if((c + 1) < (int)words)
+            if(unlikely((c + 1) < (int)words))
                 irr->value[c] = strtoull(procfile_lineword(ff, l, (uint32_t)(c + 1)), NULL, 10);
             else
                 irr->value[c] = 0;
@@ -111,12 +111,12 @@ int do_proc_softirqs(int update_every, unsigned long long dt) {
     // --------------------------------------------------------------------
 
     st = rrdset_find_bytype("system", "softirqs");
-    if(!st) {
+    if(unlikely(!st)) {
         st = rrdset_create("system", "softirqs", NULL, "softirqs", NULL, "System softirqs", "softirqs/s", 950, update_every, RRDSET_TYPE_STACKED);
 
         for(l = 0; l < lines ;l++) {
             struct interrupt *irr = irrindex(irrs, l, cpus);
-            if(!irr->used) continue;
+            if(unlikely(!irr->used)) continue;
             rrddim_add(st, irr->id, irr->name, 1, 1, RRDDIM_INCREMENTAL);
         }
     }
@@ -124,7 +124,7 @@ int do_proc_softirqs(int update_every, unsigned long long dt) {
 
     for(l = 0; l < lines ;l++) {
         struct interrupt *irr = irrindex(irrs, l, cpus);
-        if(!irr->used) continue;
+        if(unlikely(!irr->used)) continue;
         rrddim_set(st, irr->id, irr->total);
     }
     rrdset_done(st);
@@ -137,15 +137,15 @@ int do_proc_softirqs(int update_every, unsigned long long dt) {
             snprintfz(id, 50, "cpu%d_softirqs", c);
 
             st = rrdset_find_bytype("cpu", id);
-            if(!st) {
+            if(unlikely(!st)) {
                 // find if everything is zero
                 unsigned long long core_sum = 0 ;
                 for(l = 0; l < lines ;l++) {
                     struct interrupt *irr = irrindex(irrs, l, cpus);
-                    if(!irr->used) continue;
+                    if(unlikely(!irr->used)) continue;
                     core_sum += irr->value[c];
                 }
-                if(core_sum == 0) continue; // try next core
+                if(unlikely(core_sum == 0)) continue; // try next core
 
                 char title[100+1];
                 snprintfz(title, 100, "CPU%d softirqs", c);
@@ -153,7 +153,7 @@ int do_proc_softirqs(int update_every, unsigned long long dt) {
 
                 for(l = 0; l < lines ;l++) {
                     struct interrupt *irr = irrindex(irrs, l, cpus);
-                    if(!irr->used) continue;
+                    if(unlikely(!irr->used)) continue;
                     rrddim_add(st, irr->id, irr->name, 1, 1, RRDDIM_INCREMENTAL);
                 }
             }
@@ -161,7 +161,7 @@ int do_proc_softirqs(int update_every, unsigned long long dt) {
 
             for(l = 0; l < lines ;l++) {
                 struct interrupt *irr = irrindex(irrs, l, cpus);
-                if(!irr->used) continue;
+                if(unlikely(!irr->used)) continue;
                 rrddim_set(st, irr->id, irr->value[c]);
             }
             rrdset_done(st);
index 88cb820b38d16f5808dc4a7967efa87c39f13af8..0e34f2eeec8017123fb352121eacc701c3b3d0ef 100644 (file)
@@ -126,7 +126,7 @@ int do_proc_stat(int update_every, unsigned long long dt) {
                 rrdset_done(st);
             }
         }
-        else if(hash == hash_intr && strcmp(row_key, "intr") == 0) {
+        else if(unlikely(hash == hash_intr && strcmp(row_key, "intr") == 0)) {
             unsigned long long value = strtoull(procfile_lineword(ff, l, 1), NULL, 10);
 
             // --------------------------------------------------------------------
@@ -145,7 +145,7 @@ int do_proc_stat(int update_every, unsigned long long dt) {
                 rrdset_done(st);
             }
         }
-        else if(hash == hash_ctxt && strcmp(row_key, "ctxt") == 0) {
+        else if(unlikely(hash == hash_ctxt && strcmp(row_key, "ctxt") == 0)) {
             unsigned long long value = strtoull(procfile_lineword(ff, l, 1), NULL, 10);
 
             // --------------------------------------------------------------------
@@ -163,13 +163,13 @@ int do_proc_stat(int update_every, unsigned long long dt) {
                 rrdset_done(st);
             }
         }
-        else if(hash == hash_processes && !processes && strcmp(row_key, "processes") == 0) {
+        else if(unlikely(hash == hash_processes && !processes && strcmp(row_key, "processes") == 0)) {
             processes = strtoull(procfile_lineword(ff, l, 1), NULL, 10);
         }
-        else if(hash == hash_procs_running && !running && strcmp(row_key, "procs_running") == 0) {
+        else if(unlikely(hash == hash_procs_running && !running && strcmp(row_key, "procs_running") == 0)) {
             running = strtoull(procfile_lineword(ff, l, 1), NULL, 10);
         }
-        else if(hash == hash_procs_blocked && !blocked && strcmp(row_key, "procs_blocked") == 0) {
+        else if(unlikely(hash == hash_procs_blocked && !blocked && strcmp(row_key, "procs_blocked") == 0)) {
             blocked = strtoull(procfile_lineword(ff, l, 1), NULL, 10);
         }
     }
index 9515dad61693cf31d5372a7e160da1f55fcf2788..bde74f452196b7f35e2ee3e7c1e28793c56e1303 100644 (file)
@@ -1,24 +1,24 @@
 #include "common.h"
 
 int do_proc_sys_kernel_random_entropy_avail(int update_every, unsigned long long dt) {
-    static procfile *ff = NULL;
+    (void)dt;
 
-    if(dt) {} ;
+    static procfile *ff = NULL;
 
-    if(!ff) {
+    if(unlikely(!ff)) {
         char filename[FILENAME_MAX + 1];
         snprintfz(filename, FILENAME_MAX, "%s%s", global_host_prefix, "/proc/sys/kernel/random/entropy_avail");
         ff = procfile_open(config_get("plugin:proc:/proc/sys/kernel/random/entropy_avail", "filename to monitor", filename), "", PROCFILE_FLAG_DEFAULT);
+        if(unlikely(!ff)) return 1;
     }
-    if(!ff) return 1;
 
     ff = procfile_readall(ff);
-    if(!ff) return 0; // we return 0, so that we will retry to open it next time
+    if(unlikely(!ff)) return 0; // we return 0, so that we will retry to open it next time
 
     unsigned long long entropy = strtoull(procfile_lineword(ff, 0, 0), NULL, 10);
 
     RRDSET *st = rrdset_find_bytype("system", "entropy");
-    if(!st) {
+    if(unlikely(!st)) {
         st = rrdset_create("system", "entropy", NULL, "entropy", NULL, "Available Entropy", "entropy", 1000, update_every, RRDSET_TYPE_LINE);
         rrddim_add(st, "entropy", NULL, 1, 1, RRDDIM_ABSOLUTE);
     }
index 5f4e5aaddd7fb124af88c0ac0fc21be516c3f2cb..3615f56f6333510adf9ff45b8919b7cbc22cf3c5 100644 (file)
 #include "common.h"
 
 int do_proc_vmstat(int update_every, unsigned long long dt) {
+    (void)dt;
+
     static procfile *ff = NULL;
-    static int do_swapio = -1, do_io = -1, do_pgfaults = -1, gen_hashes = -1;
+    static int do_swapio = -1, do_io = -1, do_pgfaults = -1;
+
+    // static uint32_t hash_allocstall = 0;
+    // static uint32_t hash_compact_blocks_moved = 0;
+    // static uint32_t hash_compact_fail = 0;
+    // static uint32_t hash_compact_pagemigrate_failed = 0;
+    // static uint32_t hash_compact_pages_moved = 0;
+    // static uint32_t hash_compact_stall = 0;
+    // static uint32_t hash_compact_success = 0;
+    // static uint32_t hash_htlb_buddy_alloc_fail = 0;
+    // static uint32_t hash_htlb_buddy_alloc_success = 0;
+    // static uint32_t hash_kswapd_high_wmark_hit_quickly = 0;
+    // static uint32_t hash_kswapd_inodesteal = 0;
+    // static uint32_t hash_kswapd_low_wmark_hit_quickly = 0;
+    // static uint32_t hash_kswapd_skip_congestion_wait = 0;
+    // static uint32_t hash_nr_active_anon = 0;
+    // static uint32_t hash_nr_active_file = 0;
+    // static uint32_t hash_nr_anon_pages = 0;
+    // static uint32_t hash_nr_anon_transparent_hugepages = 0;
+    // static uint32_t hash_nr_bounce = 0;
+    // static uint32_t hash_nr_dirtied = 0;
+    // static uint32_t hash_nr_dirty = 0;
+    // static uint32_t hash_nr_dirty_background_threshold = 0;
+    // static uint32_t hash_nr_dirty_threshold = 0;
+    // static uint32_t hash_nr_file_pages = 0;
+    // static uint32_t hash_nr_free_pages = 0;
+    // static uint32_t hash_nr_inactive_anon = 0;
+    // static uint32_t hash_nr_inactive_file = 0;
+    // static uint32_t hash_nr_isolated_anon = 0;
+    // static uint32_t hash_nr_isolated_file = 0;
+    // static uint32_t hash_nr_kernel_stack = 0;
+    // static uint32_t hash_nr_mapped = 0;
+    // static uint32_t hash_nr_mlock = 0;
+    // static uint32_t hash_nr_page_table_pages = 0;
+    // static uint32_t hash_nr_shmem = 0;
+    // static uint32_t hash_nr_slab_reclaimable = 0;
+    // static uint32_t hash_nr_slab_unreclaimable = 0;
+    // static uint32_t hash_nr_unevictable = 0;
+    // static uint32_t hash_nr_unstable = 0;
+    // static uint32_t hash_nr_vmscan_immediate_reclaim = 0;
+    // static uint32_t hash_nr_vmscan_write = 0;
+    // static uint32_t hash_nr_writeback = 0;
+    // static uint32_t hash_nr_writeback_temp = 0;
+    // static uint32_t hash_nr_written = 0;
+    // static uint32_t hash_pageoutrun = 0;
+    // static uint32_t hash_pgactivate = 0;
+    // static uint32_t hash_pgalloc_dma = 0;
+    // static uint32_t hash_pgalloc_dma32 = 0;
+    // static uint32_t hash_pgalloc_movable = 0;
+    // static uint32_t hash_pgalloc_normal = 0;
+    // static uint32_t hash_pgdeactivate = 0;
+    static uint32_t hash_pgfault = 0;
+    // static uint32_t hash_pgfree = 0;
+    // static uint32_t hash_pginodesteal = 0;
+    static uint32_t hash_pgmajfault = 0;
+    static uint32_t hash_pgpgin = 0;
+    static uint32_t hash_pgpgout = 0;
+    // static uint32_t hash_pgrefill_dma = 0;
+    // static uint32_t hash_pgrefill_dma32 = 0;
+    // static uint32_t hash_pgrefill_movable = 0;
+    // static uint32_t hash_pgrefill_normal = 0;
+    // static uint32_t hash_pgrotated = 0;
+    // static uint32_t hash_pgscan_direct_dma = 0;
+    // static uint32_t hash_pgscan_direct_dma32 = 0;
+    // static uint32_t hash_pgscan_direct_movable = 0;
+    // static uint32_t hash_pgscan_direct_normal = 0;
+    // static uint32_t hash_pgscan_kswapd_dma = 0;
+    // static uint32_t hash_pgscan_kswapd_dma32 = 0;
+    // static uint32_t hash_pgscan_kswapd_movable = 0;
+    // static uint32_t hash_pgscan_kswapd_normal = 0;
+    // static uint32_t hash_pgsteal_direct_dma = 0;
+    // static uint32_t hash_pgsteal_direct_dma32 = 0;
+    // static uint32_t hash_pgsteal_direct_movable = 0;
+    // static uint32_t hash_pgsteal_direct_normal = 0;
+    // static uint32_t hash_pgsteal_kswapd_dma = 0;
+    // static uint32_t hash_pgsteal_kswapd_dma32 = 0;
+    // static uint32_t hash_pgsteal_kswapd_movable = 0;
+    // static uint32_t hash_pgsteal_kswapd_normal = 0;
+    static uint32_t hash_pswpin = 0;
+    static uint32_t hash_pswpout = 0;
+    // static uint32_t hash_slabs_scanned = 0;
+    // static uint32_t hash_thp_collapse_alloc = 0;
+    // static uint32_t hash_thp_collapse_alloc_failed = 0;
+    // static uint32_t hash_thp_fault_alloc = 0;
+    // static uint32_t hash_thp_fault_fallback = 0;
+    // static uint32_t hash_thp_split = 0;
+    // static uint32_t hash_unevictable_pgs_cleared = 0;
+    // static uint32_t hash_unevictable_pgs_culled = 0;
+    // static uint32_t hash_unevictable_pgs_mlocked = 0;
+    // static uint32_t hash_unevictable_pgs_mlockfreed = 0;
+    // static uint32_t hash_unevictable_pgs_munlocked = 0;
+    // static uint32_t hash_unevictable_pgs_rescued = 0;
+    // static uint32_t hash_unevictable_pgs_scanned = 0;
+    // static uint32_t hash_unevictable_pgs_stranded = 0;
 
-    // static uint32_t hash_allocstall = -1;
-    // static uint32_t hash_compact_blocks_moved = -1;
-    // static uint32_t hash_compact_fail = -1;
-    // static uint32_t hash_compact_pagemigrate_failed = -1;
-    // static uint32_t hash_compact_pages_moved = -1;
-    // static uint32_t hash_compact_stall = -1;
-    // static uint32_t hash_compact_success = -1;
-    // static uint32_t hash_htlb_buddy_alloc_fail = -1;
-    // static uint32_t hash_htlb_buddy_alloc_success = -1;
-    // static uint32_t hash_kswapd_high_wmark_hit_quickly = -1;
-    // static uint32_t hash_kswapd_inodesteal = -1;
-    // static uint32_t hash_kswapd_low_wmark_hit_quickly = -1;
-    // static uint32_t hash_kswapd_skip_congestion_wait = -1;
-    // static uint32_t hash_nr_active_anon = -1;
-    // static uint32_t hash_nr_active_file = -1;
-    // static uint32_t hash_nr_anon_pages = -1;
-    // static uint32_t hash_nr_anon_transparent_hugepages = -1;
-    // static uint32_t hash_nr_bounce = -1;
-    // static uint32_t hash_nr_dirtied = -1;
-    // static uint32_t hash_nr_dirty = -1;
-    // static uint32_t hash_nr_dirty_background_threshold = -1;
-    // static uint32_t hash_nr_dirty_threshold = -1;
-    // static uint32_t hash_nr_file_pages = -1;
-    // static uint32_t hash_nr_free_pages = -1;
-    // static uint32_t hash_nr_inactive_anon = -1;
-    // static uint32_t hash_nr_inactive_file = -1;
-    // static uint32_t hash_nr_isolated_anon = -1;
-    // static uint32_t hash_nr_isolated_file = -1;
-    // static uint32_t hash_nr_kernel_stack = -1;
-    // static uint32_t hash_nr_mapped = -1;
-    // static uint32_t hash_nr_mlock = -1;
-    // static uint32_t hash_nr_page_table_pages = -1;
-    // static uint32_t hash_nr_shmem = -1;
-    // static uint32_t hash_nr_slab_reclaimable = -1;
-    // static uint32_t hash_nr_slab_unreclaimable = -1;
-    // static uint32_t hash_nr_unevictable = -1;
-    // static uint32_t hash_nr_unstable = -1;
-    // static uint32_t hash_nr_vmscan_immediate_reclaim = -1;
-    // static uint32_t hash_nr_vmscan_write = -1;
-    // static uint32_t hash_nr_writeback = -1;
-    // static uint32_t hash_nr_writeback_temp = -1;
-    // static uint32_t hash_nr_written = -1;
-    // static uint32_t hash_pageoutrun = -1;
-    // static uint32_t hash_pgactivate = -1;
-    // static uint32_t hash_pgalloc_dma = -1;
-    // static uint32_t hash_pgalloc_dma32 = -1;
-    // static uint32_t hash_pgalloc_movable = -1;
-    // static uint32_t hash_pgalloc_normal = -1;
-    // static uint32_t hash_pgdeactivate = -1;
-    static uint32_t hash_pgfault = -1;
-    // static uint32_t hash_pgfree = -1;
-    // static uint32_t hash_pginodesteal = -1;
-    static uint32_t hash_pgmajfault = -1;
-    static uint32_t hash_pgpgin = -1;
-    static uint32_t hash_pgpgout = -1;
-    // static uint32_t hash_pgrefill_dma = -1;
-    // static uint32_t hash_pgrefill_dma32 = -1;
-    // static uint32_t hash_pgrefill_movable = -1;
-    // static uint32_t hash_pgrefill_normal = -1;
-    // static uint32_t hash_pgrotated = -1;
-    // static uint32_t hash_pgscan_direct_dma = -1;
-    // static uint32_t hash_pgscan_direct_dma32 = -1;
-    // static uint32_t hash_pgscan_direct_movable = -1;
-    // static uint32_t hash_pgscan_direct_normal = -1;
-    // static uint32_t hash_pgscan_kswapd_dma = -1;
-    // static uint32_t hash_pgscan_kswapd_dma32 = -1;
-    // static uint32_t hash_pgscan_kswapd_movable = -1;
-    // static uint32_t hash_pgscan_kswapd_normal = -1;
-    // static uint32_t hash_pgsteal_direct_dma = -1;
-    // static uint32_t hash_pgsteal_direct_dma32 = -1;
-    // static uint32_t hash_pgsteal_direct_movable = -1;
-    // static uint32_t hash_pgsteal_direct_normal = -1;
-    // static uint32_t hash_pgsteal_kswapd_dma = -1;
-    // static uint32_t hash_pgsteal_kswapd_dma32 = -1;
-    // static uint32_t hash_pgsteal_kswapd_movable = -1;
-    // static uint32_t hash_pgsteal_kswapd_normal = -1;
-    static uint32_t hash_pswpin = -1;
-    static uint32_t hash_pswpout = -1;
-    // static uint32_t hash_slabs_scanned = -1;
-    // static uint32_t hash_thp_collapse_alloc = -1;
-    // static uint32_t hash_thp_collapse_alloc_failed = -1;
-    // static uint32_t hash_thp_fault_alloc = -1;
-    // static uint32_t hash_thp_fault_fallback = -1;
-    // static uint32_t hash_thp_split = -1;
-    // static uint32_t hash_unevictable_pgs_cleared = -1;
-    // static uint32_t hash_unevictable_pgs_culled = -1;
-    // static uint32_t hash_unevictable_pgs_mlocked = -1;
-    // static uint32_t hash_unevictable_pgs_mlockfreed = -1;
-    // static uint32_t hash_unevictable_pgs_munlocked = -1;
-    // static uint32_t hash_unevictable_pgs_rescued = -1;
-    // static uint32_t hash_unevictable_pgs_scanned = -1;
-    // static uint32_t hash_unevictable_pgs_stranded = -1;
+    if(unlikely(do_swapio == -1)) {
+        do_swapio = config_get_boolean_ondemand("plugin:proc:/proc/vmstat", "swap i/o", CONFIG_ONDEMAND_ONDEMAND);
+        do_io = config_get_boolean("plugin:proc:/proc/vmstat", "disk i/o", 1);
+        do_pgfaults = config_get_boolean("plugin:proc:/proc/vmstat", "memory page faults", 1);
 
-    if(gen_hashes != 1) {
-        gen_hashes = 1;
         // hash_allocstall = simple_hash("allocstall");
         // hash_compact_blocks_moved = simple_hash("compact_blocks_moved");
         // hash_compact_fail = simple_hash("compact_fail");
@@ -193,21 +198,15 @@ int do_proc_vmstat(int update_every, unsigned long long dt) {
         // hash_unevictable_pgs_stranded = simple_hash("unevictable_pgs_stranded");
     }
 
-    if(do_swapio == -1)    do_swapio = config_get_boolean_ondemand("plugin:proc:/proc/vmstat", "swap i/o", CONFIG_ONDEMAND_ONDEMAND);
-    if(do_io == -1)        do_io = config_get_boolean("plugin:proc:/proc/vmstat", "disk i/o", 1);
-    if(do_pgfaults == -1)  do_pgfaults = config_get_boolean("plugin:proc:/proc/vmstat", "memory page faults", 1);
-
-    (void)dt;
-
-    if(!ff) {
+    if(unlikely(!ff)) {
         char filename[FILENAME_MAX + 1];
         snprintfz(filename, FILENAME_MAX, "%s%s", global_host_prefix, "/proc/vmstat");
         ff = procfile_open(config_get("plugin:proc:/proc/vmstat", "filename to monitor", filename), " \t:", PROCFILE_FLAG_DEFAULT);
+        if(unlikely(!ff)) return 1;
     }
-    if(!ff) return 1;
 
     ff = procfile_readall(ff);
-    if(!ff) return 0; // we return 0, so that we will retry to open it next time
+    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;
@@ -307,110 +306,110 @@ int do_proc_vmstat(int update_every, unsigned long long dt) {
 
     for(l = 0; l < lines ;l++) {
         words = procfile_linewords(ff, l);
-        if(words < 2) {
-            if(words) error("Cannot read /proc/vmstat line %u. Expected 2 params, read %u.", l, words);
+        if(unlikely(words < 2)) {
+            if(unlikely(words)) error("Cannot read /proc/vmstat line %u. Expected 2 params, read %u.", l, words);
             continue;
         }
 
         char *name = procfile_lineword(ff, l, 0);
         char * value = procfile_lineword(ff, l, 1);
-        if(!name || !*name || !value || !*value) continue;
+        if(unlikely(!name || !*name || !value || !*value)) continue;
 
         uint32_t hash = simple_hash(name);
 
-        if(0) ;
-        // else if(hash == hash_allocstall && strcmp(name, "allocstall") == 0) allocstall = strtoull(value, NULL, 10);
-        // else if(hash == hash_compact_blocks_moved && strcmp(name, "compact_blocks_moved") == 0) compact_blocks_moved = strtoull(value, NULL, 10);
-        // else if(hash == hash_compact_fail && strcmp(name, "compact_fail") == 0) compact_fail = strtoull(value, NULL, 10);
-        // else if(hash == hash_compact_pagemigrate_failed && strcmp(name, "compact_pagemigrate_failed") == 0) compact_pagemigrate_failed = strtoull(value, NULL, 10);
-        // else if(hash == hash_compact_pages_moved && strcmp(name, "compact_pages_moved") == 0) compact_pages_moved = strtoull(value, NULL, 10);
-        // else if(hash == hash_compact_stall && strcmp(name, "compact_stall") == 0) compact_stall = strtoull(value, NULL, 10);
-        // else if(hash == hash_compact_success && strcmp(name, "compact_success") == 0) compact_success = strtoull(value, NULL, 10);
-        // else if(hash == hash_htlb_buddy_alloc_fail && strcmp(name, "htlb_buddy_alloc_fail") == 0) htlb_buddy_alloc_fail = strtoull(value, NULL, 10);
-        // else if(hash == hash_htlb_buddy_alloc_success && strcmp(name, "htlb_buddy_alloc_success") == 0) htlb_buddy_alloc_success = strtoull(value, NULL, 10);
-        // else if(hash == hash_kswapd_high_wmark_hit_quickly && strcmp(name, "kswapd_high_wmark_hit_quickly") == 0) kswapd_high_wmark_hit_quickly = strtoull(value, NULL, 10);
-        // else if(hash == hash_kswapd_inodesteal && strcmp(name, "kswapd_inodesteal") == 0) kswapd_inodesteal = strtoull(value, NULL, 10);
-        // else if(hash == hash_kswapd_low_wmark_hit_quickly && strcmp(name, "kswapd_low_wmark_hit_quickly") == 0) kswapd_low_wmark_hit_quickly = strtoull(value, NULL, 10);
-        // else if(hash == hash_kswapd_skip_congestion_wait && strcmp(name, "kswapd_skip_congestion_wait") == 0) kswapd_skip_congestion_wait = strtoull(value, NULL, 10);
-        // else if(hash == hash_nr_active_anon && strcmp(name, "nr_active_anon") == 0) nr_active_anon = strtoull(value, NULL, 10);
-        // else if(hash == hash_nr_active_file && strcmp(name, "nr_active_file") == 0) nr_active_file = strtoull(value, NULL, 10);
-        // else if(hash == hash_nr_anon_pages && strcmp(name, "nr_anon_pages") == 0) nr_anon_pages = strtoull(value, NULL, 10);
-        // else if(hash == hash_nr_anon_transparent_hugepages && strcmp(name, "nr_anon_transparent_hugepages") == 0) nr_anon_transparent_hugepages = strtoull(value, NULL, 10);
-        // else if(hash == hash_nr_bounce && strcmp(name, "nr_bounce") == 0) nr_bounce = strtoull(value, NULL, 10);
-        // else if(hash == hash_nr_dirtied && strcmp(name, "nr_dirtied") == 0) nr_dirtied = strtoull(value, NULL, 10);
-        // else if(hash == hash_nr_dirty && strcmp(name, "nr_dirty") == 0) nr_dirty = strtoull(value, NULL, 10);
-        // else if(hash == hash_nr_dirty_background_threshold && strcmp(name, "nr_dirty_background_threshold") == 0) nr_dirty_background_threshold = strtoull(value, NULL, 10);
-        // else if(hash == hash_nr_dirty_threshold && strcmp(name, "nr_dirty_threshold") == 0) nr_dirty_threshold = strtoull(value, NULL, 10);
-        // else if(hash == hash_nr_file_pages && strcmp(name, "nr_file_pages") == 0) nr_file_pages = strtoull(value, NULL, 10);
-        // else if(hash == hash_nr_free_pages && strcmp(name, "nr_free_pages") == 0) nr_free_pages = strtoull(value, NULL, 10);
-        // else if(hash == hash_nr_inactive_anon && strcmp(name, "nr_inactive_anon") == 0) nr_inactive_anon = strtoull(value, NULL, 10);
-        // else if(hash == hash_nr_inactive_file && strcmp(name, "nr_inactive_file") == 0) nr_inactive_file = strtoull(value, NULL, 10);
-        // else if(hash == hash_nr_isolated_anon && strcmp(name, "nr_isolated_anon") == 0) nr_isolated_anon = strtoull(value, NULL, 10);
-        // else if(hash == hash_nr_isolated_file && strcmp(name, "nr_isolated_file") == 0) nr_isolated_file = strtoull(value, NULL, 10);
-        // else if(hash == hash_nr_kernel_stack && strcmp(name, "nr_kernel_stack") == 0) nr_kernel_stack = strtoull(value, NULL, 10);
-        // else if(hash == hash_nr_mapped && strcmp(name, "nr_mapped") == 0) nr_mapped = strtoull(value, NULL, 10);
-        // else if(hash == hash_nr_mlock && strcmp(name, "nr_mlock") == 0) nr_mlock = strtoull(value, NULL, 10);
-        // else if(hash == hash_nr_page_table_pages && strcmp(name, "nr_page_table_pages") == 0) nr_page_table_pages = strtoull(value, NULL, 10);
-        // else if(hash == hash_nr_shmem && strcmp(name, "nr_shmem") == 0) nr_shmem = strtoull(value, NULL, 10);
-        // else if(hash == hash_nr_slab_reclaimable && strcmp(name, "nr_slab_reclaimable") == 0) nr_slab_reclaimable = strtoull(value, NULL, 10);
-        // else if(hash == hash_nr_slab_unreclaimable && strcmp(name, "nr_slab_unreclaimable") == 0) nr_slab_unreclaimable = strtoull(value, NULL, 10);
-        // else if(hash == hash_nr_unevictable && strcmp(name, "nr_unevictable") == 0) nr_unevictable = strtoull(value, NULL, 10);
-        // else if(hash == hash_nr_unstable && strcmp(name, "nr_unstable") == 0) nr_unstable = strtoull(value, NULL, 10);
-        // else if(hash == hash_nr_vmscan_immediate_reclaim && strcmp(name, "nr_vmscan_immediate_reclaim") == 0) nr_vmscan_immediate_reclaim = strtoull(value, NULL, 10);
-        // else if(hash == hash_nr_vmscan_write && strcmp(name, "nr_vmscan_write") == 0) nr_vmscan_write = strtoull(value, NULL, 10);
-        // else if(hash == hash_nr_writeback && strcmp(name, "nr_writeback") == 0) nr_writeback = strtoull(value, NULL, 10);
-        // else if(hash == hash_nr_writeback_temp && strcmp(name, "nr_writeback_temp") == 0) nr_writeback_temp = strtoull(value, NULL, 10);
-        // else if(hash == hash_nr_written && strcmp(name, "nr_written") == 0) nr_written = strtoull(value, NULL, 10);
-        // else if(hash == hash_pageoutrun && strcmp(name, "pageoutrun") == 0) pageoutrun = strtoull(value, NULL, 10);
-        // else if(hash == hash_pgactivate && strcmp(name, "pgactivate") == 0) pgactivate = strtoull(value, NULL, 10);
-        // else if(hash == hash_pgalloc_dma && strcmp(name, "pgalloc_dma") == 0) pgalloc_dma = strtoull(value, NULL, 10);
-        // else if(hash == hash_pgalloc_dma32 && strcmp(name, "pgalloc_dma32") == 0) pgalloc_dma32 = strtoull(value, NULL, 10);
-        // else if(hash == hash_pgalloc_movable && strcmp(name, "pgalloc_movable") == 0) pgalloc_movable = strtoull(value, NULL, 10);
-        // else if(hash == hash_pgalloc_normal && strcmp(name, "pgalloc_normal") == 0) pgalloc_normal = strtoull(value, NULL, 10);
-        // else if(hash == hash_pgdeactivate && strcmp(name, "pgdeactivate") == 0) pgdeactivate = strtoull(value, NULL, 10);
-        else if(hash == hash_pgfault && strcmp(name, "pgfault") == 0) pgfault = strtoull(value, NULL, 10);
-        // else if(hash == hash_pgfree && strcmp(name, "pgfree") == 0) pgfree = strtoull(value, NULL, 10);
-        // else if(hash == hash_pginodesteal && strcmp(name, "pginodesteal") == 0) pginodesteal = strtoull(value, NULL, 10);
-        else if(hash == hash_pgmajfault && strcmp(name, "pgmajfault") == 0) pgmajfault = strtoull(value, NULL, 10);
-        else if(hash == hash_pgpgin && strcmp(name, "pgpgin") == 0) pgpgin = strtoull(value, NULL, 10);
-        else if(hash == hash_pgpgout && strcmp(name, "pgpgout") == 0) pgpgout = strtoull(value, NULL, 10);
-        // else if(hash == hash_pgrefill_dma && strcmp(name, "pgrefill_dma") == 0) pgrefill_dma = strtoull(value, NULL, 10);
-        // else if(hash == hash_pgrefill_dma32 && strcmp(name, "pgrefill_dma32") == 0) pgrefill_dma32 = strtoull(value, NULL, 10);
-        // else if(hash == hash_pgrefill_movable && strcmp(name, "pgrefill_movable") == 0) pgrefill_movable = strtoull(value, NULL, 10);
-        // else if(hash == hash_pgrefill_normal && strcmp(name, "pgrefill_normal") == 0) pgrefill_normal = strtoull(value, NULL, 10);
-        // else if(hash == hash_pgrotated && strcmp(name, "pgrotated") == 0) pgrotated = strtoull(value, NULL, 10);
-        // else if(hash == hash_pgscan_direct_dma && strcmp(name, "pgscan_direct_dma") == 0) pgscan_direct_dma = strtoull(value, NULL, 10);
-        // else if(hash == hash_pgscan_direct_dma32 && strcmp(name, "pgscan_direct_dma32") == 0) pgscan_direct_dma32 = strtoull(value, NULL, 10);
-        // else if(hash == hash_pgscan_direct_movable && strcmp(name, "pgscan_direct_movable") == 0) pgscan_direct_movable = strtoull(value, NULL, 10);
-        // else if(hash == hash_pgscan_direct_normal && strcmp(name, "pgscan_direct_normal") == 0) pgscan_direct_normal = strtoull(value, NULL, 10);
-        // else if(hash == hash_pgscan_kswapd_dma && strcmp(name, "pgscan_kswapd_dma") == 0) pgscan_kswapd_dma = strtoull(value, NULL, 10);
-        // else if(hash == hash_pgscan_kswapd_dma32 && strcmp(name, "pgscan_kswapd_dma32") == 0) pgscan_kswapd_dma32 = strtoull(value, NULL, 10);
-        // else if(hash == hash_pgscan_kswapd_movable && strcmp(name, "pgscan_kswapd_movable") == 0) pgscan_kswapd_movable = strtoull(value, NULL, 10);
-        // else if(hash == hash_pgscan_kswapd_normal && strcmp(name, "pgscan_kswapd_normal") == 0) pgscan_kswapd_normal = strtoull(value, NULL, 10);
-        // else if(hash == hash_pgsteal_direct_dma && strcmp(name, "pgsteal_direct_dma") == 0) pgsteal_direct_dma = strtoull(value, NULL, 10);
-        // else if(hash == hash_pgsteal_direct_dma32 && strcmp(name, "pgsteal_direct_dma32") == 0) pgsteal_direct_dma32 = strtoull(value, NULL, 10);
-        // else if(hash == hash_pgsteal_direct_movable && strcmp(name, "pgsteal_direct_movable") == 0) pgsteal_direct_movable = strtoull(value, NULL, 10);
-        // else if(hash == hash_pgsteal_direct_normal && strcmp(name, "pgsteal_direct_normal") == 0) pgsteal_direct_normal = strtoull(value, NULL, 10);
-        // else if(hash == hash_pgsteal_kswapd_dma && strcmp(name, "pgsteal_kswapd_dma") == 0) pgsteal_kswapd_dma = strtoull(value, NULL, 10);
-        // else if(hash == hash_pgsteal_kswapd_dma32 && strcmp(name, "pgsteal_kswapd_dma32") == 0) pgsteal_kswapd_dma32 = strtoull(value, NULL, 10);
-        // else if(hash == hash_pgsteal_kswapd_movable && strcmp(name, "pgsteal_kswapd_movable") == 0) pgsteal_kswapd_movable = strtoull(value, NULL, 10);
-        // else if(hash == hash_pgsteal_kswapd_normal && strcmp(name, "pgsteal_kswapd_normal") == 0) pgsteal_kswapd_normal = strtoull(value, NULL, 10);
-        else if(hash == hash_pswpin && strcmp(name, "pswpin") == 0) pswpin = strtoull(value, NULL, 10);
-        else if(hash == hash_pswpout && strcmp(name, "pswpout") == 0) pswpout = strtoull(value, NULL, 10);
-        // else if(hash == hash_slabs_scanned && strcmp(name, "slabs_scanned") == 0) slabs_scanned = strtoull(value, NULL, 10);
-        // else if(hash == hash_thp_collapse_alloc && strcmp(name, "thp_collapse_alloc") == 0) thp_collapse_alloc = strtoull(value, NULL, 10);
-        // else if(hash == hash_thp_collapse_alloc_failed && strcmp(name, "thp_collapse_alloc_failed") == 0) thp_collapse_alloc_failed = strtoull(value, NULL, 10);
-        // else if(hash == hash_thp_fault_alloc && strcmp(name, "thp_fault_alloc") == 0) thp_fault_alloc = strtoull(value, NULL, 10);
-        // else if(hash == hash_thp_fault_fallback && strcmp(name, "thp_fault_fallback") == 0) thp_fault_fallback = strtoull(value, NULL, 10);
-        // else if(hash == hash_thp_split && strcmp(name, "thp_split") == 0) thp_split = strtoull(value, NULL, 10);
-        // else if(hash == hash_unevictable_pgs_cleared && strcmp(name, "unevictable_pgs_cleared") == 0) unevictable_pgs_cleared = strtoull(value, NULL, 10);
-        // else if(hash == hash_unevictable_pgs_culled && strcmp(name, "unevictable_pgs_culled") == 0) unevictable_pgs_culled = strtoull(value, NULL, 10);
-        // else if(hash == hash_unevictable_pgs_mlocked && strcmp(name, "unevictable_pgs_mlocked") == 0) unevictable_pgs_mlocked = strtoull(value, NULL, 10);
-        // else if(hash == hash_unevictable_pgs_mlockfreed && strcmp(name, "unevictable_pgs_mlockfreed") == 0) unevictable_pgs_mlockfreed = strtoull(value, NULL, 10);
-        // else if(hash == hash_unevictable_pgs_munlocked && strcmp(name, "unevictable_pgs_munlocked") == 0) unevictable_pgs_munlocked = strtoull(value, NULL, 10);
-        // else if(hash == hash_unevictable_pgs_rescued && strcmp(name, "unevictable_pgs_rescued") == 0) unevictable_pgs_rescued = strtoull(value, NULL, 10);
-        // else if(hash == hash_unevictable_pgs_scanned && strcmp(name, "unevictable_pgs_scanned") == 0) unevictable_pgs_scanned = strtoull(value, NULL, 10);
-        // else if(hash == hash_unevictable_pgs_stranded && strcmp(name, "unevictable_pgs_stranded") == 0) unevictable_pgs_stranded = strtoull(value, NULL, 10);
+        if(unlikely(0)) ;
+        // else if(unlikely(hash == hash_allocstall && strcmp(name, "allocstall") == 0)) allocstall = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_compact_blocks_moved && strcmp(name, "compact_blocks_moved") == 0)) compact_blocks_moved = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_compact_fail && strcmp(name, "compact_fail") == 0)) compact_fail = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_compact_pagemigrate_failed && strcmp(name, "compact_pagemigrate_failed") == 0)) compact_pagemigrate_failed = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_compact_pages_moved && strcmp(name, "compact_pages_moved") == 0)) compact_pages_moved = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_compact_stall && strcmp(name, "compact_stall") == 0)) compact_stall = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_compact_success && strcmp(name, "compact_success") == 0)) compact_success = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_htlb_buddy_alloc_fail && strcmp(name, "htlb_buddy_alloc_fail") == 0)) htlb_buddy_alloc_fail = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_htlb_buddy_alloc_success && strcmp(name, "htlb_buddy_alloc_success") == 0)) htlb_buddy_alloc_success = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_kswapd_high_wmark_hit_quickly && strcmp(name, "kswapd_high_wmark_hit_quickly") == 0)) kswapd_high_wmark_hit_quickly = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_kswapd_inodesteal && strcmp(name, "kswapd_inodesteal") == 0)) kswapd_inodesteal = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_kswapd_low_wmark_hit_quickly && strcmp(name, "kswapd_low_wmark_hit_quickly") == 0)) kswapd_low_wmark_hit_quickly = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_kswapd_skip_congestion_wait && strcmp(name, "kswapd_skip_congestion_wait") == 0)) kswapd_skip_congestion_wait = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_nr_active_anon && strcmp(name, "nr_active_anon") == 0)) nr_active_anon = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_nr_active_file && strcmp(name, "nr_active_file") == 0)) nr_active_file = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_nr_anon_pages && strcmp(name, "nr_anon_pages") == 0)) nr_anon_pages = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_nr_anon_transparent_hugepages && strcmp(name, "nr_anon_transparent_hugepages") == 0)) nr_anon_transparent_hugepages = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_nr_bounce && strcmp(name, "nr_bounce") == 0)) nr_bounce = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_nr_dirtied && strcmp(name, "nr_dirtied") == 0)) nr_dirtied = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_nr_dirty && strcmp(name, "nr_dirty") == 0)) nr_dirty = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_nr_dirty_background_threshold && strcmp(name, "nr_dirty_background_threshold") == 0)) nr_dirty_background_threshold = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_nr_dirty_threshold && strcmp(name, "nr_dirty_threshold") == 0)) nr_dirty_threshold = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_nr_file_pages && strcmp(name, "nr_file_pages") == 0)) nr_file_pages = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_nr_free_pages && strcmp(name, "nr_free_pages") == 0)) nr_free_pages = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_nr_inactive_anon && strcmp(name, "nr_inactive_anon") == 0)) nr_inactive_anon = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_nr_inactive_file && strcmp(name, "nr_inactive_file") == 0)) nr_inactive_file = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_nr_isolated_anon && strcmp(name, "nr_isolated_anon") == 0)) nr_isolated_anon = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_nr_isolated_file && strcmp(name, "nr_isolated_file") == 0)) nr_isolated_file = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_nr_kernel_stack && strcmp(name, "nr_kernel_stack") == 0)) nr_kernel_stack = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_nr_mapped && strcmp(name, "nr_mapped") == 0)) nr_mapped = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_nr_mlock && strcmp(name, "nr_mlock") == 0)) nr_mlock = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_nr_page_table_pages && strcmp(name, "nr_page_table_pages") == 0)) nr_page_table_pages = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_nr_shmem && strcmp(name, "nr_shmem") == 0)) nr_shmem = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_nr_slab_reclaimable && strcmp(name, "nr_slab_reclaimable") == 0)) nr_slab_reclaimable = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_nr_slab_unreclaimable && strcmp(name, "nr_slab_unreclaimable") == 0)) nr_slab_unreclaimable = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_nr_unevictable && strcmp(name, "nr_unevictable") == 0)) nr_unevictable = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_nr_unstable && strcmp(name, "nr_unstable") == 0)) nr_unstable = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_nr_vmscan_immediate_reclaim && strcmp(name, "nr_vmscan_immediate_reclaim") == 0)) nr_vmscan_immediate_reclaim = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_nr_vmscan_write && strcmp(name, "nr_vmscan_write") == 0)) nr_vmscan_write = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_nr_writeback && strcmp(name, "nr_writeback") == 0)) nr_writeback = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_nr_writeback_temp && strcmp(name, "nr_writeback_temp") == 0)) nr_writeback_temp = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_nr_written && strcmp(name, "nr_written") == 0)) nr_written = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_pageoutrun && strcmp(name, "pageoutrun") == 0)) pageoutrun = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_pgactivate && strcmp(name, "pgactivate") == 0)) pgactivate = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_pgalloc_dma && strcmp(name, "pgalloc_dma") == 0)) pgalloc_dma = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_pgalloc_dma32 && strcmp(name, "pgalloc_dma32") == 0)) pgalloc_dma32 = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_pgalloc_movable && strcmp(name, "pgalloc_movable") == 0)) pgalloc_movable = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_pgalloc_normal && strcmp(name, "pgalloc_normal") == 0)) pgalloc_normal = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_pgdeactivate && strcmp(name, "pgdeactivate") == 0)) pgdeactivate = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_pgfault && strcmp(name, "pgfault") == 0)) pgfault = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_pgfree && strcmp(name, "pgfree") == 0)) pgfree = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_pginodesteal && strcmp(name, "pginodesteal") == 0)) pginodesteal = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_pgmajfault && strcmp(name, "pgmajfault") == 0)) pgmajfault = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_pgpgin && strcmp(name, "pgpgin") == 0)) pgpgin = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_pgpgout && strcmp(name, "pgpgout") == 0)) pgpgout = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_pgrefill_dma && strcmp(name, "pgrefill_dma") == 0)) pgrefill_dma = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_pgrefill_dma32 && strcmp(name, "pgrefill_dma32") == 0)) pgrefill_dma32 = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_pgrefill_movable && strcmp(name, "pgrefill_movable") == 0)) pgrefill_movable = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_pgrefill_normal && strcmp(name, "pgrefill_normal") == 0)) pgrefill_normal = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_pgrotated && strcmp(name, "pgrotated") == 0)) pgrotated = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_pgscan_direct_dma && strcmp(name, "pgscan_direct_dma") == 0)) pgscan_direct_dma = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_pgscan_direct_dma32 && strcmp(name, "pgscan_direct_dma32") == 0)) pgscan_direct_dma32 = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_pgscan_direct_movable && strcmp(name, "pgscan_direct_movable") == 0)) pgscan_direct_movable = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_pgscan_direct_normal && strcmp(name, "pgscan_direct_normal") == 0)) pgscan_direct_normal = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_pgscan_kswapd_dma && strcmp(name, "pgscan_kswapd_dma") == 0)) pgscan_kswapd_dma = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_pgscan_kswapd_dma32 && strcmp(name, "pgscan_kswapd_dma32") == 0)) pgscan_kswapd_dma32 = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_pgscan_kswapd_movable && strcmp(name, "pgscan_kswapd_movable") == 0)) pgscan_kswapd_movable = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_pgscan_kswapd_normal && strcmp(name, "pgscan_kswapd_normal") == 0)) pgscan_kswapd_normal = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_pgsteal_direct_dma && strcmp(name, "pgsteal_direct_dma") == 0)) pgsteal_direct_dma = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_pgsteal_direct_dma32 && strcmp(name, "pgsteal_direct_dma32") == 0)) pgsteal_direct_dma32 = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_pgsteal_direct_movable && strcmp(name, "pgsteal_direct_movable") == 0)) pgsteal_direct_movable = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_pgsteal_direct_normal && strcmp(name, "pgsteal_direct_normal") == 0)) pgsteal_direct_normal = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_pgsteal_kswapd_dma && strcmp(name, "pgsteal_kswapd_dma") == 0)) pgsteal_kswapd_dma = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_pgsteal_kswapd_dma32 && strcmp(name, "pgsteal_kswapd_dma32") == 0)) pgsteal_kswapd_dma32 = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_pgsteal_kswapd_movable && strcmp(name, "pgsteal_kswapd_movable") == 0)) pgsteal_kswapd_movable = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_pgsteal_kswapd_normal && strcmp(name, "pgsteal_kswapd_normal") == 0)) pgsteal_kswapd_normal = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_pswpin && strcmp(name, "pswpin") == 0)) pswpin = strtoull(value, NULL, 10);
+        else if(unlikely(hash == hash_pswpout && strcmp(name, "pswpout") == 0)) pswpout = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_slabs_scanned && strcmp(name, "slabs_scanned") == 0)) slabs_scanned = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_thp_collapse_alloc && strcmp(name, "thp_collapse_alloc") == 0)) thp_collapse_alloc = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_thp_collapse_alloc_failed && strcmp(name, "thp_collapse_alloc_failed") == 0)) thp_collapse_alloc_failed = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_thp_fault_alloc && strcmp(name, "thp_fault_alloc") == 0)) thp_fault_alloc = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_thp_fault_fallback && strcmp(name, "thp_fault_fallback") == 0)) thp_fault_fallback = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_thp_split && strcmp(name, "thp_split") == 0)) thp_split = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_unevictable_pgs_cleared && strcmp(name, "unevictable_pgs_cleared") == 0)) unevictable_pgs_cleared = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_unevictable_pgs_culled && strcmp(name, "unevictable_pgs_culled") == 0)) unevictable_pgs_culled = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_unevictable_pgs_mlocked && strcmp(name, "unevictable_pgs_mlocked") == 0)) unevictable_pgs_mlocked = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_unevictable_pgs_mlockfreed && strcmp(name, "unevictable_pgs_mlockfreed") == 0)) unevictable_pgs_mlockfreed = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_unevictable_pgs_munlocked && strcmp(name, "unevictable_pgs_munlocked") == 0)) unevictable_pgs_munlocked = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_unevictable_pgs_rescued && strcmp(name, "unevictable_pgs_rescued") == 0)) unevictable_pgs_rescued = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_unevictable_pgs_scanned && strcmp(name, "unevictable_pgs_scanned") == 0)) unevictable_pgs_scanned = strtoull(value, NULL, 10);
+        // else if(unlikely(hash == hash_unevictable_pgs_stranded && strcmp(name, "unevictable_pgs_stranded") == 0)) unevictable_pgs_stranded = strtoull(value, NULL, 10);
     }
 
     // --------------------------------------------------------------------
@@ -419,7 +418,7 @@ int do_proc_vmstat(int update_every, unsigned long long dt) {
         do_swapio = CONFIG_ONDEMAND_YES;
 
         static RRDSET *st_swapio = NULL;
-        if(!st_swapio) {
+        if(unlikely(!st_swapio)) {
             st_swapio = rrdset_create("system", "swapio", NULL, "swap", NULL, "Swap I/O", "kilobytes/s", 250, update_every, RRDSET_TYPE_AREA);
 
             rrddim_add(st_swapio, "in",  NULL, sysconf(_SC_PAGESIZE), 1024, RRDDIM_INCREMENTAL);
@@ -436,7 +435,7 @@ int do_proc_vmstat(int update_every, unsigned long long dt) {
 
     if(do_io) {
         static RRDSET *st_io = NULL;
-        if(!st_io) {
+        if(unlikely(!st_io)) {
             st_io = rrdset_create("system", "io", NULL, "disk", NULL, "Disk I/O", "kilobytes/s", 150, update_every, RRDSET_TYPE_AREA);
 
             rrddim_add(st_io, "in",  NULL,  1, 1, RRDDIM_INCREMENTAL);
@@ -453,7 +452,7 @@ int do_proc_vmstat(int update_every, unsigned long long dt) {
 
     if(do_pgfaults) {
         static RRDSET *st_pgfaults = NULL;
-        if(!st_pgfaults) {
+        if(unlikely(!st_pgfaults)) {
             st_pgfaults = rrdset_create("mem", "pgfaults", NULL, "system", NULL, "Memory Page Faults", "page faults/s", 500, update_every, RRDSET_TYPE_LINE);
             st_pgfaults->isdetail = 1;
 
index e2aa605820e4197dc1d9cb1809bcced5f53f21ed..ee7378713fc355414e37e2cda68c1b9c14bb8ab1 100644 (file)
@@ -274,7 +274,7 @@ procfile *procfile_readall(procfile *ff) {
         s = ff->len;
         x = ff->size - s;
 
-        if(!x) {
+        if(unlikely(!x)) {
             debug(D_PROCFILE, PF_PREFIX ": Expanding data buffer for file '%s'.", ff->filename);
 
             ff = reallocz(ff, sizeof(procfile) + ff->size + PROCFILE_INCREMENT_BUFFER);
@@ -348,7 +348,7 @@ void procfile_set_quotes(procfile *ff, const char *quotes) {
     // remove all quotes
     int i;
     for(i = 0; i < 256 ; i++)
-        if(ff->separators[i] == PF_CHAR_IS_QUOTE)
+        if(unlikely(ff->separators[i] == PF_CHAR_IS_QUOTE))
             ff->separators[i] = PF_CHAR_IS_WORD;
 
     // if nothing given, return
@@ -366,7 +366,7 @@ void procfile_set_open_close(procfile *ff, const char *open, const char *close)
     // remove all open/close
     int i;
     for(i = 0; i < 256 ; i++)
-        if(ff->separators[i] == PF_CHAR_IS_OPEN || ff->separators[i] == PF_CHAR_IS_CLOSE)
+        if(unlikely(ff->separators[i] == PF_CHAR_IS_OPEN || ff->separators[i] == PF_CHAR_IS_CLOSE))
             ff->separators[i] = PF_CHAR_IS_WORD;
 
     // if nothing given, return
index d699707a4fe3120947ab8ca68840abdb6668a2d8..6a264048b9826345738da192bf8d7293a61fa224 100644 (file)
@@ -915,7 +915,7 @@ int run_test(struct test *test)
                 (float)time_now / 1000000.0,
                 ((calculated_number)test->feed[c].value - (calculated_number)last) * (calculated_number)test->multiplier / (calculated_number)test->divisor,
                 (((calculated_number)test->feed[c].value - (calculated_number)last) * (calculated_number)test->multiplier / (calculated_number)test->divisor) / (calculated_number)test->feed[c].microseconds * (calculated_number)1000000);
-            rrdset_next_usec(st, test->feed[c].microseconds);
+            rrdset_next_usec_unfiltered(st, test->feed[c].microseconds);
         }
         else {
             fprintf(stderr, "    > %s: feeding position %lu\n", test->name, c+1);
@@ -1073,7 +1073,7 @@ int unit_test(long delay, long shift)
 
         fprintf(stderr, "\n\nLOOP = %lu, DELAY = %ld, VALUE = " COLLECTED_NUMBER_FORMAT "\n", c, delay, i);
         if(c) {
-            rrdset_next_usec(st, delay);
+            rrdset_next_usec_unfiltered(st, delay);
         }
         if(do_abs) rrddim_set(st, "absolute", i);
         if(do_inc) rrddim_set(st, "incremental", i);