@cryptotaxi247 / netdata-1 / commits / ca1e94f30

several code optimizations

Costa Tsaousis (ktsaou) committed Nov 7, 2016 at 23:07 UTC ca1e94f308ef7a543f8881e150f5c1a1c1865a4a
19 files changed +893 -755
src/plugin_tc.c
+5 -5
@@ -306,7 +306,7 @@ static inline void tc_device_commit(struct tc_device *d) {
306 }
307 else {
308 debug(D_TC_LOOP, "TC: Updating chart for device '%s'", d->name?d->name:d->id);
309 - rrdset_next_plugins(d->st_bytes);
309 + rrdset_next(d->st_bytes);
310
311 if(unlikely(d->name_updated && d->name && strcmp(d->id, d->name) != 0)) {
312 rrdset_set_name(d->st_bytes, d->name);
@@ -367,7 +367,7 @@ static inline void tc_device_commit(struct tc_device *d) {
367 }
368 else {
369 debug(D_TC_LOOP, "TC: Updating _packets chart for device '%s'", d->name?d->name:d->id);
370 - rrdset_next_plugins(d->st_packets);
370 + rrdset_next(d->st_packets);
371
372 // FIXME
373 // update the family
@@ -421,7 +421,7 @@ static inline void tc_device_commit(struct tc_device *d) {
421 }
422 else {
423 debug(D_TC_LOOP, "TC: Updating _dropped chart for device '%s'", d->name?d->name:d->id);
424 - rrdset_next_plugins(d->st_dropped);
424 + rrdset_next(d->st_dropped);
425
426 // FIXME
427 // update the family
@@ -475,7 +475,7 @@ static inline void tc_device_commit(struct tc_device *d) {
475 }
476 else {
477 debug(D_TC_LOOP, "TC: Updating _tokens chart for device '%s'", d->name?d->name:d->id);
478 - rrdset_next_plugins(d->st_tokens);
478 + rrdset_next(d->st_tokens);
479
480 // FIXME
481 // update the family
@@ -529,7 +529,7 @@ static inline void tc_device_commit(struct tc_device *d) {
529 }
530 else {
531 debug(D_TC_LOOP, "TC: Updating _ctokens chart for device '%s'", d->name?d->name:d->id);
532 - rrdset_next_plugins(d->st_ctokens);
532 + rrdset_next(d->st_ctokens);
533
534 // FIXME
535 // update the family
src/plugins_d.c
+1 -1
@@ -189,7 +189,7 @@ void *pluginsd_worker_thread(void *arg)
189 unsigned long long microseconds = 0;
190 if(microseconds_txt && *microseconds_txt) microseconds = strtoull(microseconds_txt, NULL, 10);
191 if(microseconds) rrdset_next_usec(st, microseconds);
192 - else rrdset_next_plugins(st);
192 + else rrdset_next(st);
193 }
194 }
195 else if(likely(hash == END_HASH && !strcmp(s, "END"))) {
src/proc_diskstats.c
+61 -56
@@ -111,7 +111,7 @@ static inline int is_mount_point_excluded(const char *mount_point) {
111 for(m = excluded_mount_points; m ; m = m->next) {
112 if(m->len <= len) {
113 // fprintf(stderr, "SPACE: comparing '%s' with '%s'\n", mount_point, m->prefix);
114 - if(strncmp(m->prefix, mount_point, m->len) == 0) {
114 + if(unlikely(strncmp(m->prefix, mount_point, m->len) == 0)) {
115 // fprintf(stderr, "SPACE: excluded '%s'\n", mount_point);
116 return 1;
117 }
@@ -130,6 +130,8 @@ struct mount_point_metadata {
130 };
131
132 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) {
133 + (void)dt;
134 +
135 static DICTIONARY *mount_points = NULL;
136 int do_space, do_inodes;
137
@@ -142,11 +144,11 @@ static inline void do_disk_space_stats(struct disk *d, const char *mount_point,
144 // if not the mountpoint has changed.
145
146 struct stat buff_stat;
145 - if(stat(mount_point, &buff_stat) == -1) {
147 + if(unlikely(stat(mount_point, &buff_stat) == -1)) {
148 error("Failed to stat() for '%s' (disk '%s')", mount_point, disk);
149 return;
150 }
149 - else if(major(buff_stat.st_dev) != d->major || minor(buff_stat.st_dev) != d->minor) {
151 + else if(unlikely(major(buff_stat.st_dev) != d->major || minor(buff_stat.st_dev) != d->minor)) {
152 error("Disk '%s' (disk '%s') switched major:minor", mount_point, disk);
153 freez(d->mount_point);
154 d->mount_point = NULL;
@@ -159,14 +161,14 @@ static inline void do_disk_space_stats(struct disk *d, const char *mount_point,
161 }
162 else {
163 struct mount_point_metadata *m = dictionary_get(mount_points, mount_point);
162 - if(!m) {
164 + if(unlikely(!m)) {
165 char var_name[4096 + 1];
166 snprintfz(var_name, 4096, "plugin:proc:/proc/diskstats:%s", mount_point);
167
168 int def_space = config_get_boolean_ondemand("plugin:proc:/proc/diskstats", "space usage for all disks", CONFIG_ONDEMAND_ONDEMAND);
169 int def_inodes = config_get_boolean_ondemand("plugin:proc:/proc/diskstats", "inodes usage for all disks", CONFIG_ONDEMAND_ONDEMAND);
170
169 - if(is_mount_point_excluded(mount_point)) {
171 + if(unlikely(is_mount_point_excluded(mount_point))) {
172 def_space = CONFIG_ONDEMAND_NO;
173 def_inodes = CONFIG_ONDEMAND_NO;
174 }
@@ -187,7 +189,7 @@ static inline void do_disk_space_stats(struct disk *d, const char *mount_point,
189 }
190 }
191
190 - if(do_space == CONFIG_ONDEMAND_NO && do_inodes == CONFIG_ONDEMAND_NO)
192 + if(unlikely(do_space == CONFIG_ONDEMAND_NO && do_inodes == CONFIG_ONDEMAND_NO))
193 return;
194
195 struct statvfs buff_statvfs;
@@ -233,7 +235,7 @@ static inline void do_disk_space_stats(struct disk *d, const char *mount_point,
235
236 if(do_space == CONFIG_ONDEMAND_YES || (do_space == CONFIG_ONDEMAND_ONDEMAND && (bavail || breserved_root || bused))) {
237 st = rrdset_find_bytype("disk_space", disk);
236 - if(!st) {
238 + if(unlikely(!st)) {
239 char title[4096 + 1];
240 snprintfz(title, 4096, "Disk Space Usage for %s [%s]", family, mount_source);
241 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,
244 rrddim_add(st, "used" , NULL, bsize, 1024*1024*1024, RRDDIM_ABSOLUTE);
245 rrddim_add(st, "reserved_for_root", "reserved for root", bsize, 1024*1024*1024, RRDDIM_ABSOLUTE);
246 }
245 - else rrdset_next_usec(st, dt);
247 + else rrdset_next(st);
248
249 rrddim_set(st, "avail", bavail);
250 rrddim_set(st, "used", bused);
@@ -254,7 +256,7 @@ static inline void do_disk_space_stats(struct disk *d, const char *mount_point,
256
257 if(do_inodes == CONFIG_ONDEMAND_YES || (do_inodes == CONFIG_ONDEMAND_ONDEMAND && (favail || freserved_root || fused))) {
258 st = rrdset_find_bytype("disk_inodes", disk);
257 - if(!st) {
259 + if(unlikely(!st)) {
260 char title[4096 + 1];
261 snprintfz(title, 4096, "Disk Files (inodes) Usage for %s [%s]", family, mount_source);
262 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,
265 rrddim_add(st, "used" , NULL, 1, 1, RRDDIM_ABSOLUTE);
266 rrddim_add(st, "reserved_for_root", "reserved for root", 1, 1, RRDDIM_ABSOLUTE);
267 }
266 - else rrdset_next_usec(st, dt);
268 + else rrdset_next(st);
269
270 rrddim_set(st, "avail", favail);
271 rrddim_set(st, "used", fused);
@@ -303,7 +305,7 @@ static struct disk *get_disk(unsigned long major, unsigned long minor, char *dis
305 d->next = NULL;
306
307 // append it to the list
306 - if(!disk_root)
308 + if(unlikely(!disk_root))
309 disk_root = d;
310 else {
311 struct disk *last;
@@ -325,18 +327,19 @@ static struct disk *get_disk(unsigned long major, unsigned long minor, char *dis
327 // find if it is a partition
328 // by checking if /sys/dev/block/MAJOR:MINOR/partition is readable.
329 snprintfz(buffer, FILENAME_MAX, path_find_block_device, major, minor, "partition");
328 - if(access(buffer, R_OK) == 0) {
330 + if(likely(access(buffer, R_OK) == 0)) {
331 d->type = DISK_TYPE_PARTITION;
330 - } else {
332 + }
333 + else {
334 // find if it is a container
335 // by checking if /sys/dev/block/MAJOR:MINOR/slaves has entries
336 snprintfz(buffer, FILENAME_MAX, path_find_block_device, major, minor, "slaves/");
334 - DIR *dirp = opendir(buffer);
335 - if (dirp != NULL) {
337 + DIR *dirp = opendir(buffer);
338 + if(likely(dirp != NULL)) {
339 struct dirent *dp;
340 while( (dp = readdir(dirp)) ) {
341 // . and .. are also files in empty folders.
339 - if(strcmp(dp->d_name, ".") == 0 || strcmp(dp->d_name, "..") == 0) {
342 + if(unlikely(strcmp(dp->d_name, ".") == 0 || strcmp(dp->d_name, "..") == 0)) {
343 continue;
344 }
345
@@ -345,7 +348,7 @@ static struct disk *get_disk(unsigned long major, unsigned long minor, char *dis
348 // Stop the loop after we found one file.
349 break;
350 }
348 - if(closedir(dirp) == -1)
351 + if(unlikely(closedir(dirp) == -1))
352 error("Unable to close dir %s", buffer);
353 }
354 }
@@ -362,7 +365,7 @@ static struct disk *get_disk(unsigned long major, unsigned long minor, char *dis
365 mi = mountinfo_find(disk_mountinfo_root, d->major, d->minor);
366 }
367 */
365 - if(mi) {
368 + if(unlikely(mi)) {
369 d->mount_point = strdupz(mi->mount_point);
370 d->mount_point_hash = mi->mount_point_hash;
371 }
@@ -374,11 +377,11 @@ static struct disk *get_disk(unsigned long major, unsigned long minor, char *dis
377 // ------------------------------------------------------------------------
378 // find the disk sector size
379
377 - if(!path_to_get_hw_sector_size[0]) {
380 + if(unlikely(!path_to_get_hw_sector_size[0])) {
381 snprintfz(buffer, FILENAME_MAX, "%s%s", global_host_prefix, "/sys/block/%s/queue/hw_sector_size");
382 snprintfz(path_to_get_hw_sector_size, FILENAME_MAX, "%s", config_get("plugin:proc:/proc/diskstats", "path to get h/w sector size", buffer));
383 }
381 - if(!path_to_get_hw_sector_size_partitions[0]) {
384 + if(unlikely(!path_to_get_hw_sector_size_partitions[0])) {
385 snprintfz(buffer, FILENAME_MAX, "%s%s", global_host_prefix, "/sys/dev/block/%lu:%lu/subsystem/%s/../queue/hw_sector_size");
386 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));
387 }
@@ -389,21 +392,21 @@ static struct disk *get_disk(unsigned long major, unsigned long minor, char *dis
392
393 // replace all / with !
394 for(t = tf; *t ;t++)
392 - if(*t == '/') *t = '!';
395 + if(unlikely(*t == '/')) *t = '!';
396
394 - if(d->type == DISK_TYPE_PARTITION)
397 + if(likely(d->type == DISK_TYPE_PARTITION))
398 snprintfz(buffer, FILENAME_MAX, path_to_get_hw_sector_size_partitions, d->major, d->minor, tf);
399 else
400 snprintfz(buffer, FILENAME_MAX, path_to_get_hw_sector_size, tf);
401
402 FILE *fpss = fopen(buffer, "r");
400 - if(fpss) {
403 + if(likely(fpss)) {
404 char buffer2[1024 + 1];
405 char *tmp = fgets(buffer2, 1024, fpss);
406
404 - if(tmp) {
407 + if(likely(tmp)) {
408 d->sector_size = atoi(tmp);
406 - if(d->sector_size <= 0) {
409 + if(unlikely(d->sector_size <= 0)) {
410 error("Invalid sector size %d for device %s in %s. Assuming 512.", d->sector_size, d->disk, buffer);
411 d->sector_size = 512;
412 }
@@ -419,15 +422,17 @@ static struct disk *get_disk(unsigned long major, unsigned long minor, char *dis
422 }
423
424 static inline int select_positive_option(int option1, int option2) {
422 - if(option1 == CONFIG_ONDEMAND_YES || option2 == CONFIG_ONDEMAND_YES)
425 + if(unlikely(option1 == CONFIG_ONDEMAND_YES || option2 == CONFIG_ONDEMAND_YES))
426 return CONFIG_ONDEMAND_YES;
424 - else if(option1 == CONFIG_ONDEMAND_ONDEMAND || option2 == CONFIG_ONDEMAND_ONDEMAND)
427 + else if(unlikely(option1 == CONFIG_ONDEMAND_ONDEMAND || option2 == CONFIG_ONDEMAND_ONDEMAND))
428 return CONFIG_ONDEMAND_ONDEMAND;
429
430 return CONFIG_ONDEMAND_NO;
431 }
432
433 int do_proc_diskstats(int update_every, unsigned long long dt) {
434 + (void)dt;
435 +
436 static procfile *ff = NULL;
437 static int global_enable_new_disks_detected_at_runtime = CONFIG_ONDEMAND_YES,
438 global_enable_performance_for_physical_disks = CONFIG_ONDEMAND_ONDEMAND,
@@ -464,15 +469,15 @@ int do_proc_diskstats(int update_every, unsigned long long dt) {
469 globals_initialized = 1;
470 }
471
467 - if(!ff) {
472 + if(unlikely(!ff)) {
473 char filename[FILENAME_MAX + 1];
474 snprintfz(filename, FILENAME_MAX, "%s%s", global_host_prefix, "/proc/diskstats");
475 ff = procfile_open(config_get("plugin:proc:/proc/diskstats", "filename to monitor", filename), " \t", PROCFILE_FLAG_DEFAULT);
476 }
472 - if(!ff) return 1;
477 + if(unlikely(!ff)) return 1;
478
479 ff = procfile_readall(ff);
475 - if(!ff) return 0; // we return 0, so that we will retry to open it next time
480 + if(unlikely(!ff)) return 0; // we return 0, so that we will retry to open it next time
481
482 uint32_t lines = procfile_lines(ff), l;
483 uint32_t words;
@@ -496,7 +501,7 @@ int do_proc_diskstats(int update_every, unsigned long long dt) {
501 last_busy_ms = 0;
502
503 words = procfile_linewords(ff, l);
499 - if(words < 14) continue;
504 + if(unlikely(words < 14)) continue;
505
506 major = strtoul(procfile_lineword(ff, l, 0), NULL, 10);
507 minor = strtoul(procfile_lineword(ff, l, 1), NULL, 10);
@@ -570,7 +575,7 @@ int do_proc_diskstats(int update_every, unsigned long long dt) {
575 snprintfz(var_name, 4096, "plugin:proc:/proc/diskstats:%s", disk);
576
577 int def_enable = config_get_boolean_ondemand(var_name, "enable", global_enable_new_disks_detected_at_runtime);
573 - if(def_enable == CONFIG_ONDEMAND_NO) {
578 + if(unlikely(def_enable == CONFIG_ONDEMAND_NO)) {
579 // the user does not want any metrics for this disk
580 d->do_io = CONFIG_ONDEMAND_NO;
581 d->do_ops = CONFIG_ONDEMAND_NO;
@@ -629,7 +634,7 @@ int do_proc_diskstats(int update_every, unsigned long long dt) {
634 ddo_backlog = CONFIG_ONDEMAND_NO;
635
636 // we enable individual performance charts only when def_performance is not disabled
632 - if(def_performance != CONFIG_ONDEMAND_NO) {
637 + if(unlikely(def_performance != CONFIG_ONDEMAND_NO)) {
638 ddo_io = global_do_io,
639 ddo_ops = global_do_ops,
640 ddo_mops = global_do_mops,
@@ -648,7 +653,7 @@ int do_proc_diskstats(int update_every, unsigned long long dt) {
653 d->do_backlog = config_get_boolean_ondemand(var_name, "backlog", ddo_backlog);
654
655 // def_space
651 - if(d->mount_point) {
656 + if(unlikely(d->mount_point)) {
657 // check the user configuration (this will also show our 'on demand' decision)
658 def_space = config_get_boolean_ondemand(var_name, "enable space metrics", def_space);
659
@@ -677,13 +682,13 @@ int do_proc_diskstats(int update_every, unsigned long long dt) {
682 d->do_io = CONFIG_ONDEMAND_YES;
683
684 st = rrdset_find_bytype(RRD_TYPE_DISK, disk);
680 - if(!st) {
685 + if(unlikely(!st)) {
686 st = rrdset_create(RRD_TYPE_DISK, disk, NULL, family, "disk.io", "Disk I/O Bandwidth", "kilobytes/s", 2000, update_every, RRDSET_TYPE_AREA);
687
688 rrddim_add(st, "reads", NULL, d->sector_size, 1024, RRDDIM_INCREMENTAL);
689 rrddim_add(st, "writes", NULL, d->sector_size * -1, 1024, RRDDIM_INCREMENTAL);
690 }
686 - else rrdset_next_usec(st, dt);
691 + else rrdset_next(st);
692
693 last_readsectors = rrddim_set(st, "reads", readsectors);
694 last_writesectors = rrddim_set(st, "writes", writesectors);
@@ -696,14 +701,14 @@ int do_proc_diskstats(int update_every, unsigned long long dt) {
701 d->do_ops = CONFIG_ONDEMAND_YES;
702
703 st = rrdset_find_bytype("disk_ops", disk);
699 - if(!st) {
704 + if(unlikely(!st)) {
705 st = rrdset_create("disk_ops", disk, NULL, family, "disk.ops", "Disk Completed I/O Operations", "operations/s", 2001, update_every, RRDSET_TYPE_LINE);
706 st->isdetail = 1;
707
708 rrddim_add(st, "reads", NULL, 1, 1, RRDDIM_INCREMENTAL);
709 rrddim_add(st, "writes", NULL, -1, 1, RRDDIM_INCREMENTAL);
710 }
706 - else rrdset_next_usec(st, dt);
711 + else rrdset_next(st);
712
713 last_reads = rrddim_set(st, "reads", reads);
714 last_writes = rrddim_set(st, "writes", writes);
@@ -716,13 +721,13 @@ int do_proc_diskstats(int update_every, unsigned long long dt) {
721 d->do_qops = CONFIG_ONDEMAND_YES;
722
723 st = rrdset_find_bytype("disk_qops", disk);
719 - if(!st) {
724 + if(unlikely(!st)) {
725 st = rrdset_create("disk_qops", disk, NULL, family, "disk.qops", "Disk Current I/O Operations", "operations", 2002, update_every, RRDSET_TYPE_LINE);
726 st->isdetail = 1;
727
728 rrddim_add(st, "operations", NULL, 1, 1, RRDDIM_ABSOLUTE);
729 }
725 - else rrdset_next_usec(st, dt);
730 + else rrdset_next(st);
731
732 rrddim_set(st, "operations", queued_ios);
733 rrdset_done(st);
@@ -734,13 +739,13 @@ int do_proc_diskstats(int update_every, unsigned long long dt) {
739 d->do_backlog = CONFIG_ONDEMAND_YES;
740
741 st = rrdset_find_bytype("disk_backlog", disk);
737 - if(!st) {
742 + if(unlikely(!st)) {
743 st = rrdset_create("disk_backlog", disk, NULL, family, "disk.backlog", "Disk Backlog", "backlog (ms)", 2003, update_every, RRDSET_TYPE_AREA);
744 st->isdetail = 1;
745
746 rrddim_add(st, "backlog", NULL, 1, 10, RRDDIM_INCREMENTAL);
747 }
743 - else rrdset_next_usec(st, dt);
748 + else rrdset_next(st);
749
750 rrddim_set(st, "backlog", backlog_ms);
751 rrdset_done(st);
@@ -752,13 +757,13 @@ int do_proc_diskstats(int update_every, unsigned long long dt) {
757 d->do_util = CONFIG_ONDEMAND_YES;
758
759 st = rrdset_find_bytype("disk_util", disk);
755 - if(!st) {
760 + if(unlikely(!st)) {
761 st = rrdset_create("disk_util", disk, NULL, family, "disk.util", "Disk Utilization Time", "% of time working", 2004, update_every, RRDSET_TYPE_AREA);
762 st->isdetail = 1;
763
764 rrddim_add(st, "utilization", NULL, 1, 10, RRDDIM_INCREMENTAL);
765 }
761 - else rrdset_next_usec(st, dt);
766 + else rrdset_next(st);
767
768 last_busy_ms = rrddim_set(st, "utilization", busy_ms);
769 rrdset_done(st);
@@ -770,14 +775,14 @@ int do_proc_diskstats(int update_every, unsigned long long dt) {
775 d->do_mops = CONFIG_ONDEMAND_YES;
776
777 st = rrdset_find_bytype("disk_mops", disk);
773 - if(!st) {
778 + if(unlikely(!st)) {
779 st = rrdset_create("disk_mops", disk, NULL, family, "disk.mops", "Disk Merged Operations", "merged operations/s", 2021, update_every, RRDSET_TYPE_LINE);
780 st->isdetail = 1;
781
782 rrddim_add(st, "reads", NULL, 1, 1, RRDDIM_INCREMENTAL);
783 rrddim_add(st, "writes", NULL, -1, 1, RRDDIM_INCREMENTAL);
784 }
780 - else rrdset_next_usec(st, dt);
785 + else rrdset_next(st);
786
787 rrddim_set(st, "reads", mreads);
788 rrddim_set(st, "writes", mwrites);
@@ -790,14 +795,14 @@ int do_proc_diskstats(int update_every, unsigned long long dt) {
795 d->do_iotime = CONFIG_ONDEMAND_YES;
796
797 st = rrdset_find_bytype("disk_iotime", disk);
793 - if(!st) {
798 + if(unlikely(!st)) {
799 st = rrdset_create("disk_iotime", disk, NULL, family, "disk.iotime", "Disk Total I/O Time", "milliseconds/s", 2022, update_every, RRDSET_TYPE_LINE);
800 st->isdetail = 1;
801
802 rrddim_add(st, "reads", NULL, 1, 1, RRDDIM_INCREMENTAL);
803 rrddim_add(st, "writes", NULL, -1, 1, RRDDIM_INCREMENTAL);
804 }
800 - else rrdset_next_usec(st, dt);
805 + else rrdset_next(st);
806
807 last_readms = rrddim_set(st, "reads", readms);
808 last_writems = rrddim_set(st, "writes", writems);
@@ -808,18 +813,18 @@ int do_proc_diskstats(int update_every, unsigned long long dt) {
813 // calculate differential charts
814 // only if this is not the first time we run
815
811 - if(dt) {
816 + if(likely(dt)) {
817 if( (d->do_iotime == CONFIG_ONDEMAND_YES || (d->do_iotime == CONFIG_ONDEMAND_ONDEMAND && (readms || writems))) &&
818 (d->do_ops == CONFIG_ONDEMAND_YES || (d->do_ops == CONFIG_ONDEMAND_ONDEMAND && (reads || writes)))) {
819 st = rrdset_find_bytype("disk_await", disk);
815 - if(!st) {
820 + if(unlikely(!st)) {
821 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);
822 st->isdetail = 1;
823
824 rrddim_add(st, "reads", NULL, 1, 1, RRDDIM_ABSOLUTE);
825 rrddim_add(st, "writes", NULL, -1, 1, RRDDIM_ABSOLUTE);
826 }
822 - else rrdset_next_usec(st, dt);
827 + else rrdset_next(st);
828
829 rrddim_set(st, "reads", (reads - last_reads) ? (readms - last_readms) / (reads - last_reads) : 0);
830 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) {
834 if( (d->do_io == CONFIG_ONDEMAND_YES || (d->do_io == CONFIG_ONDEMAND_ONDEMAND && (readsectors || writesectors))) &&
835 (d->do_ops == CONFIG_ONDEMAND_YES || (d->do_ops == CONFIG_ONDEMAND_ONDEMAND && (reads || writes)))) {
836 st = rrdset_find_bytype("disk_avgsz", disk);
832 - if(!st) {
837 + if(unlikely(!st)) {
838 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);
839 st->isdetail = 1;
840
841 rrddim_add(st, "reads", NULL, d->sector_size, 1024, RRDDIM_ABSOLUTE);
842 rrddim_add(st, "writes", NULL, d->sector_size * -1, 1024, RRDDIM_ABSOLUTE);
843 }
839 - else rrdset_next_usec(st, dt);
844 + else rrdset_next(st);
845
846 rrddim_set(st, "reads", (reads - last_reads) ? (readsectors - last_readsectors) / (reads - last_reads) : 0);
847 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) {
851 if( (d->do_util == CONFIG_ONDEMAND_YES || (d->do_util == CONFIG_ONDEMAND_ONDEMAND && busy_ms)) &&
852 (d->do_ops == CONFIG_ONDEMAND_YES || (d->do_ops == CONFIG_ONDEMAND_ONDEMAND && (reads || writes)))) {
853 st = rrdset_find_bytype("disk_svctm", disk);
849 - if(!st) {
854 + if(unlikely(!st)) {
855 st = rrdset_create("disk_svctm", disk, NULL, family, "disk.svctm", "Average Service Time", "ms per operation", 2007, update_every, RRDSET_TYPE_LINE);
856 st->isdetail = 1;
857
858 rrddim_add(st, "svctm", NULL, 1, 1, RRDDIM_ABSOLUTE);
859 }
855 - else rrdset_next_usec(st, dt);
860 + else rrdset_next(st);
861
862 rrddim_set(st, "svctm", ((reads - last_reads) + (writes - last_writes)) ? (busy_ms - last_busy_ms) / ((reads - last_reads) + (writes - last_writes)) : 0);
863 rrdset_done(st);
@@ -863,7 +868,7 @@ int do_proc_diskstats(int update_every, unsigned long long dt) {
868 // --------------------------------------------------------------------------
869 // space metrics
870
866 - if(d->mount_point && (d->do_space || d->do_inodes) ) {
871 + if(unlikely( d->mount_point && (d->do_space || d->do_inodes) )) {
872 do_disk_space_stats(d, d->mount_point, disk, disk, family, update_every, dt);
873 }
874 */
src/proc_interrupts.c
+27 -24
@@ -21,7 +21,7 @@ static inline struct interrupt *get_interrupts_array(int lines, int cpus) {
21 static struct interrupt *irrs = NULL;
22 static int allocated = 0;
23
24 - if(lines > allocated) {
24 + if(unlikely(lines > allocated)) {
25 irrs = (struct interrupt *)reallocz(irrs, lines * recordsize(cpus));
26 allocated = lines;
27 }
@@ -30,42 +30,45 @@ static inline struct interrupt *get_interrupts_array(int lines, int cpus) {
30 }
31
32 int do_proc_interrupts(int update_every, unsigned long long dt) {
33 + (void)dt;
34 +
35 static procfile *ff = NULL;
36 static int cpus = -1, do_per_core = -1;
37 struct interrupt *irrs = NULL;
38
37 - if(dt) {};
38 -
39 - if(do_per_core == -1) do_per_core = config_get_boolean("plugin:proc:/proc/interrupts", "interrupts per core", 1);
39 + if(unlikely(do_per_core == -1))
40 + do_per_core = config_get_boolean("plugin:proc:/proc/interrupts", "interrupts per core", 1);
41
41 - if(!ff) {
42 + if(unlikely(!ff)) {
43 char filename[FILENAME_MAX + 1];
44 snprintfz(filename, FILENAME_MAX, "%s%s", global_host_prefix, "/proc/interrupts");
45 ff = procfile_open(config_get("plugin:proc:/proc/interrupts", "filename to monitor", filename), " \t", PROCFILE_FLAG_DEFAULT);
46 }
46 - if(!ff) return 1;
47 + if(unlikely(!ff))
48 + return 1;
49
50 ff = procfile_readall(ff);
49 - if(!ff) return 0; // we return 0, so that we will retry to open it next time
51 + if(unlikely(!ff))
52 + return 0; // we return 0, so that we will retry to open it next time
53
54 uint32_t lines = procfile_lines(ff), l;
55 uint32_t words = procfile_linewords(ff, 0), w;
56
54 - if(!lines) {
57 + if(unlikely(!lines)) {
58 error("Cannot read /proc/interrupts, zero lines reported.");
59 return 1;
60 }
61
62 // find how many CPUs are there
60 - if(cpus == -1) {
63 + if(unlikely(cpus == -1)) {
64 cpus = 0;
65 for(w = 0; w < words ; w++) {
63 - if(strncmp(procfile_lineword(ff, 0, w), "CPU", 3) == 0)
66 + if(unlikely(strncmp(procfile_lineword(ff, 0, w), "CPU", 3) == 0))
67 cpus++;
68 }
69 }
70
68 - if(!cpus) {
71 + if(unlikely(!cpus)) {
72 error("PLUGIN: PROC_INTERRUPTS: Cannot find the number of CPUs in /proc/interrupts");
73 return 1;
74 }
@@ -81,18 +84,18 @@ int do_proc_interrupts(int update_every, unsigned long long dt) {
84 irr->total = 0;
85
86 words = procfile_linewords(ff, l);
84 - if(!words) continue;
87 + if(unlikely(!words)) continue;
88
89 irr->id = procfile_lineword(ff, l, 0);
87 - if(!irr->id || !irr->id[0]) continue;
90 + if(unlikely(!irr->id || !irr->id[0])) continue;
91
92 int idlen = strlen(irr->id);
90 - if(irr->id[idlen - 1] == ':')
93 + if(unlikely(irr->id[idlen - 1] == ':'))
94 irr->id[idlen - 1] = '\0';
95
96 int c;
97 for(c = 0; c < cpus ;c++) {
95 - if((c + 1) < (int)words)
98 + if(unlikely((c + 1) < (int)words))
99 irr->value[c] = strtoull(procfile_lineword(ff, l, (uint32_t)(c + 1)), NULL, 10);
100 else
101 irr->value[c] = 0;
@@ -100,10 +103,10 @@ int do_proc_interrupts(int update_every, unsigned long long dt) {
103 irr->total += irr->value[c];
104 }
105
103 - if(isdigit(irr->id[0]) && (uint32_t)(cpus + 2) < words) {
106 + if(unlikely(isdigit(irr->id[0]) && (uint32_t)(cpus + 2) < words)) {
107 strncpyz(irr->name, procfile_lineword(ff, l, words - 1), MAX_INTERRUPT_NAME);
108 int nlen = strlen(irr->name);
106 - if(nlen < (MAX_INTERRUPT_NAME-1)) {
109 + if(unlikely(nlen < (MAX_INTERRUPT_NAME-1))) {
110 irr->name[nlen] = '_';
111 strncpyz(&irr->name[nlen + 1], irr->id, MAX_INTERRUPT_NAME - nlen);
112 }
@@ -120,12 +123,12 @@ int do_proc_interrupts(int update_every, unsigned long long dt) {
123 // --------------------------------------------------------------------
124
125 st = rrdset_find_bytype("system", "interrupts");
123 - if(!st) {
126 + if(unlikely(!st)) {
127 st = rrdset_create("system", "interrupts", NULL, "interrupts", NULL, "System interrupts", "interrupts/s", 1000, update_every, RRDSET_TYPE_STACKED);
128
129 for(l = 0; l < lines ;l++) {
130 struct interrupt *irr = irrindex(irrs, l, cpus);
128 - if(!irr->used) continue;
131 + if(unlikely(!irr->used)) continue;
132 rrddim_add(st, irr->id, irr->name, 1, 1, RRDDIM_INCREMENTAL);
133 }
134 }
@@ -133,12 +136,12 @@ int do_proc_interrupts(int update_every, unsigned long long dt) {
136
137 for(l = 0; l < lines ;l++) {
138 struct interrupt *irr = irrindex(irrs, l, cpus);
136 - if(!irr->used) continue;
139 + if(unlikely(!irr->used)) continue;
140 rrddim_set(st, irr->id, irr->total);
141 }
142 rrdset_done(st);
143
141 - if(do_per_core) {
144 + if(likely(do_per_core)) {
145 int c;
146
147 for(c = 0; c < cpus ; c++) {
@@ -146,14 +149,14 @@ int do_proc_interrupts(int update_every, unsigned long long dt) {
149 snprintfz(id, 50, "cpu%d_interrupts", c);
150
151 st = rrdset_find_bytype("cpu", id);
149 - if(!st) {
152 + if(unlikely(!st)) {
153 char title[100+1];
154 snprintfz(title, 100, "CPU%d Interrupts", c);
155 st = rrdset_create("cpu", id, NULL, "interrupts", "cpu.interrupts", title, "interrupts/s", 1100 + c, update_every, RRDSET_TYPE_STACKED);
156
157 for(l = 0; l < lines ;l++) {
158 struct interrupt *irr = irrindex(irrs, l, cpus);
156 - if(!irr->used) continue;
159 + if(unlikely(!irr->used)) continue;
160 rrddim_add(st, irr->id, irr->name, 1, 1, RRDDIM_INCREMENTAL);
161 }
162 }
@@ -161,7 +164,7 @@ int do_proc_interrupts(int update_every, unsigned long long dt) {
164
165 for(l = 0; l < lines ;l++) {
166 struct interrupt *irr = irrindex(irrs, l, cpus);
164 - if(!irr->used) continue;
167 + if(unlikely(!irr->used)) continue;
168 rrddim_set(st, irr->id, irr->value[c]);
169 }
170 rrdset_done(st);
src/proc_loadavg.c
+18 -16
@@ -4,29 +4,31 @@
4 #define MIN_LOADAVG_UPDATE_EVERY 5
5
6 int do_proc_loadavg(int update_every, unsigned long long dt) {
7 + (void)dt;
8 +
9 static procfile *ff = NULL;
10 static int do_loadavg = -1, do_all_processes = -1;
11
10 - if(dt) {};
11 -
12 - if(!ff) {
12 + if(unlikely(!ff)) {
13 char filename[FILENAME_MAX + 1];
14 snprintfz(filename, FILENAME_MAX, "%s%s", global_host_prefix, "/proc/loadavg");
15 ff = procfile_open(config_get("plugin:proc:/proc/loadavg", "filename to monitor", filename), " \t,:|/", PROCFILE_FLAG_DEFAULT);
16 }
17 - if(!ff) return 1;
17 + if(unlikely(!ff))
18 + return 1;
19
20 ff = procfile_readall(ff);
20 - if(!ff) return 0; // we return 0, so that we will retry to open it next time
21 + if(unlikely(!ff))
22 + return 0; // we return 0, so that we will retry to open it next time
23
22 - if(do_loadavg == -1) do_loadavg = config_get_boolean("plugin:proc:/proc/loadavg", "enable load average", 1);
23 - if(do_all_processes == -1) do_all_processes = config_get_boolean("plugin:proc:/proc/loadavg", "enable total processes", 1);
24 + if(unlikely(do_loadavg == -1)) do_loadavg = config_get_boolean("plugin:proc:/proc/loadavg", "enable load average", 1);
25 + if(unlikely(do_all_processes == -1)) do_all_processes = config_get_boolean("plugin:proc:/proc/loadavg", "enable total processes", 1);
26
25 - if(procfile_lines(ff) < 1) {
27 + if(unlikely(procfile_lines(ff) < 1)) {
28 error("/proc/loadavg has no lines.");
29 return 1;
30 }
29 - if(procfile_linewords(ff, 0) < 6) {
31 + if(unlikely(procfile_linewords(ff, 0) < 6)) {
32 error("/proc/loadavg has less than 6 words in it.");
33 return 1;
34 }
@@ -44,9 +46,9 @@ int do_proc_loadavg(int update_every, unsigned long long dt) {
46
47 // --------------------------------------------------------------------
48
47 - if(do_loadavg) {
49 + if(likely(do_loadavg)) {
50 st = rrdset_find_byname("system.load");
49 - if(!st) {
51 + if(unlikely(!st)) {
52 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);
53
54 rrddim_add(st, "load1", NULL, 1, 1000, RRDDIM_ABSOLUTE);
@@ -55,17 +57,17 @@ int do_proc_loadavg(int update_every, unsigned long long dt) {
57 }
58 else rrdset_next(st);
59
58 - rrddim_set(st, "load1", load1 * 1000);
59 - rrddim_set(st, "load5", load5 * 1000);
60 - rrddim_set(st, "load15", load15 * 1000);
60 + rrddim_set(st, "load1", (collected_number)(load1 * 1000));
61 + rrddim_set(st, "load5", (collected_number)(load5 * 1000));
62 + rrddim_set(st, "load15", (collected_number)(load15 * 1000));
63 rrdset_done(st);
64 }
65
66 // --------------------------------------------------------------------
67
66 - if(do_all_processes) {
68 + if(likely(do_all_processes)) {
69 st = rrdset_find_byname("system.active_processes");
68 - if(!st) {
70 + if(unlikely(!st)) {
71 st = rrdset_create("system", "active_processes", NULL, "processes", NULL, "System Active Processes", "processes", 750, update_every, RRDSET_TYPE_LINE);
72
73 rrddim_add(st, "active", NULL, 1, 1, RRDDIM_ABSOLUTE);
src/proc_meminfo.c
+188 -68
@@ -1,96 +1,216 @@
1 #include "common.h"
2
3 -#define MAX_PROC_MEMINFO_LINE 4096
4 -#define MAX_PROC_MEMINFO_NAME 1024
5 -
3 int do_proc_meminfo(int update_every, unsigned long long dt) {
7 - static procfile *ff = NULL;
4 + (void)dt;
5
6 + static procfile *ff = NULL;
7 static int do_ram = -1, do_swap = -1, do_hwcorrupt = -1, do_committed = -1, do_writeback = -1, do_kernel = -1, do_slab = -1;
8 + static uint32_t MemTotal_hash = 0,
9 + MemFree_hash = 0,
10 + Buffers_hash = 0,
11 + Cached_hash = 0,
12 + //SwapCached_hash = 0,
13 + //Active_hash = 0,
14 + //Inactive_hash = 0,
15 + //ActiveAnon_hash = 0,
16 + //InactiveAnon_hash = 0,
17 + //ActiveFile_hash = 0,
18 + //InactiveFile_hash = 0,
19 + //Unevictable_hash = 0,
20 + //Mlocked_hash = 0,
21 + SwapTotal_hash = 0,
22 + SwapFree_hash = 0,
23 + Dirty_hash = 0,
24 + Writeback_hash = 0,
25 + //AnonPages_hash = 0,
26 + //Mapped_hash = 0,
27 + //Shmem_hash = 0,
28 + Slab_hash = 0,
29 + SReclaimable_hash = 0,
30 + SUnreclaim_hash = 0,
31 + KernelStack_hash = 0,
32 + PageTables_hash = 0,
33 + NFS_Unstable_hash = 0,
34 + Bounce_hash = 0,
35 + WritebackTmp_hash = 0,
36 + //CommitLimit_hash = 0,
37 + Committed_AS_hash = 0,
38 + //VmallocTotal_hash = 0,
39 + VmallocUsed_hash = 0,
40 + //VmallocChunk_hash = 0,
41 + //AnonHugePages_hash = 0,
42 + //HugePages_Total_hash = 0,
43 + //HugePages_Free_hash = 0,
44 + //HugePages_Rsvd_hash = 0,
45 + //HugePages_Surp_hash = 0,
46 + //Hugepagesize_hash = 0,
47 + //DirectMap4k_hash = 0,
48 + //DirectMap2M_hash = 0,
49 + HardwareCorrupted_hash = 0;
50 +
51 + if(unlikely(do_ram == -1)) {
52 + do_ram = config_get_boolean("plugin:proc:/proc/meminfo", "system ram", 1);
53 + do_swap = config_get_boolean_ondemand("plugin:proc:/proc/meminfo", "system swap", CONFIG_ONDEMAND_ONDEMAND);
54 + do_hwcorrupt = config_get_boolean_ondemand("plugin:proc:/proc/meminfo", "hardware corrupted ECC", CONFIG_ONDEMAND_ONDEMAND);
55 + do_committed = config_get_boolean("plugin:proc:/proc/meminfo", "committed memory", 1);
56 + do_writeback = config_get_boolean("plugin:proc:/proc/meminfo", "writeback memory", 1);
57 + do_kernel = config_get_boolean("plugin:proc:/proc/meminfo", "kernel memory", 1);
58 + do_slab = config_get_boolean("plugin:proc:/proc/meminfo", "slab memory", 1);
59 +
60 + MemTotal_hash = simple_hash("MemTotal");
61 + MemFree_hash = simple_hash("MemFree");
62 + Buffers_hash = simple_hash("Buffers");
63 + Cached_hash = simple_hash("Cached");
64 + //SwapCached_hash = simple_hash("SwapCached");
65 + //Active_hash = simple_hash("Active");
66 + //Inactive_hash = simple_hash("Inactive");
67 + //ActiveAnon_hash = simple_hash("ActiveAnon");
68 + //InactiveAnon_hash = simple_hash("InactiveAnon");
69 + //ActiveFile_hash = simple_hash("ActiveFile");
70 + //InactiveFile_hash = simple_hash("InactiveFile");
71 + //Unevictable_hash = simple_hash("Unevictable");
72 + //Mlocked_hash = simple_hash("Mlocked");
73 + SwapTotal_hash = simple_hash("SwapTotal");
74 + SwapFree_hash = simple_hash("SwapFree");
75 + Dirty_hash = simple_hash("Dirty");
76 + Writeback_hash = simple_hash("Writeback");
77 + //AnonPages_hash = simple_hash("AnonPages");
78 + //Mapped_hash = simple_hash("Mapped");
79 + //Shmem_hash = simple_hash("Shmem");
80 + Slab_hash = simple_hash("Slab");
81 + SReclaimable_hash = simple_hash("SReclaimable");
82 + SUnreclaim_hash = simple_hash("SUnreclaim");
83 + KernelStack_hash = simple_hash("KernelStack");
84 + PageTables_hash = simple_hash("PageTables");
85 + NFS_Unstable_hash = simple_hash("NFS_Unstable");
86 + Bounce_hash = simple_hash("Bounce");
87 + WritebackTmp_hash = simple_hash("WritebackTmp");
88 + //CommitLimit_hash = simple_hash("CommitLimit");
89 + Committed_AS_hash = simple_hash("Committed_AS");
90 + //VmallocTotal_hash = simple_hash("VmallocTotal");
91 + VmallocUsed_hash = simple_hash("VmallocUsed");
92 + //VmallocChunk_hash = simple_hash("VmallocChunk");
93 + HardwareCorrupted_hash = simple_hash("HardwareCorrupted");
94 + //AnonHugePages_hash = simple_hash("AnonHugePages");
95 + //HugePages_Total_hash = simple_hash("HugePages_Total");
96 + //HugePages_Free_hash = simple_hash("HugePages_Free");
97 + //HugePages_Rsvd_hash = simple_hash("HugePages_Rsvd");
98 + //HugePages_Surp_hash = simple_hash("HugePages_Surp");
99 + //Hugepagesize_hash = simple_hash("Hugepagesize");
100 + //DirectMap4k_hash = simple_hash("DirectMap4k");
101 + //DirectMap2M_hash = simple_hash("DirectMap2M");
102 + }
103
11 - if(do_ram == -1) do_ram = config_get_boolean("plugin:proc:/proc/meminfo", "system ram", 1);
12 - if(do_swap == -1) do_swap = config_get_boolean_ondemand("plugin:proc:/proc/meminfo", "system swap", CONFIG_ONDEMAND_ONDEMAND);
13 - if(do_hwcorrupt == -1) do_hwcorrupt = config_get_boolean_ondemand("plugin:proc:/proc/meminfo", "hardware corrupted ECC", CONFIG_ONDEMAND_ONDEMAND);
14 - if(do_committed == -1) do_committed = config_get_boolean("plugin:proc:/proc/meminfo", "committed memory", 1);
15 - if(do_writeback == -1) do_writeback = config_get_boolean("plugin:proc:/proc/meminfo", "writeback memory", 1);
16 - if(do_kernel == -1) do_kernel = config_get_boolean("plugin:proc:/proc/meminfo", "kernel memory", 1);
17 - if(do_slab == -1) do_slab = config_get_boolean("plugin:proc:/proc/meminfo", "slab memory", 1);
18 -
19 - (void)dt;
20 -
21 - if(!ff) {
104 + if(unlikely(!ff)) {
105 char filename[FILENAME_MAX + 1];
106 snprintfz(filename, FILENAME_MAX, "%s%s", global_host_prefix, "/proc/meminfo");
107 ff = procfile_open(config_get("plugin:proc:/proc/meminfo", "filename to monitor", filename), " \t:", PROCFILE_FLAG_DEFAULT);
108 + if(unlikely(!ff))
109 + return 1;
110 }
26 - if(!ff) return 1;
111
112 ff = procfile_readall(ff);
29 - if(!ff) return 0; // we return 0, so that we will retry to open it next time
113 + if(unlikely(!ff))
114 + return 0; // we return 0, so that we will retry to open it next time
115
116 uint32_t lines = procfile_lines(ff), l;
117 uint32_t words;
118
119 int hwcorrupted = 0;
120
36 - unsigned long long MemTotal = 0, MemFree = 0, Buffers = 0, Cached = 0, SwapCached = 0,
37 - Active = 0, Inactive = 0, ActiveAnon = 0, InactiveAnon = 0, ActiveFile = 0, InactiveFile = 0,
38 - Unevictable = 0, Mlocked = 0, SwapTotal = 0, SwapFree = 0, Dirty = 0, Writeback = 0, AnonPages = 0,
39 - Mapped = 0, Shmem = 0, Slab = 0, SReclaimable = 0, SUnreclaim = 0, KernelStack = 0, PageTables = 0,
40 - NFS_Unstable = 0, Bounce = 0, WritebackTmp = 0, CommitLimit = 0, Committed_AS = 0,
41 - VmallocTotal = 0, VmallocUsed = 0, VmallocChunk = 0,
42 - AnonHugePages = 0, HugePages_Total = 0, HugePages_Free = 0, HugePages_Rsvd = 0, HugePages_Surp = 0, Hugepagesize = 0,
43 - DirectMap4k = 0, DirectMap2M = 0, HardwareCorrupted = 0;
121 + unsigned long long MemTotal = 0,
122 + MemFree = 0,
123 + Buffers = 0,
124 + Cached = 0,
125 + //SwapCached = 0,
126 + //Active = 0,
127 + //Inactive = 0,
128 + //ActiveAnon = 0,
129 + //InactiveAnon = 0,
130 + //ActiveFile = 0,
131 + //InactiveFile = 0,
132 + //Unevictable = 0,
133 + //Mlocked = 0,
134 + SwapTotal = 0,
135 + SwapFree = 0,
136 + Dirty = 0,
137 + Writeback = 0,
138 + //AnonPages = 0,
139 + //Mapped = 0,
140 + //Shmem = 0,
141 + Slab = 0,
142 + SReclaimable = 0,
143 + SUnreclaim = 0,
144 + KernelStack = 0,
145 + PageTables = 0,
146 + NFS_Unstable = 0,
147 + Bounce = 0,
148 + WritebackTmp = 0,
149 + //CommitLimit = 0,
150 + Committed_AS = 0,
151 + //VmallocTotal = 0,
152 + VmallocUsed = 0,
153 + //VmallocChunk = 0,
154 + //AnonHugePages = 0,
155 + //HugePages_Total = 0,
156 + //HugePages_Free = 0,
157 + //HugePages_Rsvd = 0,
158 + //HugePages_Surp = 0,
159 + //Hugepagesize = 0,
160 + //DirectMap4k = 0,
161 + //DirectMap2M = 0,
162 + HardwareCorrupted = 0;
163
164 for(l = 0; l < lines ;l++) {
165 words = procfile_linewords(ff, l);
47 - if(words < 2) continue;
166 + if(unlikely(words < 2)) continue;
167
168 char *name = procfile_lineword(ff, l, 0);
169 + uint32_t hash = simple_hash(name);
170 unsigned long long value = strtoull(procfile_lineword(ff, l, 1), NULL, 10);
171
52 - if(!MemTotal && strcmp(name, "MemTotal") == 0) MemTotal = value;
53 - else if(!MemFree && strcmp(name, "MemFree") == 0) MemFree = value;
54 - else if(!Buffers && strcmp(name, "Buffers") == 0) Buffers = value;
55 - else if(!Cached && strcmp(name, "Cached") == 0) Cached = value;
56 - else if(!SwapCached && strcmp(name, "SwapCached") == 0) SwapCached = value;
57 - else if(!Active && strcmp(name, "Active") == 0) Active = value;
58 - else if(!Inactive && strcmp(name, "Inactive") == 0) Inactive = value;
59 - else if(!ActiveAnon && strcmp(name, "ActiveAnon") == 0) ActiveAnon = value;
60 - else if(!InactiveAnon && strcmp(name, "InactiveAnon") == 0) InactiveAnon = value;
61 - else if(!ActiveFile && strcmp(name, "ActiveFile") == 0) ActiveFile = value;
62 - else if(!InactiveFile && strcmp(name, "InactiveFile") == 0) InactiveFile = value;
63 - else if(!Unevictable && strcmp(name, "Unevictable") == 0) Unevictable = value;
64 - else if(!Mlocked && strcmp(name, "Mlocked") == 0) Mlocked = value;
65 - else if(!SwapTotal && strcmp(name, "SwapTotal") == 0) SwapTotal = value;
66 - else if(!SwapFree && strcmp(name, "SwapFree") == 0) SwapFree = value;
67 - else if(!Dirty && strcmp(name, "Dirty") == 0) Dirty = value;
68 - else if(!Writeback && strcmp(name, "Writeback") == 0) Writeback = value;
69 - else if(!AnonPages && strcmp(name, "AnonPages") == 0) AnonPages = value;
70 - else if(!Mapped && strcmp(name, "Mapped") == 0) Mapped = value;
71 - else if(!Shmem && strcmp(name, "Shmem") == 0) Shmem = value;
72 - else if(!Slab && strcmp(name, "Slab") == 0) Slab = value;
73 - else if(!SReclaimable && strcmp(name, "SReclaimable") == 0) SReclaimable = value;
74 - else if(!SUnreclaim && strcmp(name, "SUnreclaim") == 0) SUnreclaim = value;
75 - else if(!KernelStack && strcmp(name, "KernelStack") == 0) KernelStack = value;
76 - else if(!PageTables && strcmp(name, "PageTables") == 0) PageTables = value;
77 - else if(!NFS_Unstable && strcmp(name, "NFS_Unstable") == 0) NFS_Unstable = value;
78 - else if(!Bounce && strcmp(name, "Bounce") == 0) Bounce = value;
79 - else if(!WritebackTmp && strcmp(name, "WritebackTmp") == 0) WritebackTmp = value;
80 - else if(!CommitLimit && strcmp(name, "CommitLimit") == 0) CommitLimit = value;
81 - else if(!Committed_AS && strcmp(name, "Committed_AS") == 0) Committed_AS = value;
82 - else if(!VmallocTotal && strcmp(name, "VmallocTotal") == 0) VmallocTotal = value;
83 - else if(!VmallocUsed && strcmp(name, "VmallocUsed") == 0) VmallocUsed = value;
84 - else if(!VmallocChunk && strcmp(name, "VmallocChunk") == 0) VmallocChunk = value;
85 - else if(!HardwareCorrupted && strcmp(name, "HardwareCorrupted") == 0) { HardwareCorrupted = value; hwcorrupted = 1; }
86 - else if(!AnonHugePages && strcmp(name, "AnonHugePages") == 0) AnonHugePages = value;
87 - else if(!HugePages_Total && strcmp(name, "HugePages_Total") == 0) HugePages_Total = value;
88 - else if(!HugePages_Free && strcmp(name, "HugePages_Free") == 0) HugePages_Free = value;
89 - else if(!HugePages_Rsvd && strcmp(name, "HugePages_Rsvd") == 0) HugePages_Rsvd = value;
90 - else if(!HugePages_Surp && strcmp(name, "HugePages_Surp") == 0) HugePages_Surp = value;
91 - else if(!Hugepagesize && strcmp(name, "Hugepagesize") == 0) Hugepagesize = value;
92 - else if(!DirectMap4k && strcmp(name, "DirectMap4k") == 0) DirectMap4k = value;
93 - else if(!DirectMap2M && strcmp(name, "DirectMap2M") == 0) DirectMap2M = value;
172 + if(hash == MemTotal_hash && strcmp(name, "MemTotal") == 0) MemTotal = value;
173 + else if(hash == MemFree_hash && strcmp(name, "MemFree") == 0) MemFree = value;
174 + else if(hash == Buffers_hash && strcmp(name, "Buffers") == 0) Buffers = value;
175 + else if(hash == Cached_hash && strcmp(name, "Cached") == 0) Cached = value;
176 + //else if(hash == SwapCached_hash && strcmp(name, "SwapCached") == 0) SwapCached = value;
177 + //else if(hash == Active_hash && strcmp(name, "Active") == 0) Active = value;
178 + //else if(hash == Inactive_hash && strcmp(name, "Inactive") == 0) Inactive = value;
179 + //else if(hash == ActiveAnon_hash && strcmp(name, "ActiveAnon") == 0) ActiveAnon = value;
180 + //else if(hash == InactiveAnon_hash && strcmp(name, "InactiveAnon") == 0) InactiveAnon = value;
181 + //else if(hash == ActiveFile_hash && strcmp(name, "ActiveFile") == 0) ActiveFile = value;
182 + //else if(hash == InactiveFile_hash && strcmp(name, "InactiveFile") == 0) InactiveFile = value;
183 + //else if(hash == Unevictable_hash && strcmp(name, "Unevictable") == 0) Unevictable = value;
184 + //else if(hash == Mlocked_hash && strcmp(name, "Mlocked") == 0) Mlocked = value;
185 + else if(hash == SwapTotal_hash && strcmp(name, "SwapTotal") == 0) SwapTotal = value;
186 + else if(hash == SwapFree_hash && strcmp(name, "SwapFree") == 0) SwapFree = value;
187 + else if(hash == Dirty_hash && strcmp(name, "Dirty") == 0) Dirty = value;
188 + else if(hash == Writeback_hash && strcmp(name, "Writeback") == 0) Writeback = value;
189 + //else if(hash == AnonPages_hash && strcmp(name, "AnonPages") == 0) AnonPages = value;
190 + //else if(hash == Mapped_hash && strcmp(name, "Mapped") == 0) Mapped = value;
191 + //else if(hash == Shmem_hash && strcmp(name, "Shmem") == 0) Shmem = value;
192 + else if(hash == Slab_hash && strcmp(name, "Slab") == 0) Slab = value;
193 + else if(hash == SReclaimable_hash && strcmp(name, "SReclaimable") == 0) SReclaimable = value;
194 + else if(hash == SUnreclaim_hash && strcmp(name, "SUnreclaim") == 0) SUnreclaim = value;
195 + else if(hash == KernelStack_hash && strcmp(name, "KernelStack") == 0) KernelStack = value;
196 + else if(hash == PageTables_hash && strcmp(name, "PageTables") == 0) PageTables = value;
197 + else if(hash == NFS_Unstable_hash && strcmp(name, "NFS_Unstable") == 0) NFS_Unstable = value;
198 + else if(hash == Bounce_hash && strcmp(name, "Bounce") == 0) Bounce = value;
199 + else if(hash == WritebackTmp_hash && strcmp(name, "WritebackTmp") == 0) WritebackTmp = value;
200 + //else if(hash == CommitLimit_hash && strcmp(name, "CommitLimit") == 0) CommitLimit = value;
201 + else if(hash == Committed_AS_hash && strcmp(name, "Committed_AS") == 0) Committed_AS = value;
202 + //else if(hash == VmallocTotal_hash && strcmp(name, "VmallocTotal") == 0) VmallocTotal = value;
203 + else if(hash == VmallocUsed_hash && strcmp(name, "VmallocUsed") == 0) VmallocUsed = value;
204 + //else if(hash == VmallocChunk_hash && strcmp(name, "VmallocChunk") == 0) VmallocChunk = value;
205 + else if(hash == HardwareCorrupted_hash && strcmp(name, "HardwareCorrupted") == 0) { HardwareCorrupted = value; hwcorrupted = 1; }
206 + //else if(hash == AnonHugePages_hash && strcmp(name, "AnonHugePages") == 0) AnonHugePages = value;
207 + //else if(hash == HugePages_Total_hash && strcmp(name, "HugePages_Total") == 0) HugePages_Total = value;
208 + //else if(hash == HugePages_Free_hash && strcmp(name, "HugePages_Free") == 0) HugePages_Free = value;
209 + //else if(hash == HugePages_Rsvd_hash && strcmp(name, "HugePages_Rsvd") == 0) HugePages_Rsvd = value;
210 + //else if(hash == HugePages_Surp_hash && strcmp(name, "HugePages_Surp") == 0) HugePages_Surp = value;
211 + //else if(hash == Hugepagesize_hash && strcmp(name, "Hugepagesize") == 0) Hugepagesize = value;
212 + //else if(hash == DirectMap4k_hash && strcmp(name, "DirectMap4k") == 0) DirectMap4k = value;
213 + //else if(hash == DirectMap2M_hash && strcmp(name, "DirectMap2M") == 0) DirectMap2M = value;
214 }
215
216 RRDSET *st;
src/proc_net_netstat.c
+17 -17
@@ -543,8 +543,8 @@ int do_proc_net_netstat(int update_every, unsigned long long dt) {
543 char filename[FILENAME_MAX + 1];
544 snprintfz(filename, FILENAME_MAX, "%s%s", global_host_prefix, "/proc/net/netstat");
545 ff = procfile_open(config_get("plugin:proc:/proc/net/netstat", "filename to monitor", filename), " \t:", PROCFILE_FLAG_DEFAULT);
546 + if(unlikely(!ff)) return 1;
547 }
547 - if(unlikely(!ff)) return 1;
548
549 ff = procfile_readall(ff);
550 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) {
559 if(unlikely(hash == hash_ipext && strcmp(key, "IpExt") == 0)) {
560 uint32_t h = l++;
561
562 - if(strcmp(procfile_lineword(ff, l, 0), "IpExt") != 0) {
562 + if(unlikely(strcmp(procfile_lineword(ff, l, 0), "IpExt") != 0)) {
563 error("Cannot read IpExt line from /proc/net/netstat.");
564 break;
565 }
566 words = procfile_linewords(ff, l);
567 - if(words < 2) {
567 + if(unlikely(words < 2)) {
568 error("Cannot read /proc/net/netstat IpExt line. Expected 2+ params, read %u.", words);
569 continue;
570 }
@@ -578,7 +578,7 @@ int do_proc_net_netstat(int update_every, unsigned long long dt) {
578 if(do_bandwidth == CONFIG_ONDEMAND_YES || (do_bandwidth == CONFIG_ONDEMAND_ONDEMAND && (*ipext_InOctets || *ipext_OutOctets))) {
579 do_bandwidth = CONFIG_ONDEMAND_YES;
580 st = rrdset_find("system.ipv4");
581 - if(!st) {
581 + if(unlikely(!st)) {
582 st = rrdset_create("system", "ipv4", NULL, "network", NULL, "IPv4 Bandwidth", "kilobits/s", 500, update_every, RRDSET_TYPE_AREA);
583
584 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) {
596 if(do_inerrors == CONFIG_ONDEMAND_YES || (do_inerrors == CONFIG_ONDEMAND_ONDEMAND && (*ipext_InNoRoutes || *ipext_InTruncatedPkts))) {
597 do_inerrors = CONFIG_ONDEMAND_YES;
598 st = rrdset_find("ipv4.inerrors");
599 - if(!st) {
599 + if(unlikely(!st)) {
600 st = rrdset_create("ipv4", "inerrors", NULL, "errors", NULL, "IPv4 Input Errors", "packets/s", 4000, update_every, RRDSET_TYPE_LINE);
601 st->isdetail = 1;
602
@@ -617,7 +617,7 @@ int do_proc_net_netstat(int update_every, unsigned long long dt) {
617 if(do_mcast == CONFIG_ONDEMAND_YES || (do_mcast == CONFIG_ONDEMAND_ONDEMAND && (*ipext_InMcastOctets || *ipext_OutMcastOctets))) {
618 do_mcast = CONFIG_ONDEMAND_YES;
619 st = rrdset_find("ipv4.mcast");
620 - if(!st) {
620 + if(unlikely(!st)) {
621 st = rrdset_create("ipv4", "mcast", NULL, "multicast", NULL, "IPv4 Multicast Bandwidth", "kilobits/s", 9000, update_every, RRDSET_TYPE_AREA);
622 st->isdetail = 1;
623
@@ -636,7 +636,7 @@ int do_proc_net_netstat(int update_every, unsigned long long dt) {
636 if(do_bcast == CONFIG_ONDEMAND_YES || (do_bcast == CONFIG_ONDEMAND_ONDEMAND && (*ipext_InBcastOctets || *ipext_OutBcastOctets))) {
637 do_bcast = CONFIG_ONDEMAND_YES;
638 st = rrdset_find("ipv4.bcast");
639 - if(!st) {
639 + if(unlikely(!st)) {
640 st = rrdset_create("ipv4", "bcast", NULL, "broadcast", NULL, "IPv4 Broadcast Bandwidth", "kilobits/s", 8000, update_every, RRDSET_TYPE_AREA);
641 st->isdetail = 1;
642
@@ -655,7 +655,7 @@ int do_proc_net_netstat(int update_every, unsigned long long dt) {
655 if(do_mcast_p == CONFIG_ONDEMAND_YES || (do_mcast_p == CONFIG_ONDEMAND_ONDEMAND && (*ipext_InMcastPkts || *ipext_OutMcastPkts))) {
656 do_mcast_p = CONFIG_ONDEMAND_YES;
657 st = rrdset_find("ipv4.mcastpkts");
658 - if(!st) {
658 + if(unlikely(!st)) {
659 st = rrdset_create("ipv4", "mcastpkts", NULL, "multicast", NULL, "IPv4 Multicast Packets", "packets/s", 8600, update_every, RRDSET_TYPE_LINE);
660 st->isdetail = 1;
661
@@ -674,7 +674,7 @@ int do_proc_net_netstat(int update_every, unsigned long long dt) {
674 if(do_bcast_p == CONFIG_ONDEMAND_YES || (do_bcast_p == CONFIG_ONDEMAND_ONDEMAND && (*ipext_InBcastPkts || *ipext_OutBcastPkts))) {
675 do_bcast_p = CONFIG_ONDEMAND_YES;
676 st = rrdset_find("ipv4.bcastpkts");
677 - if(!st) {
677 + if(unlikely(!st)) {
678 st = rrdset_create("ipv4", "bcastpkts", NULL, "broadcast", NULL, "IPv4 Broadcast Packets", "packets/s", 8500, update_every, RRDSET_TYPE_LINE);
679 st->isdetail = 1;
680
@@ -693,7 +693,7 @@ int do_proc_net_netstat(int update_every, unsigned long long dt) {
693 if(do_ecn == CONFIG_ONDEMAND_YES || (do_ecn == CONFIG_ONDEMAND_ONDEMAND && (*ipext_InCEPkts || *ipext_InECT0Pkts || *ipext_InECT1Pkts || *ipext_InNoECTPkts))) {
694 do_ecn = CONFIG_ONDEMAND_YES;
695 st = rrdset_find("ipv4.ecnpkts");
696 - if(!st) {
696 + if(unlikely(!st)) {
697 st = rrdset_create("ipv4", "ecnpkts", NULL, "ecn", NULL, "IPv4 ECN Statistics", "packets/s", 8700, update_every, RRDSET_TYPE_LINE);
698 st->isdetail = 1;
699
@@ -714,12 +714,12 @@ int do_proc_net_netstat(int update_every, unsigned long long dt) {
714 else if(unlikely(hash == hash_tcpext && strcmp(key, "TcpExt") == 0)) {
715 uint32_t h = l++;
716
717 - if(strcmp(procfile_lineword(ff, l, 0), "TcpExt") != 0) {
717 + if(unlikely(strcmp(procfile_lineword(ff, l, 0), "TcpExt") != 0)) {
718 error("Cannot read TcpExt line from /proc/net/netstat.");
719 break;
720 }
721 words = procfile_linewords(ff, l);
722 - if(words < 2) {
722 + if(unlikely(words < 2)) {
723 error("Cannot read /proc/net/netstat TcpExt line. Expected 2+ params, read %u.", words);
724 continue;
725 }
@@ -733,7 +733,7 @@ int do_proc_net_netstat(int update_every, unsigned long long dt) {
733 if(do_tcpext_memory == CONFIG_ONDEMAND_YES || (do_tcpext_memory == CONFIG_ONDEMAND_ONDEMAND && (*tcpext_TCPMemoryPressures))) {
734 do_tcpext_memory = CONFIG_ONDEMAND_YES;
735 st = rrdset_find("ipv4.tcpmemorypressures");
736 - if(!st) {
736 + if(unlikely(!st)) {
737 st = rrdset_create("ipv4", "tcpmemorypressures", NULL, "tcp", NULL, "TCP Memory Pressures", "events/s", 3000, update_every, RRDSET_TYPE_LINE);
738
739 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) {
749 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))) {
750 do_tcpext_connaborts = CONFIG_ONDEMAND_YES;
751 st = rrdset_find("ipv4.tcpconnaborts");
752 - if(!st) {
752 + if(unlikely(!st)) {
753 st = rrdset_create("ipv4", "tcpconnaborts", NULL, "tcp", NULL, "TCP Connection Aborts", "connections/s", 3010, update_every, RRDSET_TYPE_LINE);
754
755 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) {
774 if(do_tcpext_reorder == CONFIG_ONDEMAND_YES || (do_tcpext_reorder == CONFIG_ONDEMAND_ONDEMAND && (*tcpext_TCPRenoReorder || *tcpext_TCPFACKReorder || *tcpext_TCPSACKReorder || *tcpext_TCPTSReorder))) {
775 do_tcpext_reorder = CONFIG_ONDEMAND_YES;
776 st = rrdset_find("ipv4.tcpreorders");
777 - if(!st) {
777 + if(unlikely(!st)) {
778 st = rrdset_create("ipv4", "tcpreorders", NULL, "tcp", NULL, "TCP Reordered Packets by Detection Method", "packets/s", 3020, update_every, RRDSET_TYPE_LINE);
779
780 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) {
796 if(do_tcpext_ofo == CONFIG_ONDEMAND_YES || (do_tcpext_ofo == CONFIG_ONDEMAND_ONDEMAND && (*tcpext_TCPOFOQueue || *tcpext_TCPOFODrop || *tcpext_TCPOFOMerge))) {
797 do_tcpext_ofo = CONFIG_ONDEMAND_YES;
798 st = rrdset_find("ipv4.tcpofo");
799 - if(!st) {
799 + if(unlikely(!st)) {
800 st = rrdset_create("ipv4", "tcpofo", NULL, "tcp", NULL, "TCP Out-Of-Order Queue", "packets/s", 3050, update_every, RRDSET_TYPE_LINE);
801
802 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) {
818 if(do_tcpext_syscookies == CONFIG_ONDEMAND_YES || (do_tcpext_syscookies == CONFIG_ONDEMAND_ONDEMAND && (*tcpext_SyncookiesSent || *tcpext_SyncookiesRecv || *tcpext_SyncookiesFailed))) {
819 do_tcpext_syscookies = CONFIG_ONDEMAND_YES;
820 st = rrdset_find("ipv4.tcpsyncookies");
821 - if(!st) {
821 + if(unlikely(!st)) {
822 st = rrdset_create("ipv4", "tcpsyncookies", NULL, "tcp", NULL, "TCP SYN Cookies", "packets/s", 3100, update_every, RRDSET_TYPE_LINE);
823
824 rrddim_add(st, "SyncookiesRecv", "received", 1, 1, RRDDIM_INCREMENTAL);
src/proc_net_snmp.c
+1 -1
@@ -360,8 +360,8 @@ int do_proc_net_snmp(int update_every, unsigned long long dt) {
360 char filename[FILENAME_MAX + 1];
361 snprintfz(filename, FILENAME_MAX, "%s%s", global_host_prefix, "/proc/net/snmp");
362 ff = procfile_open(config_get("plugin:proc:/proc/net/snmp", "filename to monitor", filename), " \t:", PROCFILE_FLAG_DEFAULT);
363 + if(unlikely(!ff)) return 1;
364 }
364 - if(unlikely(!ff)) return 1;
365
366 ff = procfile_readall(ff);
367 if(unlikely(!ff)) return 0; // we return 0, so that we will retry to open it next time
src/proc_net_snmp6.c
+256 -253
@@ -4,8 +4,10 @@
4 #define RRD_TYPE_NET_SNMP6_LEN strlen(RRD_TYPE_NET_SNMP6)
5
6 int do_proc_net_snmp6(int update_every, unsigned long long dt) {
7 + (void)dt;
8 +
9 static procfile *ff = NULL;
8 - static int gen_hashes = -1;
10 + static int initialized = 0;
11
12 static int do_ip_packets = -1, do_ip_fragsout = -1, do_ip_fragsin = -1, do_ip_errors = -1,
13 do_udplite_packets = -1, do_udplite_errors = -1,
@@ -14,112 +16,113 @@ int do_proc_net_snmp6(int update_every, unsigned long long dt) {
16 do_icmp = -1, do_icmp_redir = -1, do_icmp_errors = -1, do_icmp_echos = -1, do_icmp_groupmemb = -1,
17 do_icmp_router = -1, do_icmp_neighbor = -1, do_icmp_mldv2 = -1, do_icmp_types = -1, do_ect = -1;
18
17 - static uint32_t hash_Ip6InReceives = -1;
18 -
19 - static uint32_t hash_Ip6InHdrErrors = -1;
20 - static uint32_t hash_Ip6InTooBigErrors = -1;
21 - static uint32_t hash_Ip6InNoRoutes = -1;
22 - static uint32_t hash_Ip6InAddrErrors = -1;
23 - static uint32_t hash_Ip6InUnknownProtos = -1;
24 - static uint32_t hash_Ip6InTruncatedPkts = -1;
25 - static uint32_t hash_Ip6InDiscards = -1;
26 - static uint32_t hash_Ip6InDelivers = -1;
27 -
28 - static uint32_t hash_Ip6OutForwDatagrams = -1;
29 - static uint32_t hash_Ip6OutRequests = -1;
30 - static uint32_t hash_Ip6OutDiscards = -1;
31 - static uint32_t hash_Ip6OutNoRoutes = -1;
32 -
33 - static uint32_t hash_Ip6ReasmTimeout = -1;
34 - static uint32_t hash_Ip6ReasmReqds = -1;
35 - static uint32_t hash_Ip6ReasmOKs = -1;
36 - static uint32_t hash_Ip6ReasmFails = -1;
37 -
38 - static uint32_t hash_Ip6FragOKs = -1;
39 - static uint32_t hash_Ip6FragFails = -1;
40 - static uint32_t hash_Ip6FragCreates = -1;
41 -
42 - static uint32_t hash_Ip6InMcastPkts = -1;
43 - static uint32_t hash_Ip6OutMcastPkts = -1;
44 -
45 - static uint32_t hash_Ip6InOctets = -1;
46 - static uint32_t hash_Ip6OutOctets = -1;
47 -
48 - static uint32_t hash_Ip6InMcastOctets = -1;
49 - static uint32_t hash_Ip6OutMcastOctets = -1;
50 - static uint32_t hash_Ip6InBcastOctets = -1;
51 - static uint32_t hash_Ip6OutBcastOctets = -1;
52 -
53 - static uint32_t hash_Ip6InNoECTPkts = -1;
54 - static uint32_t hash_Ip6InECT1Pkts = -1;
55 - static uint32_t hash_Ip6InECT0Pkts = -1;
56 - static uint32_t hash_Ip6InCEPkts = -1;
57 -
58 - static uint32_t hash_Icmp6InMsgs = -1;
59 - static uint32_t hash_Icmp6InErrors = -1;
60 - static uint32_t hash_Icmp6OutMsgs = -1;
61 - static uint32_t hash_Icmp6OutErrors = -1;
62 - static uint32_t hash_Icmp6InCsumErrors = -1;
63 - static uint32_t hash_Icmp6InDestUnreachs = -1;
64 - static uint32_t hash_Icmp6InPktTooBigs = -1;
65 - static uint32_t hash_Icmp6InTimeExcds = -1;
66 - static uint32_t hash_Icmp6InParmProblems = -1;
67 - static uint32_t hash_Icmp6InEchos = -1;
68 - static uint32_t hash_Icmp6InEchoReplies = -1;
69 - static uint32_t hash_Icmp6InGroupMembQueries = -1;
70 - static uint32_t hash_Icmp6InGroupMembResponses = -1;
71 - static uint32_t hash_Icmp6InGroupMembReductions = -1;
72 - static uint32_t hash_Icmp6InRouterSolicits = -1;
73 - static uint32_t hash_Icmp6InRouterAdvertisements = -1;
74 - static uint32_t hash_Icmp6InNeighborSolicits = -1;
75 - static uint32_t hash_Icmp6InNeighborAdvertisements = -1;
76 - static uint32_t hash_Icmp6InRedirects = -1;
77 - static uint32_t hash_Icmp6InMLDv2Reports = -1;
78 - static uint32_t hash_Icmp6OutDestUnreachs = -1;
79 - static uint32_t hash_Icmp6OutPktTooBigs = -1;
80 - static uint32_t hash_Icmp6OutTimeExcds = -1;
81 - static uint32_t hash_Icmp6OutParmProblems = -1;
82 - static uint32_t hash_Icmp6OutEchos = -1;
83 - static uint32_t hash_Icmp6OutEchoReplies = -1;
84 - static uint32_t hash_Icmp6OutGroupMembQueries = -1;
85 - static uint32_t hash_Icmp6OutGroupMembResponses = -1;
86 - static uint32_t hash_Icmp6OutGroupMembReductions = -1;
87 - static uint32_t hash_Icmp6OutRouterSolicits = -1;
88 - static uint32_t hash_Icmp6OutRouterAdvertisements = -1;
89 - static uint32_t hash_Icmp6OutNeighborSolicits = -1;
90 - static uint32_t hash_Icmp6OutNeighborAdvertisements = -1;
91 - static uint32_t hash_Icmp6OutRedirects = -1;
92 - static uint32_t hash_Icmp6OutMLDv2Reports = -1;
93 - static uint32_t hash_Icmp6InType1 = -1;
94 - static uint32_t hash_Icmp6InType128 = -1;
95 - static uint32_t hash_Icmp6InType129 = -1;
96 - static uint32_t hash_Icmp6InType136 = -1;
97 - static uint32_t hash_Icmp6OutType1 = -1;
98 - static uint32_t hash_Icmp6OutType128 = -1;
99 - static uint32_t hash_Icmp6OutType129 = -1;
100 - static uint32_t hash_Icmp6OutType133 = -1;
101 - static uint32_t hash_Icmp6OutType135 = -1;
102 - static uint32_t hash_Icmp6OutType143 = -1;
103 -
104 - static uint32_t hash_Udp6InDatagrams = -1;
105 - static uint32_t hash_Udp6NoPorts = -1;
106 - static uint32_t hash_Udp6InErrors = -1;
107 - static uint32_t hash_Udp6OutDatagrams = -1;
108 - static uint32_t hash_Udp6RcvbufErrors = -1;
109 - static uint32_t hash_Udp6SndbufErrors = -1;
110 - static uint32_t hash_Udp6InCsumErrors = -1;
111 - static uint32_t hash_Udp6IgnoredMulti = -1;
112 -
113 - static uint32_t hash_UdpLite6InDatagrams = -1;
114 - static uint32_t hash_UdpLite6NoPorts = -1;
115 - static uint32_t hash_UdpLite6InErrors = -1;
116 - static uint32_t hash_UdpLite6OutDatagrams = -1;
117 - static uint32_t hash_UdpLite6RcvbufErrors = -1;
118 - static uint32_t hash_UdpLite6SndbufErrors = -1;
119 - static uint32_t hash_UdpLite6InCsumErrors = -1;
120 -
121 - if(gen_hashes != 1) {
122 - gen_hashes = 1;
19 + static uint32_t hash_Ip6InReceives = 0;
20 +
21 + static uint32_t hash_Ip6InHdrErrors = 0;
22 + static uint32_t hash_Ip6InTooBigErrors = 0;
23 + static uint32_t hash_Ip6InNoRoutes = 0;
24 + static uint32_t hash_Ip6InAddrErrors = 0;
25 + static uint32_t hash_Ip6InUnknownProtos = 0;
26 + static uint32_t hash_Ip6InTruncatedPkts = 0;
27 + static uint32_t hash_Ip6InDiscards = 0;
28 + static uint32_t hash_Ip6InDelivers = 0;
29 +
30 + static uint32_t hash_Ip6OutForwDatagrams = 0;
31 + static uint32_t hash_Ip6OutRequests = 0;
32 + static uint32_t hash_Ip6OutDiscards = 0;
33 + static uint32_t hash_Ip6OutNoRoutes = 0;
34 +
35 + static uint32_t hash_Ip6ReasmTimeout = 0;
36 + static uint32_t hash_Ip6ReasmReqds = 0;
37 + static uint32_t hash_Ip6ReasmOKs = 0;
38 + static uint32_t hash_Ip6ReasmFails = 0;
39 +
40 + static uint32_t hash_Ip6FragOKs = 0;
41 + static uint32_t hash_Ip6FragFails = 0;
42 + static uint32_t hash_Ip6FragCreates = 0;
43 +
44 + static uint32_t hash_Ip6InMcastPkts = 0;
45 + static uint32_t hash_Ip6OutMcastPkts = 0;
46 +
47 + static uint32_t hash_Ip6InOctets = 0;
48 + static uint32_t hash_Ip6OutOctets = 0;
49 +
50 + static uint32_t hash_Ip6InMcastOctets = 0;
51 + static uint32_t hash_Ip6OutMcastOctets = 0;
52 + static uint32_t hash_Ip6InBcastOctets = 0;
53 + static uint32_t hash_Ip6OutBcastOctets = 0;
54 +
55 + static uint32_t hash_Ip6InNoECTPkts = 0;
56 + static uint32_t hash_Ip6InECT1Pkts = 0;
57 + static uint32_t hash_Ip6InECT0Pkts = 0;
58 + static uint32_t hash_Ip6InCEPkts = 0;
59 +
60 + static uint32_t hash_Icmp6InMsgs = 0;
61 + static uint32_t hash_Icmp6InErrors = 0;
62 + static uint32_t hash_Icmp6OutMsgs = 0;
63 + static uint32_t hash_Icmp6OutErrors = 0;
64 + static uint32_t hash_Icmp6InCsumErrors = 0;
65 + static uint32_t hash_Icmp6InDestUnreachs = 0;
66 + static uint32_t hash_Icmp6InPktTooBigs = 0;
67 + static uint32_t hash_Icmp6InTimeExcds = 0;
68 + static uint32_t hash_Icmp6InParmProblems = 0;
69 + static uint32_t hash_Icmp6InEchos = 0;
70 + static uint32_t hash_Icmp6InEchoReplies = 0;
71 + static uint32_t hash_Icmp6InGroupMembQueries = 0;
72 + static uint32_t hash_Icmp6InGroupMembResponses = 0;
73 + static uint32_t hash_Icmp6InGroupMembReductions = 0;
74 + static uint32_t hash_Icmp6InRouterSolicits = 0;
75 + static uint32_t hash_Icmp6InRouterAdvertisements = 0;
76 + static uint32_t hash_Icmp6InNeighborSolicits = 0;
77 + static uint32_t hash_Icmp6InNeighborAdvertisements = 0;
78 + static uint32_t hash_Icmp6InRedirects = 0;
79 + static uint32_t hash_Icmp6InMLDv2Reports = 0;
80 + static uint32_t hash_Icmp6OutDestUnreachs = 0;
81 + static uint32_t hash_Icmp6OutPktTooBigs = 0;
82 + static uint32_t hash_Icmp6OutTimeExcds = 0;
83 + static uint32_t hash_Icmp6OutParmProblems = 0;
84 + static uint32_t hash_Icmp6OutEchos = 0;
85 + static uint32_t hash_Icmp6OutEchoReplies = 0;
86 + static uint32_t hash_Icmp6OutGroupMembQueries = 0;
87 + static uint32_t hash_Icmp6OutGroupMembResponses = 0;
88 + static uint32_t hash_Icmp6OutGroupMembReductions = 0;
89 + static uint32_t hash_Icmp6OutRouterSolicits = 0;
90 + static uint32_t hash_Icmp6OutRouterAdvertisements = 0;
91 + static uint32_t hash_Icmp6OutNeighborSolicits = 0;
92 + static uint32_t hash_Icmp6OutNeighborAdvertisements = 0;
93 + static uint32_t hash_Icmp6OutRedirects = 0;
94 + static uint32_t hash_Icmp6OutMLDv2Reports = 0;
95 + static uint32_t hash_Icmp6InType1 = 0;
96 + static uint32_t hash_Icmp6InType128 = 0;
97 + static uint32_t hash_Icmp6InType129 = 0;
98 + static uint32_t hash_Icmp6InType136 = 0;
99 + static uint32_t hash_Icmp6OutType1 = 0;
100 + static uint32_t hash_Icmp6OutType128 = 0;
101 + static uint32_t hash_Icmp6OutType129 = 0;
102 + static uint32_t hash_Icmp6OutType133 = 0;
103 + static uint32_t hash_Icmp6OutType135 = 0;
104 + static uint32_t hash_Icmp6OutType143 = 0;
105 +
106 + static uint32_t hash_Udp6InDatagrams = 0;
107 + static uint32_t hash_Udp6NoPorts = 0;
108 + static uint32_t hash_Udp6InErrors = 0;
109 + static uint32_t hash_Udp6OutDatagrams = 0;
110 + static uint32_t hash_Udp6RcvbufErrors = 0;
111 + static uint32_t hash_Udp6SndbufErrors = 0;
112 + static uint32_t hash_Udp6InCsumErrors = 0;
113 + static uint32_t hash_Udp6IgnoredMulti = 0;
114 +
115 + static uint32_t hash_UdpLite6InDatagrams = 0;
116 + static uint32_t hash_UdpLite6NoPorts = 0;
117 + static uint32_t hash_UdpLite6InErrors = 0;
118 + static uint32_t hash_UdpLite6OutDatagrams = 0;
119 + static uint32_t hash_UdpLite6RcvbufErrors = 0;
120 + static uint32_t hash_UdpLite6SndbufErrors = 0;
121 + static uint32_t hash_UdpLite6InCsumErrors = 0;
122 +
123 + if(unlikely(!initialized)) {
124 + initialized = 1;
125 +
126 hash_Ip6InReceives = simple_hash("Ip6InReceives");
127 hash_Ip6InHdrErrors = simple_hash("Ip6InHdrErrors");
128 hash_Ip6InTooBigErrors = simple_hash("Ip6InTooBigErrors");
@@ -212,42 +215,42 @@ int do_proc_net_snmp6(int update_every, unsigned long long dt) {
215 hash_UdpLite6RcvbufErrors = simple_hash("UdpLite6RcvbufErrors");
216 hash_UdpLite6SndbufErrors = simple_hash("UdpLite6SndbufErrors");
217 hash_UdpLite6InCsumErrors = simple_hash("UdpLite6InCsumErrors");
218 +
219 + do_ip_packets = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "ipv6 packets", CONFIG_ONDEMAND_ONDEMAND);
220 + do_ip_fragsout = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "ipv6 fragments sent", CONFIG_ONDEMAND_ONDEMAND);
221 + do_ip_fragsin = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "ipv6 fragments assembly", CONFIG_ONDEMAND_ONDEMAND);
222 + do_ip_errors = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "ipv6 errors", CONFIG_ONDEMAND_ONDEMAND);
223 + do_udp_packets = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "ipv6 UDP packets", CONFIG_ONDEMAND_ONDEMAND);
224 + do_udp_errors = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "ipv6 UDP errors", CONFIG_ONDEMAND_ONDEMAND);
225 + do_udplite_packets = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "ipv6 UDPlite packets", CONFIG_ONDEMAND_ONDEMAND);
226 + do_udplite_errors = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "ipv6 UDPlite errors", CONFIG_ONDEMAND_ONDEMAND);
227 + do_bandwidth = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "bandwidth", CONFIG_ONDEMAND_ONDEMAND);
228 + do_mcast = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "multicast bandwidth", CONFIG_ONDEMAND_ONDEMAND);
229 + do_bcast = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "broadcast bandwidth", CONFIG_ONDEMAND_ONDEMAND);
230 + do_mcast_p = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "multicast packets", CONFIG_ONDEMAND_ONDEMAND);
231 + do_icmp = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "icmp", CONFIG_ONDEMAND_ONDEMAND);
232 + do_icmp_redir = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "icmp redirects", CONFIG_ONDEMAND_ONDEMAND);
233 + do_icmp_errors = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "icmp errors", CONFIG_ONDEMAND_ONDEMAND);
234 + do_icmp_echos = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "icmp echos", CONFIG_ONDEMAND_ONDEMAND);
235 + do_icmp_groupmemb = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "icmp group membership", CONFIG_ONDEMAND_ONDEMAND);
236 + do_icmp_router = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "icmp router", CONFIG_ONDEMAND_ONDEMAND);
237 + do_icmp_neighbor = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "icmp neighbor", CONFIG_ONDEMAND_ONDEMAND);
238 + do_icmp_mldv2 = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "icmp mldv2", CONFIG_ONDEMAND_ONDEMAND);
239 + do_icmp_types = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "icmp types", CONFIG_ONDEMAND_ONDEMAND);
240 + do_ect = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "ect", CONFIG_ONDEMAND_ONDEMAND);
241 }
242
217 - if(do_ip_packets == -1) do_ip_packets = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "ipv6 packets", CONFIG_ONDEMAND_ONDEMAND);
218 - if(do_ip_fragsout == -1) do_ip_fragsout = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "ipv6 fragments sent", CONFIG_ONDEMAND_ONDEMAND);
219 - if(do_ip_fragsin == -1) do_ip_fragsin = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "ipv6 fragments assembly", CONFIG_ONDEMAND_ONDEMAND);
220 - if(do_ip_errors == -1) do_ip_errors = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "ipv6 errors", CONFIG_ONDEMAND_ONDEMAND);
221 - if(do_udp_packets == -1) do_udp_packets = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "ipv6 UDP packets", CONFIG_ONDEMAND_ONDEMAND);
222 - if(do_udp_errors == -1) do_udp_errors = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "ipv6 UDP errors", CONFIG_ONDEMAND_ONDEMAND);
223 - if(do_udplite_packets == -1) do_udplite_packets = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "ipv6 UDPlite packets", CONFIG_ONDEMAND_ONDEMAND);
224 - if(do_udplite_errors == -1) do_udplite_errors = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "ipv6 UDPlite errors", CONFIG_ONDEMAND_ONDEMAND);
225 - if(do_bandwidth == -1) do_bandwidth = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "bandwidth", CONFIG_ONDEMAND_ONDEMAND);
226 - if(do_mcast == -1) do_mcast = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "multicast bandwidth", CONFIG_ONDEMAND_ONDEMAND);
227 - if(do_bcast == -1) do_bcast = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "broadcast bandwidth", CONFIG_ONDEMAND_ONDEMAND);
228 - if(do_mcast_p == -1) do_mcast_p = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "multicast packets", CONFIG_ONDEMAND_ONDEMAND);
229 - if(do_icmp == -1) do_icmp = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "icmp", CONFIG_ONDEMAND_ONDEMAND);
230 - if(do_icmp_redir == -1) do_icmp_redir = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "icmp redirects", CONFIG_ONDEMAND_ONDEMAND);
231 - if(do_icmp_errors == -1) do_icmp_errors = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "icmp errors", CONFIG_ONDEMAND_ONDEMAND);
232 - if(do_icmp_echos == -1) do_icmp_echos = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "icmp echos", CONFIG_ONDEMAND_ONDEMAND);
233 - if(do_icmp_groupmemb == -1) do_icmp_groupmemb = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "icmp group membership", CONFIG_ONDEMAND_ONDEMAND);
234 - if(do_icmp_router == -1) do_icmp_router = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "icmp router", CONFIG_ONDEMAND_ONDEMAND);
235 - if(do_icmp_neighbor == -1) do_icmp_neighbor = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "icmp neighbor", CONFIG_ONDEMAND_ONDEMAND);
236 - if(do_icmp_mldv2 == -1) do_icmp_mldv2 = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "icmp mldv2", CONFIG_ONDEMAND_ONDEMAND);
237 - if(do_icmp_types == -1) do_icmp_types = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "icmp types", CONFIG_ONDEMAND_ONDEMAND);
238 - if(do_ect == -1) do_ect = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "ect", CONFIG_ONDEMAND_ONDEMAND);
239 -
240 - if(dt) {};
241 -
242 - if(!ff) {
243 + if(unlikely(!ff)) {
244 char filename[FILENAME_MAX + 1];
245 snprintfz(filename, FILENAME_MAX, "%s%s", global_host_prefix, "/proc/net/snmp6");
246 ff = procfile_open(config_get("plugin:proc:/proc/net/snmp6", "filename to monitor", filename), " \t:", PROCFILE_FLAG_DEFAULT);
247 + if(unlikely(!ff))
248 + return 1;
249 }
247 - if(!ff) return 1;
250
251 ff = procfile_readall(ff);
250 - if(!ff) return 0; // we return 0, so that we will retry to open it next time
252 + if(unlikely(!ff))
253 + return 0; // we return 0, so that we will retry to open it next time
254
255 uint32_t lines = procfile_lines(ff), l;
256 uint32_t words;
@@ -347,110 +350,110 @@ int do_proc_net_snmp6(int update_every, unsigned long long dt) {
350
351 for(l = 0; l < lines ;l++) {
352 words = procfile_linewords(ff, l);
350 - if(words < 2) {
351 - if(words) error("Cannot read /proc/net/snmp6 line %u. Expected 2 params, read %u.", l, words);
353 + if(unlikely(words < 2)) {
354 + if(unlikely(words)) error("Cannot read /proc/net/snmp6 line %u. Expected 2 params, read %u.", l, words);
355 continue;
356 }
357
358 char *name = procfile_lineword(ff, l, 0);
359 char * value = procfile_lineword(ff, l, 1);
357 - if(!name || !*name || !value || !*value) continue;
360 + if(unlikely(!name || !*name || !value || !*value))
361 + continue;
362
363 uint32_t hash = simple_hash(name);
364
361 - if(0) ;
362 - else if(hash == hash_Ip6InReceives && strcmp(name, "Ip6InReceives") == 0) Ip6InReceives = strtoull(value, NULL, 10);
363 - else if(hash == hash_Ip6InHdrErrors && strcmp(name, "Ip6InHdrErrors") == 0) Ip6InHdrErrors = strtoull(value, NULL, 10);
364 - else if(hash == hash_Ip6InTooBigErrors && strcmp(name, "Ip6InTooBigErrors") == 0) Ip6InTooBigErrors = strtoull(value, NULL, 10);
365 - else if(hash == hash_Ip6InNoRoutes && strcmp(name, "Ip6InNoRoutes") == 0) Ip6InNoRoutes = strtoull(value, NULL, 10);
366 - else if(hash == hash_Ip6InAddrErrors && strcmp(name, "Ip6InAddrErrors") == 0) Ip6InAddrErrors = strtoull(value, NULL, 10);
367 - else if(hash == hash_Ip6InUnknownProtos && strcmp(name, "Ip6InUnknownProtos") == 0) Ip6InUnknownProtos = strtoull(value, NULL, 10);
368 - else if(hash == hash_Ip6InTruncatedPkts && strcmp(name, "Ip6InTruncatedPkts") == 0) Ip6InTruncatedPkts = strtoull(value, NULL, 10);
369 - else if(hash == hash_Ip6InDiscards && strcmp(name, "Ip6InDiscards") == 0) Ip6InDiscards = strtoull(value, NULL, 10);
370 - else if(hash == hash_Ip6InDelivers && strcmp(name, "Ip6InDelivers") == 0) Ip6InDelivers = strtoull(value, NULL, 10);
371 - else if(hash == hash_Ip6OutForwDatagrams && strcmp(name, "Ip6OutForwDatagrams") == 0) Ip6OutForwDatagrams = strtoull(value, NULL, 10);
372 - else if(hash == hash_Ip6OutRequests && strcmp(name, "Ip6OutRequests") == 0) Ip6OutRequests = strtoull(value, NULL, 10);
373 - else if(hash == hash_Ip6OutDiscards && strcmp(name, "Ip6OutDiscards") == 0) Ip6OutDiscards = strtoull(value, NULL, 10);
374 - else if(hash == hash_Ip6OutNoRoutes && strcmp(name, "Ip6OutNoRoutes") == 0) Ip6OutNoRoutes = strtoull(value, NULL, 10);
375 - else if(hash == hash_Ip6ReasmTimeout && strcmp(name, "Ip6ReasmTimeout") == 0) Ip6ReasmTimeout = strtoull(value, NULL, 10);
376 - else if(hash == hash_Ip6ReasmReqds && strcmp(name, "Ip6ReasmReqds") == 0) Ip6ReasmReqds = strtoull(value, NULL, 10);
377 - else if(hash == hash_Ip6ReasmOKs && strcmp(name, "Ip6ReasmOKs") == 0) Ip6ReasmOKs = strtoull(value, NULL, 10);
378 - else if(hash == hash_Ip6ReasmFails && strcmp(name, "Ip6ReasmFails") == 0) Ip6ReasmFails = strtoull(value, NULL, 10);
379 - else if(hash == hash_Ip6FragOKs && strcmp(name, "Ip6FragOKs") == 0) Ip6FragOKs = strtoull(value, NULL, 10);
380 - else if(hash == hash_Ip6FragFails && strcmp(name, "Ip6FragFails") == 0) Ip6FragFails = strtoull(value, NULL, 10);
381 - else if(hash == hash_Ip6FragCreates && strcmp(name, "Ip6FragCreates") == 0) Ip6FragCreates = strtoull(value, NULL, 10);
382 - else if(hash == hash_Ip6InMcastPkts && strcmp(name, "Ip6InMcastPkts") == 0) Ip6InMcastPkts = strtoull(value, NULL, 10);
383 - else if(hash == hash_Ip6OutMcastPkts && strcmp(name, "Ip6OutMcastPkts") == 0) Ip6OutMcastPkts = strtoull(value, NULL, 10);
384 - else if(hash == hash_Ip6InOctets && strcmp(name, "Ip6InOctets") == 0) Ip6InOctets = strtoull(value, NULL, 10);
385 - else if(hash == hash_Ip6OutOctets && strcmp(name, "Ip6OutOctets") == 0) Ip6OutOctets = strtoull(value, NULL, 10);
386 - else if(hash == hash_Ip6InMcastOctets && strcmp(name, "Ip6InMcastOctets") == 0) Ip6InMcastOctets = strtoull(value, NULL, 10);
387 - else if(hash == hash_Ip6OutMcastOctets && strcmp(name, "Ip6OutMcastOctets") == 0) Ip6OutMcastOctets = strtoull(value, NULL, 10);
388 - else if(hash == hash_Ip6InBcastOctets && strcmp(name, "Ip6InBcastOctets") == 0) Ip6InBcastOctets = strtoull(value, NULL, 10);
389 - else if(hash == hash_Ip6OutBcastOctets && strcmp(name, "Ip6OutBcastOctets") == 0) Ip6OutBcastOctets = strtoull(value, NULL, 10);
390 - else if(hash == hash_Ip6InNoECTPkts && strcmp(name, "Ip6InNoECTPkts") == 0) Ip6InNoECTPkts = strtoull(value, NULL, 10);
391 - else if(hash == hash_Ip6InECT1Pkts && strcmp(name, "Ip6InECT1Pkts") == 0) Ip6InECT1Pkts = strtoull(value, NULL, 10);
392 - else if(hash == hash_Ip6InECT0Pkts && strcmp(name, "Ip6InECT0Pkts") == 0) Ip6InECT0Pkts = strtoull(value, NULL, 10);
393 - else if(hash == hash_Ip6InCEPkts && strcmp(name, "Ip6InCEPkts") == 0) Ip6InCEPkts = strtoull(value, NULL, 10);
394 - else if(hash == hash_Icmp6InMsgs && strcmp(name, "Icmp6InMsgs") == 0) Icmp6InMsgs = strtoull(value, NULL, 10);
395 - else if(hash == hash_Icmp6InErrors && strcmp(name, "Icmp6InErrors") == 0) Icmp6InErrors = strtoull(value, NULL, 10);
396 - else if(hash == hash_Icmp6OutMsgs && strcmp(name, "Icmp6OutMsgs") == 0) Icmp6OutMsgs = strtoull(value, NULL, 10);
397 - else if(hash == hash_Icmp6OutErrors && strcmp(name, "Icmp6OutErrors") == 0) Icmp6OutErrors = strtoull(value, NULL, 10);
398 - else if(hash == hash_Icmp6InCsumErrors && strcmp(name, "Icmp6InCsumErrors") == 0) Icmp6InCsumErrors = strtoull(value, NULL, 10);
399 - else if(hash == hash_Icmp6InDestUnreachs && strcmp(name, "Icmp6InDestUnreachs") == 0) Icmp6InDestUnreachs = strtoull(value, NULL, 10);
400 - else if(hash == hash_Icmp6InPktTooBigs && strcmp(name, "Icmp6InPktTooBigs") == 0) Icmp6InPktTooBigs = strtoull(value, NULL, 10);
401 - else if(hash == hash_Icmp6InTimeExcds && strcmp(name, "Icmp6InTimeExcds") == 0) Icmp6InTimeExcds = strtoull(value, NULL, 10);
402 - else if(hash == hash_Icmp6InParmProblems && strcmp(name, "Icmp6InParmProblems") == 0) Icmp6InParmProblems = strtoull(value, NULL, 10);
403 - else if(hash == hash_Icmp6InEchos && strcmp(name, "Icmp6InEchos") == 0) Icmp6InEchos = strtoull(value, NULL, 10);
404 - else if(hash == hash_Icmp6InEchoReplies && strcmp(name, "Icmp6InEchoReplies") == 0) Icmp6InEchoReplies = strtoull(value, NULL, 10);
405 - else if(hash == hash_Icmp6InGroupMembQueries && strcmp(name, "Icmp6InGroupMembQueries") == 0) Icmp6InGroupMembQueries = strtoull(value, NULL, 10);
406 - else if(hash == hash_Icmp6InGroupMembResponses && strcmp(name, "Icmp6InGroupMembResponses") == 0) Icmp6InGroupMembResponses = strtoull(value, NULL, 10);
407 - else if(hash == hash_Icmp6InGroupMembReductions && strcmp(name, "Icmp6InGroupMembReductions") == 0) Icmp6InGroupMembReductions = strtoull(value, NULL, 10);
408 - else if(hash == hash_Icmp6InRouterSolicits && strcmp(name, "Icmp6InRouterSolicits") == 0) Icmp6InRouterSolicits = strtoull(value, NULL, 10);
409 - else if(hash == hash_Icmp6InRouterAdvertisements && strcmp(name, "Icmp6InRouterAdvertisements") == 0) Icmp6InRouterAdvertisements = strtoull(value, NULL, 10);
410 - else if(hash == hash_Icmp6InNeighborSolicits && strcmp(name, "Icmp6InNeighborSolicits") == 0) Icmp6InNeighborSolicits = strtoull(value, NULL, 10);
411 - else if(hash == hash_Icmp6InNeighborAdvertisements && strcmp(name, "Icmp6InNeighborAdvertisements") == 0) Icmp6InNeighborAdvertisements = strtoull(value, NULL, 10);
412 - else if(hash == hash_Icmp6InRedirects && strcmp(name, "Icmp6InRedirects") == 0) Icmp6InRedirects = strtoull(value, NULL, 10);
413 - else if(hash == hash_Icmp6InMLDv2Reports && strcmp(name, "Icmp6InMLDv2Reports") == 0) Icmp6InMLDv2Reports = strtoull(value, NULL, 10);
414 - else if(hash == hash_Icmp6OutDestUnreachs && strcmp(name, "Icmp6OutDestUnreachs") == 0) Icmp6OutDestUnreachs = strtoull(value, NULL, 10);
415 - else if(hash == hash_Icmp6OutPktTooBigs && strcmp(name, "Icmp6OutPktTooBigs") == 0) Icmp6OutPktTooBigs = strtoull(value, NULL, 10);
416 - else if(hash == hash_Icmp6OutTimeExcds && strcmp(name, "Icmp6OutTimeExcds") == 0) Icmp6OutTimeExcds = strtoull(value, NULL, 10);
417 - else if(hash == hash_Icmp6OutParmProblems && strcmp(name, "Icmp6OutParmProblems") == 0) Icmp6OutParmProblems = strtoull(value, NULL, 10);
418 - else if(hash == hash_Icmp6OutEchos && strcmp(name, "Icmp6OutEchos") == 0) Icmp6OutEchos = strtoull(value, NULL, 10);
419 - else if(hash == hash_Icmp6OutEchoReplies && strcmp(name, "Icmp6OutEchoReplies") == 0) Icmp6OutEchoReplies = strtoull(value, NULL, 10);
420 - else if(hash == hash_Icmp6OutGroupMembQueries && strcmp(name, "Icmp6OutGroupMembQueries") == 0) Icmp6OutGroupMembQueries = strtoull(value, NULL, 10);
421 - else if(hash == hash_Icmp6OutGroupMembResponses && strcmp(name, "Icmp6OutGroupMembResponses") == 0) Icmp6OutGroupMembResponses = strtoull(value, NULL, 10);
422 - else if(hash == hash_Icmp6OutGroupMembReductions && strcmp(name, "Icmp6OutGroupMembReductions") == 0) Icmp6OutGroupMembReductions = strtoull(value, NULL, 10);
423 - else if(hash == hash_Icmp6OutRouterSolicits && strcmp(name, "Icmp6OutRouterSolicits") == 0) Icmp6OutRouterSolicits = strtoull(value, NULL, 10);
424 - else if(hash == hash_Icmp6OutRouterAdvertisements && strcmp(name, "Icmp6OutRouterAdvertisements") == 0) Icmp6OutRouterAdvertisements = strtoull(value, NULL, 10);
425 - else if(hash == hash_Icmp6OutNeighborSolicits && strcmp(name, "Icmp6OutNeighborSolicits") == 0) Icmp6OutNeighborSolicits = strtoull(value, NULL, 10);
426 - else if(hash == hash_Icmp6OutNeighborAdvertisements && strcmp(name, "Icmp6OutNeighborAdvertisements") == 0) Icmp6OutNeighborAdvertisements = strtoull(value, NULL, 10);
427 - else if(hash == hash_Icmp6OutRedirects && strcmp(name, "Icmp6OutRedirects") == 0) Icmp6OutRedirects = strtoull(value, NULL, 10);
428 - else if(hash == hash_Icmp6OutMLDv2Reports && strcmp(name, "Icmp6OutMLDv2Reports") == 0) Icmp6OutMLDv2Reports = strtoull(value, NULL, 10);
429 - else if(hash == hash_Icmp6InType1 && strcmp(name, "Icmp6InType1") == 0) Icmp6InType1 = strtoull(value, NULL, 10);
430 - else if(hash == hash_Icmp6InType128 && strcmp(name, "Icmp6InType128") == 0) Icmp6InType128 = strtoull(value, NULL, 10);
431 - else if(hash == hash_Icmp6InType129 && strcmp(name, "Icmp6InType129") == 0) Icmp6InType129 = strtoull(value, NULL, 10);
432 - else if(hash == hash_Icmp6InType136 && strcmp(name, "Icmp6InType136") == 0) Icmp6InType136 = strtoull(value, NULL, 10);
433 - else if(hash == hash_Icmp6OutType1 && strcmp(name, "Icmp6OutType1") == 0) Icmp6OutType1 = strtoull(value, NULL, 10);
434 - else if(hash == hash_Icmp6OutType128 && strcmp(name, "Icmp6OutType128") == 0) Icmp6OutType128 = strtoull(value, NULL, 10);
435 - else if(hash == hash_Icmp6OutType129 && strcmp(name, "Icmp6OutType129") == 0) Icmp6OutType129 = strtoull(value, NULL, 10);
436 - else if(hash == hash_Icmp6OutType133 && strcmp(name, "Icmp6OutType133") == 0) Icmp6OutType133 = strtoull(value, NULL, 10);
437 - else if(hash == hash_Icmp6OutType135 && strcmp(name, "Icmp6OutType135") == 0) Icmp6OutType135 = strtoull(value, NULL, 10);
438 - else if(hash == hash_Icmp6OutType143 && strcmp(name, "Icmp6OutType143") == 0) Icmp6OutType143 = strtoull(value, NULL, 10);
439 - else if(hash == hash_Udp6InDatagrams && strcmp(name, "Udp6InDatagrams") == 0) Udp6InDatagrams = strtoull(value, NULL, 10);
440 - else if(hash == hash_Udp6NoPorts && strcmp(name, "Udp6NoPorts") == 0) Udp6NoPorts = strtoull(value, NULL, 10);
441 - else if(hash == hash_Udp6InErrors && strcmp(name, "Udp6InErrors") == 0) Udp6InErrors = strtoull(value, NULL, 10);
442 - else if(hash == hash_Udp6OutDatagrams && strcmp(name, "Udp6OutDatagrams") == 0) Udp6OutDatagrams = strtoull(value, NULL, 10);
443 - else if(hash == hash_Udp6RcvbufErrors && strcmp(name, "Udp6RcvbufErrors") == 0) Udp6RcvbufErrors = strtoull(value, NULL, 10);
444 - else if(hash == hash_Udp6SndbufErrors && strcmp(name, "Udp6SndbufErrors") == 0) Udp6SndbufErrors = strtoull(value, NULL, 10);
445 - else if(hash == hash_Udp6InCsumErrors && strcmp(name, "Udp6InCsumErrors") == 0) Udp6InCsumErrors = strtoull(value, NULL, 10);
446 - else if(hash == hash_Udp6IgnoredMulti && strcmp(name, "Udp6IgnoredMulti") == 0) Udp6IgnoredMulti = strtoull(value, NULL, 10);
447 - else if(hash == hash_UdpLite6InDatagrams && strcmp(name, "UdpLite6InDatagrams") == 0) UdpLite6InDatagrams = strtoull(value, NULL, 10);
448 - else if(hash == hash_UdpLite6NoPorts && strcmp(name, "UdpLite6NoPorts") == 0) UdpLite6NoPorts = strtoull(value, NULL, 10);
449 - else if(hash == hash_UdpLite6InErrors && strcmp(name, "UdpLite6InErrors") == 0) UdpLite6InErrors = strtoull(value, NULL, 10);
450 - else if(hash == hash_UdpLite6OutDatagrams && strcmp(name, "UdpLite6OutDatagrams") == 0) UdpLite6OutDatagrams = strtoull(value, NULL, 10);
451 - else if(hash == hash_UdpLite6RcvbufErrors && strcmp(name, "UdpLite6RcvbufErrors") == 0) UdpLite6RcvbufErrors = strtoull(value, NULL, 10);
452 - else if(hash == hash_UdpLite6SndbufErrors && strcmp(name, "UdpLite6SndbufErrors") == 0) UdpLite6SndbufErrors = strtoull(value, NULL, 10);
453 - else if(hash == hash_UdpLite6InCsumErrors && strcmp(name, "UdpLite6InCsumErrors") == 0) UdpLite6InCsumErrors = strtoull(value, NULL, 10);
365 + if(unlikely(hash == hash_Ip6InReceives && strcmp(name, "Ip6InReceives") == 0)) Ip6InReceives = strtoull(value, NULL, 10);
366 + else if(unlikely(hash == hash_Ip6InHdrErrors && strcmp(name, "Ip6InHdrErrors") == 0)) Ip6InHdrErrors = strtoull(value, NULL, 10);
367 + else if(unlikely(hash == hash_Ip6InTooBigErrors && strcmp(name, "Ip6InTooBigErrors") == 0)) Ip6InTooBigErrors = strtoull(value, NULL, 10);
368 + else if(unlikely(hash == hash_Ip6InNoRoutes && strcmp(name, "Ip6InNoRoutes") == 0)) Ip6InNoRoutes = strtoull(value, NULL, 10);
369 + else if(unlikely(hash == hash_Ip6InAddrErrors && strcmp(name, "Ip6InAddrErrors") == 0)) Ip6InAddrErrors = strtoull(value, NULL, 10);
370 + else if(unlikely(hash == hash_Ip6InUnknownProtos && strcmp(name, "Ip6InUnknownProtos") == 0)) Ip6InUnknownProtos = strtoull(value, NULL, 10);
371 + else if(unlikely(hash == hash_Ip6InTruncatedPkts && strcmp(name, "Ip6InTruncatedPkts") == 0)) Ip6InTruncatedPkts = strtoull(value, NULL, 10);
372 + else if(unlikely(hash == hash_Ip6InDiscards && strcmp(name, "Ip6InDiscards") == 0)) Ip6InDiscards = strtoull(value, NULL, 10);
373 + else if(unlikely(hash == hash_Ip6InDelivers && strcmp(name, "Ip6InDelivers") == 0)) Ip6InDelivers = strtoull(value, NULL, 10);
374 + else if(unlikely(hash == hash_Ip6OutForwDatagrams && strcmp(name, "Ip6OutForwDatagrams") == 0)) Ip6OutForwDatagrams = strtoull(value, NULL, 10);
375 + else if(unlikely(hash == hash_Ip6OutRequests && strcmp(name, "Ip6OutRequests") == 0)) Ip6OutRequests = strtoull(value, NULL, 10);
376 + else if(unlikely(hash == hash_Ip6OutDiscards && strcmp(name, "Ip6OutDiscards") == 0)) Ip6OutDiscards = strtoull(value, NULL, 10);
377 + else if(unlikely(hash == hash_Ip6OutNoRoutes && strcmp(name, "Ip6OutNoRoutes") == 0)) Ip6OutNoRoutes = strtoull(value, NULL, 10);
378 + else if(unlikely(hash == hash_Ip6ReasmTimeout && strcmp(name, "Ip6ReasmTimeout") == 0)) Ip6ReasmTimeout = strtoull(value, NULL, 10);
379 + else if(unlikely(hash == hash_Ip6ReasmReqds && strcmp(name, "Ip6ReasmReqds") == 0)) Ip6ReasmReqds = strtoull(value, NULL, 10);
380 + else if(unlikely(hash == hash_Ip6ReasmOKs && strcmp(name, "Ip6ReasmOKs") == 0)) Ip6ReasmOKs = strtoull(value, NULL, 10);
381 + else if(unlikely(hash == hash_Ip6ReasmFails && strcmp(name, "Ip6ReasmFails") == 0)) Ip6ReasmFails = strtoull(value, NULL, 10);
382 + else if(unlikely(hash == hash_Ip6FragOKs && strcmp(name, "Ip6FragOKs") == 0)) Ip6FragOKs = strtoull(value, NULL, 10);
383 + else if(unlikely(hash == hash_Ip6FragFails && strcmp(name, "Ip6FragFails") == 0)) Ip6FragFails = strtoull(value, NULL, 10);
384 + else if(unlikely(hash == hash_Ip6FragCreates && strcmp(name, "Ip6FragCreates") == 0)) Ip6FragCreates = strtoull(value, NULL, 10);
385 + else if(unlikely(hash == hash_Ip6InMcastPkts && strcmp(name, "Ip6InMcastPkts") == 0)) Ip6InMcastPkts = strtoull(value, NULL, 10);
386 + else if(unlikely(hash == hash_Ip6OutMcastPkts && strcmp(name, "Ip6OutMcastPkts") == 0)) Ip6OutMcastPkts = strtoull(value, NULL, 10);
387 + else if(unlikely(hash == hash_Ip6InOctets && strcmp(name, "Ip6InOctets") == 0)) Ip6InOctets = strtoull(value, NULL, 10);
388 + else if(unlikely(hash == hash_Ip6OutOctets && strcmp(name, "Ip6OutOctets") == 0)) Ip6OutOctets = strtoull(value, NULL, 10);
389 + else if(unlikely(hash == hash_Ip6InMcastOctets && strcmp(name, "Ip6InMcastOctets") == 0)) Ip6InMcastOctets = strtoull(value, NULL, 10);
390 + else if(unlikely(hash == hash_Ip6OutMcastOctets && strcmp(name, "Ip6OutMcastOctets") == 0)) Ip6OutMcastOctets = strtoull(value, NULL, 10);
391 + else if(unlikely(hash == hash_Ip6InBcastOctets && strcmp(name, "Ip6InBcastOctets") == 0)) Ip6InBcastOctets = strtoull(value, NULL, 10);
392 + else if(unlikely(hash == hash_Ip6OutBcastOctets && strcmp(name, "Ip6OutBcastOctets") == 0)) Ip6OutBcastOctets = strtoull(value, NULL, 10);
393 + else if(unlikely(hash == hash_Ip6InNoECTPkts && strcmp(name, "Ip6InNoECTPkts") == 0)) Ip6InNoECTPkts = strtoull(value, NULL, 10);
394 + else if(unlikely(hash == hash_Ip6InECT1Pkts && strcmp(name, "Ip6InECT1Pkts") == 0)) Ip6InECT1Pkts = strtoull(value, NULL, 10);
395 + else if(unlikely(hash == hash_Ip6InECT0Pkts && strcmp(name, "Ip6InECT0Pkts") == 0)) Ip6InECT0Pkts = strtoull(value, NULL, 10);
396 + else if(unlikely(hash == hash_Ip6InCEPkts && strcmp(name, "Ip6InCEPkts") == 0)) Ip6InCEPkts = strtoull(value, NULL, 10);
397 + else if(unlikely(hash == hash_Icmp6InMsgs && strcmp(name, "Icmp6InMsgs") == 0)) Icmp6InMsgs = strtoull(value, NULL, 10);
398 + else if(unlikely(hash == hash_Icmp6InErrors && strcmp(name, "Icmp6InErrors") == 0)) Icmp6InErrors = strtoull(value, NULL, 10);
399 + else if(unlikely(hash == hash_Icmp6OutMsgs && strcmp(name, "Icmp6OutMsgs") == 0)) Icmp6OutMsgs = strtoull(value, NULL, 10);
400 + else if(unlikely(hash == hash_Icmp6OutErrors && strcmp(name, "Icmp6OutErrors") == 0)) Icmp6OutErrors = strtoull(value, NULL, 10);
401 + else if(unlikely(hash == hash_Icmp6InCsumErrors && strcmp(name, "Icmp6InCsumErrors") == 0)) Icmp6InCsumErrors = strtoull(value, NULL, 10);
402 + else if(unlikely(hash == hash_Icmp6InDestUnreachs && strcmp(name, "Icmp6InDestUnreachs") == 0)) Icmp6InDestUnreachs = strtoull(value, NULL, 10);
403 + else if(unlikely(hash == hash_Icmp6InPktTooBigs && strcmp(name, "Icmp6InPktTooBigs") == 0)) Icmp6InPktTooBigs = strtoull(value, NULL, 10);
404 + else if(unlikely(hash == hash_Icmp6InTimeExcds && strcmp(name, "Icmp6InTimeExcds") == 0)) Icmp6InTimeExcds = strtoull(value, NULL, 10);
405 + else if(unlikely(hash == hash_Icmp6InParmProblems && strcmp(name, "Icmp6InParmProblems") == 0)) Icmp6InParmProblems = strtoull(value, NULL, 10);
406 + else if(unlikely(hash == hash_Icmp6InEchos && strcmp(name, "Icmp6InEchos") == 0)) Icmp6InEchos = strtoull(value, NULL, 10);
407 + else if(unlikely(hash == hash_Icmp6InEchoReplies && strcmp(name, "Icmp6InEchoReplies") == 0)) Icmp6InEchoReplies = strtoull(value, NULL, 10);
408 + else if(unlikely(hash == hash_Icmp6InGroupMembQueries && strcmp(name, "Icmp6InGroupMembQueries") == 0)) Icmp6InGroupMembQueries = strtoull(value, NULL, 10);
409 + else if(unlikely(hash == hash_Icmp6InGroupMembResponses && strcmp(name, "Icmp6InGroupMembResponses") == 0)) Icmp6InGroupMembResponses = strtoull(value, NULL, 10);
410 + else if(unlikely(hash == hash_Icmp6InGroupMembReductions && strcmp(name, "Icmp6InGroupMembReductions") == 0)) Icmp6InGroupMembReductions = strtoull(value, NULL, 10);
411 + else if(unlikely(hash == hash_Icmp6InRouterSolicits && strcmp(name, "Icmp6InRouterSolicits") == 0)) Icmp6InRouterSolicits = strtoull(value, NULL, 10);
412 + else if(unlikely(hash == hash_Icmp6InRouterAdvertisements && strcmp(name, "Icmp6InRouterAdvertisements") == 0)) Icmp6InRouterAdvertisements = strtoull(value, NULL, 10);
413 + else if(unlikely(hash == hash_Icmp6InNeighborSolicits && strcmp(name, "Icmp6InNeighborSolicits") == 0)) Icmp6InNeighborSolicits = strtoull(value, NULL, 10);
414 + else if(unlikely(hash == hash_Icmp6InNeighborAdvertisements && strcmp(name, "Icmp6InNeighborAdvertisements") == 0)) Icmp6InNeighborAdvertisements = strtoull(value, NULL, 10);
415 + else if(unlikely(hash == hash_Icmp6InRedirects && strcmp(name, "Icmp6InRedirects") == 0)) Icmp6InRedirects = strtoull(value, NULL, 10);
416 + else if(unlikely(hash == hash_Icmp6InMLDv2Reports && strcmp(name, "Icmp6InMLDv2Reports") == 0)) Icmp6InMLDv2Reports = strtoull(value, NULL, 10);
417 + else if(unlikely(hash == hash_Icmp6OutDestUnreachs && strcmp(name, "Icmp6OutDestUnreachs") == 0)) Icmp6OutDestUnreachs = strtoull(value, NULL, 10);
418 + else if(unlikely(hash == hash_Icmp6OutPktTooBigs && strcmp(name, "Icmp6OutPktTooBigs") == 0)) Icmp6OutPktTooBigs = strtoull(value, NULL, 10);
419 + else if(unlikely(hash == hash_Icmp6OutTimeExcds && strcmp(name, "Icmp6OutTimeExcds") == 0)) Icmp6OutTimeExcds = strtoull(value, NULL, 10);
420 + else if(unlikely(hash == hash_Icmp6OutParmProblems && strcmp(name, "Icmp6OutParmProblems") == 0)) Icmp6OutParmProblems = strtoull(value, NULL, 10);
421 + else if(unlikely(hash == hash_Icmp6OutEchos && strcmp(name, "Icmp6OutEchos") == 0)) Icmp6OutEchos = strtoull(value, NULL, 10);
422 + else if(unlikely(hash == hash_Icmp6OutEchoReplies && strcmp(name, "Icmp6OutEchoReplies") == 0)) Icmp6OutEchoReplies = strtoull(value, NULL, 10);
423 + else if(unlikely(hash == hash_Icmp6OutGroupMembQueries && strcmp(name, "Icmp6OutGroupMembQueries") == 0)) Icmp6OutGroupMembQueries = strtoull(value, NULL, 10);
424 + else if(unlikely(hash == hash_Icmp6OutGroupMembResponses && strcmp(name, "Icmp6OutGroupMembResponses") == 0)) Icmp6OutGroupMembResponses = strtoull(value, NULL, 10);
425 + else if(unlikely(hash == hash_Icmp6OutGroupMembReductions && strcmp(name, "Icmp6OutGroupMembReductions") == 0)) Icmp6OutGroupMembReductions = strtoull(value, NULL, 10);
426 + else if(unlikely(hash == hash_Icmp6OutRouterSolicits && strcmp(name, "Icmp6OutRouterSolicits") == 0)) Icmp6OutRouterSolicits = strtoull(value, NULL, 10);
427 + else if(unlikely(hash == hash_Icmp6OutRouterAdvertisements && strcmp(name, "Icmp6OutRouterAdvertisements") == 0)) Icmp6OutRouterAdvertisements = strtoull(value, NULL, 10);
428 + else if(unlikely(hash == hash_Icmp6OutNeighborSolicits && strcmp(name, "Icmp6OutNeighborSolicits") == 0)) Icmp6OutNeighborSolicits = strtoull(value, NULL, 10);
429 + else if(unlikely(hash == hash_Icmp6OutNeighborAdvertisements && strcmp(name, "Icmp6OutNeighborAdvertisements") == 0)) Icmp6OutNeighborAdvertisements = strtoull(value, NULL, 10);
430 + else if(unlikely(hash == hash_Icmp6OutRedirects && strcmp(name, "Icmp6OutRedirects") == 0)) Icmp6OutRedirects = strtoull(value, NULL, 10);
431 + else if(unlikely(hash == hash_Icmp6OutMLDv2Reports && strcmp(name, "Icmp6OutMLDv2Reports") == 0)) Icmp6OutMLDv2Reports = strtoull(value, NULL, 10);
432 + else if(unlikely(hash == hash_Icmp6InType1 && strcmp(name, "Icmp6InType1") == 0)) Icmp6InType1 = strtoull(value, NULL, 10);
433 + else if(unlikely(hash == hash_Icmp6InType128 && strcmp(name, "Icmp6InType128") == 0)) Icmp6InType128 = strtoull(value, NULL, 10);
434 + else if(unlikely(hash == hash_Icmp6InType129 && strcmp(name, "Icmp6InType129") == 0)) Icmp6InType129 = strtoull(value, NULL, 10);
435 + else if(unlikely(hash == hash_Icmp6InType136 && strcmp(name, "Icmp6InType136") == 0)) Icmp6InType136 = strtoull(value, NULL, 10);
436 + else if(unlikely(hash == hash_Icmp6OutType1 && strcmp(name, "Icmp6OutType1") == 0)) Icmp6OutType1 = strtoull(value, NULL, 10);
437 + else if(unlikely(hash == hash_Icmp6OutType128 && strcmp(name, "Icmp6OutType128") == 0)) Icmp6OutType128 = strtoull(value, NULL, 10);
438 + else if(unlikely(hash == hash_Icmp6OutType129 && strcmp(name, "Icmp6OutType129") == 0)) Icmp6OutType129 = strtoull(value, NULL, 10);
439 + else if(unlikely(hash == hash_Icmp6OutType133 && strcmp(name, "Icmp6OutType133") == 0)) Icmp6OutType133 = strtoull(value, NULL, 10);
440 + else if(unlikely(hash == hash_Icmp6OutType135 && strcmp(name, "Icmp6OutType135") == 0)) Icmp6OutType135 = strtoull(value, NULL, 10);
441 + else if(unlikely(hash == hash_Icmp6OutType143 && strcmp(name, "Icmp6OutType143") == 0)) Icmp6OutType143 = strtoull(value, NULL, 10);
442 + else if(unlikely(hash == hash_Udp6InDatagrams && strcmp(name, "Udp6InDatagrams") == 0)) Udp6InDatagrams = strtoull(value, NULL, 10);
443 + else if(unlikely(hash == hash_Udp6NoPorts && strcmp(name, "Udp6NoPorts") == 0)) Udp6NoPorts = strtoull(value, NULL, 10);
444 + else if(unlikely(hash == hash_Udp6InErrors && strcmp(name, "Udp6InErrors") == 0)) Udp6InErrors = strtoull(value, NULL, 10);
445 + else if(unlikely(hash == hash_Udp6OutDatagrams && strcmp(name, "Udp6OutDatagrams") == 0)) Udp6OutDatagrams = strtoull(value, NULL, 10);
446 + else if(unlikely(hash == hash_Udp6RcvbufErrors && strcmp(name, "Udp6RcvbufErrors") == 0)) Udp6RcvbufErrors = strtoull(value, NULL, 10);
447 + else if(unlikely(hash == hash_Udp6SndbufErrors && strcmp(name, "Udp6SndbufErrors") == 0)) Udp6SndbufErrors = strtoull(value, NULL, 10);
448 + else if(unlikely(hash == hash_Udp6InCsumErrors && strcmp(name, "Udp6InCsumErrors") == 0)) Udp6InCsumErrors = strtoull(value, NULL, 10);
449 + else if(unlikely(hash == hash_Udp6IgnoredMulti && strcmp(name, "Udp6IgnoredMulti") == 0)) Udp6IgnoredMulti = strtoull(value, NULL, 10);
450 + else if(unlikely(hash == hash_UdpLite6InDatagrams && strcmp(name, "UdpLite6InDatagrams") == 0)) UdpLite6InDatagrams = strtoull(value, NULL, 10);
451 + else if(unlikely(hash == hash_UdpLite6NoPorts && strcmp(name, "UdpLite6NoPorts") == 0)) UdpLite6NoPorts = strtoull(value, NULL, 10);
452 + else if(unlikely(hash == hash_UdpLite6InErrors && strcmp(name, "UdpLite6InErrors") == 0)) UdpLite6InErrors = strtoull(value, NULL, 10);
453 + else if(unlikely(hash == hash_UdpLite6OutDatagrams && strcmp(name, "UdpLite6OutDatagrams") == 0)) UdpLite6OutDatagrams = strtoull(value, NULL, 10);
454 + else if(unlikely(hash == hash_UdpLite6RcvbufErrors && strcmp(name, "UdpLite6RcvbufErrors") == 0)) UdpLite6RcvbufErrors = strtoull(value, NULL, 10);
455 + else if(unlikely(hash == hash_UdpLite6SndbufErrors && strcmp(name, "UdpLite6SndbufErrors") == 0)) UdpLite6SndbufErrors = strtoull(value, NULL, 10);
456 + else if(unlikely(hash == hash_UdpLite6InCsumErrors && strcmp(name, "UdpLite6InCsumErrors") == 0)) UdpLite6InCsumErrors = strtoull(value, NULL, 10);
457 }
458
459 RRDSET *st;
@@ -460,7 +463,7 @@ int do_proc_net_snmp6(int update_every, unsigned long long dt) {
463 if(do_bandwidth == CONFIG_ONDEMAND_YES || (do_bandwidth == CONFIG_ONDEMAND_ONDEMAND && (Ip6InOctets || Ip6OutOctets))) {
464 do_bandwidth = CONFIG_ONDEMAND_YES;
465 st = rrdset_find("system.ipv6");
463 - if(!st) {
466 + if(unlikely(!st)) {
467 st = rrdset_create("system", "ipv6", NULL, "network", NULL, "IPv6 Bandwidth", "kilobits/s", 500, update_every, RRDSET_TYPE_AREA);
468
469 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) {
481 if(do_ip_packets == CONFIG_ONDEMAND_YES || (do_ip_packets == CONFIG_ONDEMAND_ONDEMAND && (Ip6InReceives || Ip6OutRequests || Ip6InDelivers || Ip6OutForwDatagrams))) {
482 do_ip_packets = CONFIG_ONDEMAND_YES;
483 st = rrdset_find(RRD_TYPE_NET_SNMP6 ".packets");
481 - if(!st) {
484 + if(unlikely(!st)) {
485 st = rrdset_create(RRD_TYPE_NET_SNMP6, "packets", NULL, "packets", NULL, "IPv6 Packets", "packets/s", 3000, update_every, RRDSET_TYPE_LINE);
486
487 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) {
503 if(do_ip_fragsout == CONFIG_ONDEMAND_YES || (do_ip_fragsout == CONFIG_ONDEMAND_ONDEMAND && (Ip6FragOKs || Ip6FragFails || Ip6FragCreates))) {
504 do_ip_fragsout = CONFIG_ONDEMAND_YES;
505 st = rrdset_find(RRD_TYPE_NET_SNMP6 ".fragsout");
503 - if(!st) {
506 + if(unlikely(!st)) {
507 st = rrdset_create(RRD_TYPE_NET_SNMP6, "fragsout", NULL, "fragments", NULL, "IPv6 Fragments Sent", "packets/s", 3010, update_every, RRDSET_TYPE_LINE);
508 st->isdetail = 1;
509
@@ -527,7 +530,7 @@ int do_proc_net_snmp6(int update_every, unsigned long long dt) {
530 ))) {
531 do_ip_fragsin = CONFIG_ONDEMAND_YES;
532 st = rrdset_find(RRD_TYPE_NET_SNMP6 ".fragsin");
530 - if(!st) {
533 + if(unlikely(!st)) {
534 st = rrdset_create(RRD_TYPE_NET_SNMP6, "fragsin", NULL, "fragments", NULL, "IPv6 Fragments Reassembly", "packets/s", 3011, update_every, RRDSET_TYPE_LINE);
535 st->isdetail = 1;
536
@@ -560,7 +563,7 @@ int do_proc_net_snmp6(int update_every, unsigned long long dt) {
563 ))) {
564 do_ip_errors = CONFIG_ONDEMAND_YES;
565 st = rrdset_find(RRD_TYPE_NET_SNMP6 ".errors");
563 - if(!st) {
566 + if(unlikely(!st)) {
567 st = rrdset_create(RRD_TYPE_NET_SNMP6, "errors", NULL, "errors", NULL, "IPv6 Errors", "packets/s", 3002, update_every, RRDSET_TYPE_LINE);
568 st->isdetail = 1;
569
@@ -597,7 +600,7 @@ int do_proc_net_snmp6(int update_every, unsigned long long dt) {
600 if(do_udp_packets == CONFIG_ONDEMAND_YES || (do_udp_packets == CONFIG_ONDEMAND_ONDEMAND && (Udp6InDatagrams || Udp6OutDatagrams))) {
601 do_udp_packets = CONFIG_ONDEMAND_YES;
602 st = rrdset_find(RRD_TYPE_NET_SNMP6 ".udppackets");
600 - if(!st) {
603 + if(unlikely(!st)) {
604 st = rrdset_create(RRD_TYPE_NET_SNMP6, "udppackets", NULL, "udp", NULL, "IPv6 UDP Packets", "packets/s", 3601, update_every, RRDSET_TYPE_LINE);
605
606 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) {
626 ))) {
627 do_udp_errors = CONFIG_ONDEMAND_YES;
628 st = rrdset_find(RRD_TYPE_NET_SNMP6 ".udperrors");
626 - if(!st) {
629 + if(unlikely(!st)) {
630 st = rrdset_create(RRD_TYPE_NET_SNMP6, "udperrors", NULL, "udp", NULL, "IPv6 UDP Errors", "events/s", 3701, update_every, RRDSET_TYPE_LINE);
631 st->isdetail = 1;
632
@@ -650,7 +653,7 @@ int do_proc_net_snmp6(int update_every, unsigned long long dt) {
653 if(do_udplite_packets == CONFIG_ONDEMAND_YES || (do_udplite_packets == CONFIG_ONDEMAND_ONDEMAND && (UdpLite6InDatagrams || UdpLite6OutDatagrams))) {
654 do_udplite_packets = CONFIG_ONDEMAND_YES;
655 st = rrdset_find(RRD_TYPE_NET_SNMP6 ".udplitepackets");
653 - if(!st) {
656 + if(unlikely(!st)) {
657 st = rrdset_create(RRD_TYPE_NET_SNMP6, "udplitepackets", NULL, "udplite", NULL, "IPv6 UDPlite Packets", "packets/s", 3601, update_every, RRDSET_TYPE_LINE);
658
659 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) {
679 ))) {
680 do_udplite_errors = CONFIG_ONDEMAND_YES;
681 st = rrdset_find(RRD_TYPE_NET_SNMP6 ".udpliteerrors");
679 - if(!st) {
682 + if(unlikely(!st)) {
683 st = rrdset_create(RRD_TYPE_NET_SNMP6, "udpliteerrors", NULL, "udplite", NULL, "IPv6 UDP Lite Errors", "events/s", 3701, update_every, RRDSET_TYPE_LINE);
684 st->isdetail = 1;
685
@@ -701,7 +704,7 @@ int do_proc_net_snmp6(int update_every, unsigned long long dt) {
704 if(do_mcast == CONFIG_ONDEMAND_YES || (do_mcast == CONFIG_ONDEMAND_ONDEMAND && (Ip6OutMcastOctets || Ip6InMcastOctets))) {
705 do_mcast = CONFIG_ONDEMAND_YES;
706 st = rrdset_find(RRD_TYPE_NET_SNMP6 ".mcast");
704 - if(!st) {
707 + if(unlikely(!st)) {
708 st = rrdset_create(RRD_TYPE_NET_SNMP6, "mcast", NULL, "multicast", NULL, "IPv6 Multicast Bandwidth", "kilobits/s", 9000, update_every, RRDSET_TYPE_AREA);
709 st->isdetail = 1;
710
@@ -720,7 +723,7 @@ int do_proc_net_snmp6(int update_every, unsigned long long dt) {
723 if(do_bcast == CONFIG_ONDEMAND_YES || (do_bcast == CONFIG_ONDEMAND_ONDEMAND && (Ip6OutBcastOctets || Ip6InBcastOctets))) {
724 do_bcast = CONFIG_ONDEMAND_YES;
725 st = rrdset_find(RRD_TYPE_NET_SNMP6 ".bcast");
723 - if(!st) {
726 + if(unlikely(!st)) {
727 st = rrdset_create(RRD_TYPE_NET_SNMP6, "bcast", NULL, "broadcast", NULL, "IPv6 Broadcast Bandwidth", "kilobits/s", 8000, update_every, RRDSET_TYPE_AREA);
728 st->isdetail = 1;
729
@@ -739,7 +742,7 @@ int do_proc_net_snmp6(int update_every, unsigned long long dt) {
742 if(do_mcast_p == CONFIG_ONDEMAND_YES || (do_mcast_p == CONFIG_ONDEMAND_ONDEMAND && (Ip6OutMcastPkts || Ip6InMcastPkts))) {
743 do_mcast_p = CONFIG_ONDEMAND_YES;
744 st = rrdset_find(RRD_TYPE_NET_SNMP6 ".mcastpkts");
742 - if(!st) {
745 + if(unlikely(!st)) {
746 st = rrdset_create(RRD_TYPE_NET_SNMP6, "mcastpkts", NULL, "multicast", NULL, "IPv6 Multicast Packets", "packets/s", 9500, update_every, RRDSET_TYPE_LINE);
747 st->isdetail = 1;
748
@@ -758,7 +761,7 @@ int do_proc_net_snmp6(int update_every, unsigned long long dt) {
761 if(do_icmp == CONFIG_ONDEMAND_YES || (do_icmp == CONFIG_ONDEMAND_ONDEMAND && (Icmp6InMsgs || Icmp6OutMsgs))) {
762 do_icmp = CONFIG_ONDEMAND_YES;
763 st = rrdset_find(RRD_TYPE_NET_SNMP6 ".icmp");
761 - if(!st) {
764 + if(unlikely(!st)) {
765 st = rrdset_create(RRD_TYPE_NET_SNMP6, "icmp", NULL, "icmp", NULL, "IPv6 ICMP Messages", "messages/s", 10000, update_every, RRDSET_TYPE_LINE);
766
767 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) {
779 if(do_icmp_redir == CONFIG_ONDEMAND_YES || (do_icmp_redir == CONFIG_ONDEMAND_ONDEMAND && (Icmp6InRedirects || Icmp6OutRedirects))) {
780 do_icmp_redir = CONFIG_ONDEMAND_YES;
781 st = rrdset_find(RRD_TYPE_NET_SNMP6 ".icmpredir");
779 - if(!st) {
782 + if(unlikely(!st)) {
783 st = rrdset_create(RRD_TYPE_NET_SNMP6, "icmpredir", NULL, "icmp", NULL, "IPv6 ICMP Redirects", "redirects/s", 10050, update_every, RRDSET_TYPE_LINE);
784
785 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) {
810 ))) {
811 do_icmp_errors = CONFIG_ONDEMAND_YES;
812 st = rrdset_find(RRD_TYPE_NET_SNMP6 ".icmperrors");
810 - if(!st) {
813 + if(unlikely(!st)) {
814 st = rrdset_create(RRD_TYPE_NET_SNMP6, "icmperrors", NULL, "icmp", NULL, "IPv6 ICMP Errors", "errors/s", 10100, update_every, RRDSET_TYPE_LINE);
815
816 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) {
853 ))) {
854 do_icmp_echos = CONFIG_ONDEMAND_YES;
855 st = rrdset_find(RRD_TYPE_NET_SNMP6 ".icmpechos");
853 - if(!st) {
856 + if(unlikely(!st)) {
857 st = rrdset_create(RRD_TYPE_NET_SNMP6, "icmpechos", NULL, "icmp", NULL, "IPv6 ICMP Echo", "messages/s", 10200, update_every, RRDSET_TYPE_LINE);
858
859 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) {
883 ))) {
884 do_icmp_groupmemb = CONFIG_ONDEMAND_YES;
885 st = rrdset_find(RRD_TYPE_NET_SNMP6 ".groupmemb");
883 - if(!st) {
886 + if(unlikely(!st)) {
887 st = rrdset_create(RRD_TYPE_NET_SNMP6, "groupmemb", NULL, "icmp", NULL, "IPv6 ICMP Group Membership", "messages/s", 10300, update_every, RRDSET_TYPE_LINE);
888
889 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) {
915 ))) {
916 do_icmp_router = CONFIG_ONDEMAND_YES;
917 st = rrdset_find(RRD_TYPE_NET_SNMP6 ".icmprouter");
915 - if(!st) {
918 + if(unlikely(!st)) {
919 st = rrdset_create(RRD_TYPE_NET_SNMP6, "icmprouter", NULL, "icmp", NULL, "IPv6 Router Messages", "messages/s", 10400, update_every, RRDSET_TYPE_LINE);
920
921 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) {
943 ))) {
944 do_icmp_neighbor = CONFIG_ONDEMAND_YES;
945 st = rrdset_find(RRD_TYPE_NET_SNMP6 ".icmpneighbor");
943 - if(!st) {
946 + if(unlikely(!st)) {
947 st = rrdset_create(RRD_TYPE_NET_SNMP6, "icmpneighbor", NULL, "icmp", NULL, "IPv6 Neighbor Messages", "messages/s", 10500, update_every, RRDSET_TYPE_LINE);
948
949 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) {
965 if(do_icmp_mldv2 == CONFIG_ONDEMAND_YES || (do_icmp_mldv2 == CONFIG_ONDEMAND_ONDEMAND && (Icmp6InMLDv2Reports || Icmp6OutMLDv2Reports))) {
966 do_icmp_mldv2 = CONFIG_ONDEMAND_YES;
967 st = rrdset_find(RRD_TYPE_NET_SNMP6 ".icmpmldv2");
965 - if(!st) {
968 + if(unlikely(!st)) {
969 st = rrdset_create(RRD_TYPE_NET_SNMP6, "icmpmldv2", NULL, "icmp", NULL, "IPv6 ICMP MLDv2 Reports", "reports/s", 10600, update_every, RRDSET_TYPE_LINE);
970
971 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) {
995 ))) {
996 do_icmp_types = CONFIG_ONDEMAND_YES;
997 st = rrdset_find(RRD_TYPE_NET_SNMP6 ".icmptypes");
995 - if(!st) {
998 + if(unlikely(!st)) {
999 st = rrdset_create(RRD_TYPE_NET_SNMP6, "icmptypes", NULL, "icmp", NULL, "IPv6 ICMP Types", "messages/s", 10700, update_every, RRDSET_TYPE_LINE);
1000
1001 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) {
1035 ))) {
1036 do_ect = CONFIG_ONDEMAND_YES;
1037 st = rrdset_find(RRD_TYPE_NET_SNMP6 ".ect");
1035 - if(!st) {
1038 + if(unlikely(!st)) {
1039 st = rrdset_create(RRD_TYPE_NET_SNMP6, "ect", NULL, "packets", NULL, "IPv6 ECT Packets", "packets/s", 10800, update_every, RRDSET_TYPE_LINE);
1040
1041 rrddim_add(st, "InNoECTPkts", NULL, 1, 1, RRDDIM_INCREMENTAL);
src/proc_net_softnet_stat.c
+13 -12
@@ -19,28 +19,28 @@ int do_proc_net_softnet_stat(int update_every, unsigned long long dt) {
19 static int do_per_core = -1;
20 static uint32_t allocated_lines = 0, allocated_columns = 0, *data = NULL;
21
22 - if(do_per_core == -1) do_per_core = config_get_boolean("plugin:proc:/proc/net/softnet_stat", "softnet_stat per core", 1);
22 + if(unlikely(do_per_core == -1)) do_per_core = config_get_boolean("plugin:proc:/proc/net/softnet_stat", "softnet_stat per core", 1);
23
24 - if(!ff) {
24 + if(unlikely(!ff)) {
25 char filename[FILENAME_MAX + 1];
26 snprintfz(filename, FILENAME_MAX, "%s%s", global_host_prefix, "/proc/net/softnet_stat");
27 ff = procfile_open(config_get("plugin:proc:/proc/net/softnet_stat", "filename to monitor", filename), " \t", PROCFILE_FLAG_DEFAULT);
28 + if(unlikely(!ff)) return 1;
29 }
29 - if(!ff) return 1;
30
31 ff = procfile_readall(ff);
32 - if(!ff) return 0; // we return 0, so that we will retry to open it next time
32 + if(unlikely(!ff)) return 0; // we return 0, so that we will retry to open it next time
33
34 uint32_t lines = procfile_lines(ff), l;
35 uint32_t words = procfile_linewords(ff, 0), w;
36
37 - if(!lines || !words) {
37 + if(unlikely(!lines || !words)) {
38 error("Cannot read /proc/net/softnet_stat, %u lines and %u columns reported.", lines, words);
39 return 1;
40 }
41
42 - if(lines > 200) lines = 200;
43 - if(words > 50) words = 50;
42 + if(unlikely(lines > 200)) lines = 200;
43 + if(unlikely(words > 50)) words = 50;
44
45 if(unlikely(!data || lines > allocated_lines || words > allocated_columns)) {
46 freez(data);
@@ -55,9 +55,10 @@ int do_proc_net_softnet_stat(int update_every, unsigned long long dt) {
55 // parse the values
56 for(l = 0; l < lines ;l++) {
57 words = procfile_linewords(ff, l);
58 - if(!words) continue;
58 + if(unlikely(!words)) continue;
59
60 - if(words > allocated_columns) words = allocated_columns;
60 + if(unlikely(words > allocated_columns))
61 + words = allocated_columns;
62
63 for(w = 0; w < words ; w++) {
64 if(unlikely(softnet_column_name(w))) {
@@ -68,7 +69,7 @@ int do_proc_net_softnet_stat(int update_every, unsigned long long dt) {
69 }
70 }
71
71 - if(data[(lines * allocated_columns)] == 0)
72 + if(unlikely(data[(lines * allocated_columns)] == 0))
73 lines--;
74
75 RRDSET *st;
@@ -76,7 +77,7 @@ int do_proc_net_softnet_stat(int update_every, unsigned long long dt) {
77 // --------------------------------------------------------------------
78
79 st = rrdset_find_bytype("system", "softnet_stat");
79 - if(!st) {
80 + if(unlikely(!st)) {
81 st = rrdset_create("system", "softnet_stat", NULL, "softnet_stat", NULL, "System softnet_stat", "events/s", 955, update_every, RRDSET_TYPE_LINE);
82 for(w = 0; w < allocated_columns ;w++)
83 if(unlikely(softnet_column_name(w)))
@@ -96,7 +97,7 @@ int do_proc_net_softnet_stat(int update_every, unsigned long long dt) {
97 snprintfz(id, 50, "cpu%u_softnet_stat", l);
98
99 st = rrdset_find_bytype("cpu", id);
99 - if(!st) {
100 + if(unlikely(!st)) {
101 char title[100+1];
102 snprintfz(title, 100, "CPU%u softnet_stat", l);
103
src/proc_net_stat_conntrack.c
+24 -21
@@ -2,30 +2,33 @@
2
3 #define RRD_TYPE_NET_STAT_NETFILTER "netfilter"
4 #define RRD_TYPE_NET_STAT_CONNTRACK "conntrack"
5 -#define RRD_TYPE_NET_STAT_CONNTRACK_LEN strlen(RRD_TYPE_NET_STAT_CONNTRACK)
5
6 int do_proc_net_stat_conntrack(int update_every, unsigned long long dt) {
7 + (void)dt;
8 +
9 static procfile *ff = NULL;
10 static int do_sockets = -1, do_new = -1, do_changes = -1, do_expect = -1, do_search = -1, do_errors = -1;
11
11 - if(do_sockets == -1) do_sockets = config_get_boolean("plugin:proc:/proc/net/stat/nf_conntrack", "netfilter connections", 1);
12 - if(do_new == -1) do_new = config_get_boolean("plugin:proc:/proc/net/stat/nf_conntrack", "netfilter new connections", 1);
13 - if(do_changes == -1) do_changes = config_get_boolean("plugin:proc:/proc/net/stat/nf_conntrack", "netfilter connection changes", 1);
14 - if(do_expect == -1) do_expect = config_get_boolean("plugin:proc:/proc/net/stat/nf_conntrack", "netfilter connection expectations", 1);
15 - if(do_search == -1) do_search = config_get_boolean("plugin:proc:/proc/net/stat/nf_conntrack", "netfilter connection searches", 1);
16 - if(do_errors == -1) do_errors = config_get_boolean("plugin:proc:/proc/net/stat/nf_conntrack", "netfilter errors", 1);
17 -
18 - if(dt) {};
12 + if(unlikely(do_sockets == -1)) {
13 + do_sockets = config_get_boolean("plugin:proc:/proc/net/stat/nf_conntrack", "netfilter connections", 1);
14 + do_new = config_get_boolean("plugin:proc:/proc/net/stat/nf_conntrack", "netfilter new connections", 1);
15 + do_changes = config_get_boolean("plugin:proc:/proc/net/stat/nf_conntrack", "netfilter connection changes", 1);
16 + do_expect = config_get_boolean("plugin:proc:/proc/net/stat/nf_conntrack", "netfilter connection expectations", 1);
17 + do_search = config_get_boolean("plugin:proc:/proc/net/stat/nf_conntrack", "netfilter connection searches", 1);
18 + do_errors = config_get_boolean("plugin:proc:/proc/net/stat/nf_conntrack", "netfilter errors", 1);
19 + }
20
20 - if(!ff) {
21 + if(unlikely(!ff)) {
22 char filename[FILENAME_MAX + 1];
23 snprintfz(filename, FILENAME_MAX, "%s%s", global_host_prefix, "/proc/net/stat/nf_conntrack");
24 ff = procfile_open(config_get("plugin:proc:/proc/net/stat/nf_conntrack", "filename to monitor", filename), " \t:", PROCFILE_FLAG_DEFAULT);
25 + if(unlikely(!ff))
26 + return 1;
27 }
25 - if(!ff) return 1;
28
29 ff = procfile_readall(ff);
28 - if(!ff) return 0; // we return 0, so that we will retry to open it next time
30 + if(unlikely(!ff))
31 + return 0; // we return 0, so that we will retry to open it next time
32
33 uint32_t lines = procfile_lines(ff), l;
34 uint32_t words;
@@ -35,8 +38,8 @@ int do_proc_net_stat_conntrack(int update_every, unsigned long long dt) {
38
39 for(l = 1; l < lines ;l++) {
40 words = procfile_linewords(ff, l);
38 - if(words < 17) {
39 - if(words) error("Cannot read /proc/net/stat/nf_conntrack line. Expected 17 params, read %u.", words);
41 + if(unlikely(words < 17)) {
42 + if(unlikely(words)) error("Cannot read /proc/net/stat/nf_conntrack line. Expected 17 params, read %u.", words);
43 continue;
44 }
45
@@ -60,7 +63,7 @@ int do_proc_net_stat_conntrack(int update_every, unsigned long long dt) {
63 texpect_delete = strtoull(procfile_lineword(ff, l, 15), NULL, 16);
64 tsearch_restart = strtoull(procfile_lineword(ff, l, 16), NULL, 16);
65
63 - if(!aentries) aentries = tentries;
66 + if(unlikely(!aentries)) aentries = tentries;
67
68 // sum all the cpus together
69 asearched += tsearched; // conntrack.search
@@ -87,7 +90,7 @@ int do_proc_net_stat_conntrack(int update_every, unsigned long long dt) {
90
91 if(do_sockets) {
92 st = rrdset_find(RRD_TYPE_NET_STAT_NETFILTER "." RRD_TYPE_NET_STAT_CONNTRACK "_sockets");
90 - if(!st) {
93 + if(unlikely(!st)) {
94 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);
95
96 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) {
105
106 if(do_new) {
107 st = rrdset_find(RRD_TYPE_NET_STAT_NETFILTER "." RRD_TYPE_NET_STAT_CONNTRACK "_new");
105 - if(!st) {
108 + if(unlikely(!st)) {
109 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);
110
111 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) {
124
125 if(do_changes) {
126 st = rrdset_find(RRD_TYPE_NET_STAT_NETFILTER "." RRD_TYPE_NET_STAT_CONNTRACK "_changes");
124 - if(!st) {
127 + if(unlikely(!st)) {
128 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);
129 st->isdetail = 1;
130
@@ -141,7 +144,7 @@ int do_proc_net_stat_conntrack(int update_every, unsigned long long dt) {
144
145 if(do_expect) {
146 st = rrdset_find(RRD_TYPE_NET_STAT_NETFILTER "." RRD_TYPE_NET_STAT_CONNTRACK "_expect");
144 - if(!st) {
147 + if(unlikely(!st)) {
148 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);
149 st->isdetail = 1;
150
@@ -161,7 +164,7 @@ int do_proc_net_stat_conntrack(int update_every, unsigned long long dt) {
164
165 if(do_search) {
166 st = rrdset_find(RRD_TYPE_NET_STAT_NETFILTER "." RRD_TYPE_NET_STAT_CONNTRACK "_search");
164 - if(!st) {
167 + if(unlikely(!st)) {
168 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);
169 st->isdetail = 1;
170
@@ -181,7 +184,7 @@ int do_proc_net_stat_conntrack(int update_every, unsigned long long dt) {
184
185 if(do_errors) {
186 st = rrdset_find(RRD_TYPE_NET_STAT_NETFILTER "." RRD_TYPE_NET_STAT_CONNTRACK "_errors");
184 - if(!st) {
187 + if(unlikely(!st)) {
188 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);
189 st->isdetail = 1;
190
src/proc_net_stat_synproxy.c
+20 -16
@@ -2,32 +2,35 @@
2
3 #define RRD_TYPE_NET_STAT_NETFILTER "netfilter"
4 #define RRD_TYPE_NET_STAT_SYNPROXY "synproxy"
5 -#define RRD_TYPE_NET_STAT_SYNPROXY_LEN strlen(RRD_TYPE_NET_STAT_SYNPROXY)
5
6 int do_proc_net_stat_synproxy(int update_every, unsigned long long dt) {
7 + (void)dt;
8 +
9 static int do_entries = -1, do_cookies = -1, do_syns = -1, do_reopened = -1;
10 static procfile *ff = NULL;
11
11 - if(do_entries == -1) do_entries = config_get_boolean_ondemand("plugin:proc:/proc/net/stat/synproxy", "SYNPROXY entries", CONFIG_ONDEMAND_ONDEMAND);
12 - if(do_cookies == -1) do_cookies = config_get_boolean_ondemand("plugin:proc:/proc/net/stat/synproxy", "SYNPROXY cookies", CONFIG_ONDEMAND_ONDEMAND);
13 - if(do_syns == -1) do_syns = config_get_boolean_ondemand("plugin:proc:/proc/net/stat/synproxy", "SYNPROXY SYN received", CONFIG_ONDEMAND_ONDEMAND);
14 - if(do_reopened == -1) do_reopened = config_get_boolean_ondemand("plugin:proc:/proc/net/stat/synproxy", "SYNPROXY connections reopened", CONFIG_ONDEMAND_ONDEMAND);
15 -
16 - if(dt) {};
12 + if(unlikely(do_entries == -1)) {
13 + do_entries = config_get_boolean_ondemand("plugin:proc:/proc/net/stat/synproxy", "SYNPROXY entries", CONFIG_ONDEMAND_ONDEMAND);
14 + do_cookies = config_get_boolean_ondemand("plugin:proc:/proc/net/stat/synproxy", "SYNPROXY cookies", CONFIG_ONDEMAND_ONDEMAND);
15 + do_syns = config_get_boolean_ondemand("plugin:proc:/proc/net/stat/synproxy", "SYNPROXY SYN received", CONFIG_ONDEMAND_ONDEMAND);
16 + do_reopened = config_get_boolean_ondemand("plugin:proc:/proc/net/stat/synproxy", "SYNPROXY connections reopened", CONFIG_ONDEMAND_ONDEMAND);
17 + }
18
18 - if(!ff) {
19 + if(unlikely(!ff)) {
20 char filename[FILENAME_MAX + 1];
21 snprintfz(filename, FILENAME_MAX, "%s%s", global_host_prefix, "/proc/net/stat/synproxy");
22 ff = procfile_open(config_get("plugin:proc:/proc/net/stat/synproxy", "filename to monitor", filename), " \t,:|", PROCFILE_FLAG_DEFAULT);
23 + if(unlikely(!ff))
24 + return 1;
25 }
23 - if(!ff) return 1;
26
27 ff = procfile_readall(ff);
26 - if(!ff) return 0; // we return 0, so that we will retry to open it next time
28 + if(unlikely(!ff))
29 + return 0; // we return 0, so that we will retry to open it next time
30
31 // make sure we have 3 lines
32 size_t lines = procfile_lines(ff), l;
30 - if(lines < 2) {
33 + if(unlikely(lines < 2)) {
34 error("/proc/net/stat/synproxy has %zu lines, expected no less than 2. Disabling it.", lines);
35 return 1;
36 }
@@ -37,7 +40,8 @@ int do_proc_net_stat_synproxy(int update_every, unsigned long long dt) {
40 // synproxy gives its values per CPU
41 for(l = 1; l < lines ;l++) {
42 int words = procfile_linewords(ff, l);
40 - if(words < 6) continue;
43 + if(unlikely(words < 6))
44 + continue;
45
46 entries += strtoull(procfile_lineword(ff, l, 0), NULL, 16);
47 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) {
61 do_entries = CONFIG_ONDEMAND_YES;
62
63 st = rrdset_find(RRD_TYPE_NET_STAT_NETFILTER "." RRD_TYPE_NET_STAT_SYNPROXY "_entries");
60 - if(!st) {
64 + if(unlikely(!st)) {
65 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);
66
67 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) {
78 do_syns = CONFIG_ONDEMAND_YES;
79
80 st = rrdset_find(RRD_TYPE_NET_STAT_NETFILTER "." RRD_TYPE_NET_STAT_SYNPROXY "_syn_received");
77 - if(!st) {
81 + if(unlikely(!st)) {
82 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);
83
84 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) {
95 do_reopened = CONFIG_ONDEMAND_YES;
96
97 st = rrdset_find(RRD_TYPE_NET_STAT_NETFILTER "." RRD_TYPE_NET_STAT_SYNPROXY "_conn_reopened");
94 - if(!st) {
98 + if(unlikely(!st)) {
99 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);
100
101 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) {
112 do_cookies = CONFIG_ONDEMAND_YES;
113
114 st = rrdset_find(RRD_TYPE_NET_STAT_NETFILTER "." RRD_TYPE_NET_STAT_SYNPROXY "_cookies");
111 - if(!st) {
115 + if(unlikely(!st)) {
116 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);
117
118 rrddim_add(st, "valid", NULL, 1, 1, RRDDIM_INCREMENTAL);
src/proc_self_mountinfo.c
+21 -23
@@ -49,7 +49,7 @@ struct mountinfo *mountinfo_find(struct mountinfo *root, unsigned long major, un
49 struct mountinfo *mi;
50
51 for(mi = root; mi ; mi = mi->next)
52 - if(mi->major == major && mi->minor == minor)
52 + if(unlikely(mi->major == major && mi->minor == minor))
53 return mi;
54
55 return NULL;
@@ -62,12 +62,12 @@ struct mountinfo *mountinfo_find_by_filesystem_mount_source(struct mountinfo *ro
62 uint32_t filesystem_hash = simple_hash(filesystem), mount_source_hash = simple_hash(mount_source);
63
64 for(mi = root; mi ; mi = mi->next)
65 - if(mi->filesystem
65 + if(unlikely(mi->filesystem
66 && mi->mount_source
67 && mi->filesystem_hash == filesystem_hash
68 && mi->mount_source_hash == mount_source_hash
69 && !strcmp(mi->filesystem, filesystem)
70 - && !strcmp(mi->mount_source, mount_source))
70 + && !strcmp(mi->mount_source, mount_source)))
71 return mi;
72
73 return NULL;
@@ -80,10 +80,10 @@ struct mountinfo *mountinfo_find_by_filesystem_super_option(struct mountinfo *ro
80 size_t solen = strlen(super_options);
81
82 for(mi = root; mi ; mi = mi->next)
83 - if(mi->filesystem
83 + if(unlikely(mi->filesystem
84 && mi->super_options
85 && mi->filesystem_hash == filesystem_hash
86 - && !strcmp(mi->filesystem, filesystem)) {
86 + && !strcmp(mi->filesystem, filesystem))) {
87
88 // super_options is a comma separated list
89 char *s = mi->super_options, *e;
@@ -92,7 +92,7 @@ struct mountinfo *mountinfo_find_by_filesystem_super_option(struct mountinfo *ro
92 while(*e && *e != ',') e++;
93
94 size_t len = e - s;
95 - if(len == solen && !strncmp(s, super_options, len))
95 + if(unlikely(len == solen && !strncmp(s, super_options, len)))
96 return mi;
97
98 if(*e == ',') s = ++e;
@@ -164,20 +164,21 @@ struct mountinfo *mountinfo_read() {
164 char filename[FILENAME_MAX + 1];
165 snprintfz(filename, FILENAME_MAX, "%s/proc/self/mountinfo", global_host_prefix);
166 ff = procfile_open(filename, " \t", PROCFILE_FLAG_DEFAULT);
167 - if(!ff) {
167 + if(unlikely(!ff)) {
168 snprintfz(filename, FILENAME_MAX, "%s/proc/1/mountinfo", global_host_prefix);
169 ff = procfile_open(filename, " \t", PROCFILE_FLAG_DEFAULT);
170 - if(!ff) return NULL;
170 + if(unlikely(!ff)) return NULL;
171 }
172
173 ff = procfile_readall(ff);
174 - if(!ff) return NULL;
174 + if(unlikely(!ff))
175 + return NULL;
176
177 struct mountinfo *root = NULL, *last = NULL, *mi = NULL;
178
179 unsigned long l, lines = procfile_lines(ff);
180 for(l = 0; l < lines ;l++) {
180 - if(procfile_linewords(ff, l) < 5)
181 + if(unlikely(procfile_linewords(ff, l) < 5))
182 continue;
183
184 mi = mallocz(sizeof(struct mountinfo));
@@ -189,7 +190,7 @@ struct mountinfo *mountinfo_read() {
190 char *major = procfile_lineword(ff, l, w), *minor; w++;
191 for(minor = major; *minor && *minor != ':' ;minor++) ;
192
192 - if(!*minor) {
193 + if(unlikely(!*minor)) {
194 error("Cannot parse major:minor on '%s' at line %lu of '%s'", major, l + 1, filename);
195 freez(mi);
196 continue;
@@ -232,14 +233,11 @@ struct mountinfo *mountinfo_read() {
233 // we have some optional fields
234 // read them into a new array of pointers;
235
235 - mi->optional_fields = malloc(mi->optional_fields_count * sizeof(char *));
236 - if(unlikely(!mi->optional_fields))
237 - fatal("Cannot allocate memory for %d mountinfo optional fields", mi->optional_fields_count);
236 + mi->optional_fields = mallocz(mi->optional_fields_count * sizeof(char *));
237
238 int i;
239 for(i = 0; i < mi->optional_fields_count ; i++) {
241 - *mi->optional_fields[wo] = strdup(procfile_lineword(ff, l, w));
242 - if(!mi->optional_fields[wo]) fatal("Cannot allocate memory");
240 + *mi->optional_fields[wo] = strdupz(procfile_lineword(ff, l, w));
241 wo++;
242 }
243 }
@@ -258,10 +256,10 @@ struct mountinfo *mountinfo_read() {
256
257 mi->super_options = strdupz(procfile_lineword(ff, l, w)); w++;
258
261 - if(ME_DUMMY(mi->mount_source, mi->filesystem))
259 + if(unlikely(ME_DUMMY(mi->mount_source, mi->filesystem)))
260 mi->flags |= MOUNTINFO_IS_DUMMY;
261
264 - if(ME_REMOTE(mi->mount_source, mi->filesystem))
262 + if(unlikely(ME_REMOTE(mi->mount_source, mi->filesystem)))
263 mi->flags |= MOUNTINFO_IS_REMOTE;
264
265 // mark as BIND the duplicates (i.e. same filesystem + same source)
@@ -301,10 +299,10 @@ struct mountinfo *mountinfo_read() {
299 // check if it has size
300 {
301 struct statvfs buff_statvfs;
304 - if(statvfs(mi->mount_point, &buff_statvfs) < 0) {
302 + if(unlikely(statvfs(mi->mount_point, &buff_statvfs) < 0)) {
303 mi->flags |= MOUNTINFO_NO_STAT;
304 }
307 - else if(!buff_statvfs.f_blocks /* || !buff_statvfs.f_files */) {
305 + else if(unlikely(!buff_statvfs.f_blocks /* || !buff_statvfs.f_files */)) {
306 mi->flags |= MOUNTINFO_NO_SIZE;
307 }
308 }
@@ -353,10 +351,10 @@ struct mountinfo *mountinfo_read() {
351
352 while ((mnt = getmntent_r(fp, &mntbuf, buf, 4096))) {
353 char *bind = hasmntopt(mnt, "bind");
356 - if(bind) {
354 + if(unlikely(bind)) {
355 struct mountinfo *mi;
356 for(mi = root; mi ; mi = mi->next) {
359 - if(strcmp(mnt->mnt_dir, mi->mount_point) == 0) {
357 + if(unlikely(strcmp(mnt->mnt_dir, mi->mount_point) == 0)) {
358 fprintf(stderr, "Mount point '%s' is BIND\n", mi->mount_point);
359 mi->flags |= MOUNTINFO_IS_BIND;
360 break;
@@ -364,7 +362,7 @@ struct mountinfo *mountinfo_read() {
362 }
363
364 #ifdef NETDATA_INTERNAL_CHECKS
367 - if(!mi) {
365 + if(unlikely(!mi)) {
366 error("Mount point '%s' not found in /proc/self/mountinfo", mnt->mnt_dir);
367 }
368 #endif
src/proc_softirqs.c
+23 -23
@@ -21,7 +21,7 @@ static inline struct interrupt *get_interrupts_array(int lines, int cpus) {
21 static struct interrupt *irrs = NULL;
22 static int allocated = 0;
23
24 - if(lines > allocated) {
24 + if(unlikely(lines > allocated)) {
25 irrs = (struct interrupt *)reallocz(irrs, lines * recordsize(cpus));
26 allocated = lines;
27 }
@@ -30,43 +30,43 @@ static inline struct interrupt *get_interrupts_array(int lines, int cpus) {
30 }
31
32 int do_proc_softirqs(int update_every, unsigned long long dt) {
33 + (void)dt;
34 +
35 static procfile *ff = NULL;
36 static int cpus = -1, do_per_core = -1;
37
38 struct interrupt *irrs = NULL;
39
38 - if(dt) {};
39 -
40 - if(do_per_core == -1) do_per_core = config_get_boolean("plugin:proc:/proc/softirqs", "interrupts per core", 1);
40 + if(unlikely(do_per_core == -1)) do_per_core = config_get_boolean("plugin:proc:/proc/softirqs", "interrupts per core", 1);
41
42 - if(!ff) {
42 + if(unlikely(!ff)) {
43 char filename[FILENAME_MAX + 1];
44 snprintfz(filename, FILENAME_MAX, "%s%s", global_host_prefix, "/proc/softirqs");
45 ff = procfile_open(config_get("plugin:proc:/proc/softirqs", "filename to monitor", filename), " \t", PROCFILE_FLAG_DEFAULT);
46 + if(unlikely(!ff)) return 1;
47 }
47 - if(!ff) return 1;
48
49 ff = procfile_readall(ff);
50 - if(!ff) return 0; // we return 0, so that we will retry to open it next time
50 + if(unlikely(!ff)) return 0; // we return 0, so that we will retry to open it next time
51
52 uint32_t lines = procfile_lines(ff), l;
53 uint32_t words = procfile_linewords(ff, 0), w;
54
55 - if(!lines) {
55 + if(unlikely(!lines)) {
56 error("Cannot read /proc/softirqs, zero lines reported.");
57 return 1;
58 }
59
60 // find how many CPUs are there
61 - if(cpus == -1) {
61 + if(unlikely(cpus == -1)) {
62 cpus = 0;
63 for(w = 0; w < words ; w++) {
64 - if(strncmp(procfile_lineword(ff, 0, w), "CPU", 3) == 0)
64 + if(unlikely(strncmp(procfile_lineword(ff, 0, w), "CPU", 3) == 0))
65 cpus++;
66 }
67 }
68
69 - if(!cpus) {
69 + if(unlikely(!cpus)) {
70 error("PLUGIN: PROC_SOFTIRQS: Cannot find the number of CPUs in /proc/softirqs");
71 return 1;
72 }
@@ -82,18 +82,18 @@ int do_proc_softirqs(int update_every, unsigned long long dt) {
82 irr->total = 0;
83
84 words = procfile_linewords(ff, l);
85 - if(!words) continue;
85 + if(unlikely(!words)) continue;
86
87 irr->id = procfile_lineword(ff, l, 0);
88 - if(!irr->id || !irr->id[0]) continue;
88 + if(unlikely(!irr->id || !irr->id[0])) continue;
89
90 int idlen = strlen(irr->id);
91 - if(irr->id[idlen - 1] == ':')
91 + if(unlikely(irr->id[idlen - 1] == ':'))
92 irr->id[idlen - 1] = '\0';
93
94 int c;
95 for(c = 0; c < cpus ;c++) {
96 - if((c + 1) < (int)words)
96 + if(unlikely((c + 1) < (int)words))
97 irr->value[c] = strtoull(procfile_lineword(ff, l, (uint32_t)(c + 1)), NULL, 10);
98 else
99 irr->value[c] = 0;
@@ -111,12 +111,12 @@ int do_proc_softirqs(int update_every, unsigned long long dt) {
111 // --------------------------------------------------------------------
112
113 st = rrdset_find_bytype("system", "softirqs");
114 - if(!st) {
114 + if(unlikely(!st)) {
115 st = rrdset_create("system", "softirqs", NULL, "softirqs", NULL, "System softirqs", "softirqs/s", 950, update_every, RRDSET_TYPE_STACKED);
116
117 for(l = 0; l < lines ;l++) {
118 struct interrupt *irr = irrindex(irrs, l, cpus);
119 - if(!irr->used) continue;
119 + if(unlikely(!irr->used)) continue;
120 rrddim_add(st, irr->id, irr->name, 1, 1, RRDDIM_INCREMENTAL);
121 }
122 }
@@ -124,7 +124,7 @@ int do_proc_softirqs(int update_every, unsigned long long dt) {
124
125 for(l = 0; l < lines ;l++) {
126 struct interrupt *irr = irrindex(irrs, l, cpus);
127 - if(!irr->used) continue;
127 + if(unlikely(!irr->used)) continue;
128 rrddim_set(st, irr->id, irr->total);
129 }
130 rrdset_done(st);
@@ -137,15 +137,15 @@ int do_proc_softirqs(int update_every, unsigned long long dt) {
137 snprintfz(id, 50, "cpu%d_softirqs", c);
138
139 st = rrdset_find_bytype("cpu", id);
140 - if(!st) {
140 + if(unlikely(!st)) {
141 // find if everything is zero
142 unsigned long long core_sum = 0 ;
143 for(l = 0; l < lines ;l++) {
144 struct interrupt *irr = irrindex(irrs, l, cpus);
145 - if(!irr->used) continue;
145 + if(unlikely(!irr->used)) continue;
146 core_sum += irr->value[c];
147 }
148 - if(core_sum == 0) continue; // try next core
148 + if(unlikely(core_sum == 0)) continue; // try next core
149
150 char title[100+1];
151 snprintfz(title, 100, "CPU%d softirqs", c);
@@ -153,7 +153,7 @@ int do_proc_softirqs(int update_every, unsigned long long dt) {
153
154 for(l = 0; l < lines ;l++) {
155 struct interrupt *irr = irrindex(irrs, l, cpus);
156 - if(!irr->used) continue;
156 + if(unlikely(!irr->used)) continue;
157 rrddim_add(st, irr->id, irr->name, 1, 1, RRDDIM_INCREMENTAL);
158 }
159 }
@@ -161,7 +161,7 @@ int do_proc_softirqs(int update_every, unsigned long long dt) {
161
162 for(l = 0; l < lines ;l++) {
163 struct interrupt *irr = irrindex(irrs, l, cpus);
164 - if(!irr->used) continue;
164 + if(unlikely(!irr->used)) continue;
165 rrddim_set(st, irr->id, irr->value[c]);
166 }
167 rrdset_done(st);
src/proc_stat.c
+5 -5
@@ -126,7 +126,7 @@ int do_proc_stat(int update_every, unsigned long long dt) {
126 rrdset_done(st);
127 }
128 }
129 - else if(hash == hash_intr && strcmp(row_key, "intr") == 0) {
129 + else if(unlikely(hash == hash_intr && strcmp(row_key, "intr") == 0)) {
130 unsigned long long value = strtoull(procfile_lineword(ff, l, 1), NULL, 10);
131
132 // --------------------------------------------------------------------
@@ -145,7 +145,7 @@ int do_proc_stat(int update_every, unsigned long long dt) {
145 rrdset_done(st);
146 }
147 }
148 - else if(hash == hash_ctxt && strcmp(row_key, "ctxt") == 0) {
148 + else if(unlikely(hash == hash_ctxt && strcmp(row_key, "ctxt") == 0)) {
149 unsigned long long value = strtoull(procfile_lineword(ff, l, 1), NULL, 10);
150
151 // --------------------------------------------------------------------
@@ -163,13 +163,13 @@ int do_proc_stat(int update_every, unsigned long long dt) {
163 rrdset_done(st);
164 }
165 }
166 - else if(hash == hash_processes && !processes && strcmp(row_key, "processes") == 0) {
166 + else if(unlikely(hash == hash_processes && !processes && strcmp(row_key, "processes") == 0)) {
167 processes = strtoull(procfile_lineword(ff, l, 1), NULL, 10);
168 }
169 - else if(hash == hash_procs_running && !running && strcmp(row_key, "procs_running") == 0) {
169 + else if(unlikely(hash == hash_procs_running && !running && strcmp(row_key, "procs_running") == 0)) {
170 running = strtoull(procfile_lineword(ff, l, 1), NULL, 10);
171 }
172 - else if(hash == hash_procs_blocked && !blocked && strcmp(row_key, "procs_blocked") == 0) {
172 + else if(unlikely(hash == hash_procs_blocked && !blocked && strcmp(row_key, "procs_blocked") == 0)) {
173 blocked = strtoull(procfile_lineword(ff, l, 1), NULL, 10);
174 }
175 }
src/proc_sys_kernel_random_entropy_avail.c
+6 -6
@@ -1,24 +1,24 @@
1 #include "common.h"
2
3 int do_proc_sys_kernel_random_entropy_avail(int update_every, unsigned long long dt) {
4 - static procfile *ff = NULL;
4 + (void)dt;
5
6 - if(dt) {} ;
6 + static procfile *ff = NULL;
7
8 - if(!ff) {
8 + if(unlikely(!ff)) {
9 char filename[FILENAME_MAX + 1];
10 snprintfz(filename, FILENAME_MAX, "%s%s", global_host_prefix, "/proc/sys/kernel/random/entropy_avail");
11 ff = procfile_open(config_get("plugin:proc:/proc/sys/kernel/random/entropy_avail", "filename to monitor", filename), "", PROCFILE_FLAG_DEFAULT);
12 + if(unlikely(!ff)) return 1;
13 }
13 - if(!ff) return 1;
14
15 ff = procfile_readall(ff);
16 - if(!ff) return 0; // we return 0, so that we will retry to open it next time
16 + if(unlikely(!ff)) return 0; // we return 0, so that we will retry to open it next time
17
18 unsigned long long entropy = strtoull(procfile_lineword(ff, 0, 0), NULL, 10);
19
20 RRDSET *st = rrdset_find_bytype("system", "entropy");
21 - if(!st) {
21 + if(unlikely(!st)) {
22 st = rrdset_create("system", "entropy", NULL, "entropy", NULL, "Available Entropy", "entropy", 1000, update_every, RRDSET_TYPE_LINE);
23 rrddim_add(st, "entropy", NULL, 1, 1, RRDDIM_ABSOLUTE);
24 }
src/proc_vmstat.c
+202 -203
@@ -1,104 +1,109 @@
1 #include "common.h"
2
3 int do_proc_vmstat(int update_every, unsigned long long dt) {
4 + (void)dt;
5 +
6 static procfile *ff = NULL;
5 - static int do_swapio = -1, do_io = -1, do_pgfaults = -1, gen_hashes = -1;
7 + static int do_swapio = -1, do_io = -1, do_pgfaults = -1;
8 +
9 + // static uint32_t hash_allocstall = 0;
10 + // static uint32_t hash_compact_blocks_moved = 0;
11 + // static uint32_t hash_compact_fail = 0;
12 + // static uint32_t hash_compact_pagemigrate_failed = 0;
13 + // static uint32_t hash_compact_pages_moved = 0;
14 + // static uint32_t hash_compact_stall = 0;
15 + // static uint32_t hash_compact_success = 0;
16 + // static uint32_t hash_htlb_buddy_alloc_fail = 0;
17 + // static uint32_t hash_htlb_buddy_alloc_success = 0;
18 + // static uint32_t hash_kswapd_high_wmark_hit_quickly = 0;
19 + // static uint32_t hash_kswapd_inodesteal = 0;
20 + // static uint32_t hash_kswapd_low_wmark_hit_quickly = 0;
21 + // static uint32_t hash_kswapd_skip_congestion_wait = 0;
22 + // static uint32_t hash_nr_active_anon = 0;
23 + // static uint32_t hash_nr_active_file = 0;
24 + // static uint32_t hash_nr_anon_pages = 0;
25 + // static uint32_t hash_nr_anon_transparent_hugepages = 0;
26 + // static uint32_t hash_nr_bounce = 0;
27 + // static uint32_t hash_nr_dirtied = 0;
28 + // static uint32_t hash_nr_dirty = 0;
29 + // static uint32_t hash_nr_dirty_background_threshold = 0;
30 + // static uint32_t hash_nr_dirty_threshold = 0;
31 + // static uint32_t hash_nr_file_pages = 0;
32 + // static uint32_t hash_nr_free_pages = 0;
33 + // static uint32_t hash_nr_inactive_anon = 0;
34 + // static uint32_t hash_nr_inactive_file = 0;
35 + // static uint32_t hash_nr_isolated_anon = 0;
36 + // static uint32_t hash_nr_isolated_file = 0;
37 + // static uint32_t hash_nr_kernel_stack = 0;
38 + // static uint32_t hash_nr_mapped = 0;
39 + // static uint32_t hash_nr_mlock = 0;
40 + // static uint32_t hash_nr_page_table_pages = 0;
41 + // static uint32_t hash_nr_shmem = 0;
42 + // static uint32_t hash_nr_slab_reclaimable = 0;
43 + // static uint32_t hash_nr_slab_unreclaimable = 0;
44 + // static uint32_t hash_nr_unevictable = 0;
45 + // static uint32_t hash_nr_unstable = 0;
46 + // static uint32_t hash_nr_vmscan_immediate_reclaim = 0;
47 + // static uint32_t hash_nr_vmscan_write = 0;
48 + // static uint32_t hash_nr_writeback = 0;
49 + // static uint32_t hash_nr_writeback_temp = 0;
50 + // static uint32_t hash_nr_written = 0;
51 + // static uint32_t hash_pageoutrun = 0;
52 + // static uint32_t hash_pgactivate = 0;
53 + // static uint32_t hash_pgalloc_dma = 0;
54 + // static uint32_t hash_pgalloc_dma32 = 0;
55 + // static uint32_t hash_pgalloc_movable = 0;
56 + // static uint32_t hash_pgalloc_normal = 0;
57 + // static uint32_t hash_pgdeactivate = 0;
58 + static uint32_t hash_pgfault = 0;
59 + // static uint32_t hash_pgfree = 0;
60 + // static uint32_t hash_pginodesteal = 0;
61 + static uint32_t hash_pgmajfault = 0;
62 + static uint32_t hash_pgpgin = 0;
63 + static uint32_t hash_pgpgout = 0;
64 + // static uint32_t hash_pgrefill_dma = 0;
65 + // static uint32_t hash_pgrefill_dma32 = 0;
66 + // static uint32_t hash_pgrefill_movable = 0;
67 + // static uint32_t hash_pgrefill_normal = 0;
68 + // static uint32_t hash_pgrotated = 0;
69 + // static uint32_t hash_pgscan_direct_dma = 0;
70 + // static uint32_t hash_pgscan_direct_dma32 = 0;
71 + // static uint32_t hash_pgscan_direct_movable = 0;
72 + // static uint32_t hash_pgscan_direct_normal = 0;
73 + // static uint32_t hash_pgscan_kswapd_dma = 0;
74 + // static uint32_t hash_pgscan_kswapd_dma32 = 0;
75 + // static uint32_t hash_pgscan_kswapd_movable = 0;
76 + // static uint32_t hash_pgscan_kswapd_normal = 0;
77 + // static uint32_t hash_pgsteal_direct_dma = 0;
78 + // static uint32_t hash_pgsteal_direct_dma32 = 0;
79 + // static uint32_t hash_pgsteal_direct_movable = 0;
80 + // static uint32_t hash_pgsteal_direct_normal = 0;
81 + // static uint32_t hash_pgsteal_kswapd_dma = 0;
82 + // static uint32_t hash_pgsteal_kswapd_dma32 = 0;
83 + // static uint32_t hash_pgsteal_kswapd_movable = 0;
84 + // static uint32_t hash_pgsteal_kswapd_normal = 0;
85 + static uint32_t hash_pswpin = 0;
86 + static uint32_t hash_pswpout = 0;
87 + // static uint32_t hash_slabs_scanned = 0;
88 + // static uint32_t hash_thp_collapse_alloc = 0;
89 + // static uint32_t hash_thp_collapse_alloc_failed = 0;
90 + // static uint32_t hash_thp_fault_alloc = 0;
91 + // static uint32_t hash_thp_fault_fallback = 0;
92 + // static uint32_t hash_thp_split = 0;
93 + // static uint32_t hash_unevictable_pgs_cleared = 0;
94 + // static uint32_t hash_unevictable_pgs_culled = 0;
95 + // static uint32_t hash_unevictable_pgs_mlocked = 0;
96 + // static uint32_t hash_unevictable_pgs_mlockfreed = 0;
97 + // static uint32_t hash_unevictable_pgs_munlocked = 0;
98 + // static uint32_t hash_unevictable_pgs_rescued = 0;
99 + // static uint32_t hash_unevictable_pgs_scanned = 0;
100 + // static uint32_t hash_unevictable_pgs_stranded = 0;
101
7 - // static uint32_t hash_allocstall = -1;
8 - // static uint32_t hash_compact_blocks_moved = -1;
9 - // static uint32_t hash_compact_fail = -1;
10 - // static uint32_t hash_compact_pagemigrate_failed = -1;
11 - // static uint32_t hash_compact_pages_moved = -1;
12 - // static uint32_t hash_compact_stall = -1;
13 - // static uint32_t hash_compact_success = -1;
14 - // static uint32_t hash_htlb_buddy_alloc_fail = -1;
15 - // static uint32_t hash_htlb_buddy_alloc_success = -1;
16 - // static uint32_t hash_kswapd_high_wmark_hit_quickly = -1;
17 - // static uint32_t hash_kswapd_inodesteal = -1;
18 - // static uint32_t hash_kswapd_low_wmark_hit_quickly = -1;
19 - // static uint32_t hash_kswapd_skip_congestion_wait = -1;
20 - // static uint32_t hash_nr_active_anon = -1;
21 - // static uint32_t hash_nr_active_file = -1;
22 - // static uint32_t hash_nr_anon_pages = -1;
23 - // static uint32_t hash_nr_anon_transparent_hugepages = -1;
24 - // static uint32_t hash_nr_bounce = -1;
25 - // static uint32_t hash_nr_dirtied = -1;
26 - // static uint32_t hash_nr_dirty = -1;
27 - // static uint32_t hash_nr_dirty_background_threshold = -1;
28 - // static uint32_t hash_nr_dirty_threshold = -1;
29 - // static uint32_t hash_nr_file_pages = -1;
30 - // static uint32_t hash_nr_free_pages = -1;
31 - // static uint32_t hash_nr_inactive_anon = -1;
32 - // static uint32_t hash_nr_inactive_file = -1;
33 - // static uint32_t hash_nr_isolated_anon = -1;
34 - // static uint32_t hash_nr_isolated_file = -1;
35 - // static uint32_t hash_nr_kernel_stack = -1;
36 - // static uint32_t hash_nr_mapped = -1;
37 - // static uint32_t hash_nr_mlock = -1;
38 - // static uint32_t hash_nr_page_table_pages = -1;
39 - // static uint32_t hash_nr_shmem = -1;
40 - // static uint32_t hash_nr_slab_reclaimable = -1;
41 - // static uint32_t hash_nr_slab_unreclaimable = -1;
42 - // static uint32_t hash_nr_unevictable = -1;
43 - // static uint32_t hash_nr_unstable = -1;
44 - // static uint32_t hash_nr_vmscan_immediate_reclaim = -1;
45 - // static uint32_t hash_nr_vmscan_write = -1;
46 - // static uint32_t hash_nr_writeback = -1;
47 - // static uint32_t hash_nr_writeback_temp = -1;
48 - // static uint32_t hash_nr_written = -1;
49 - // static uint32_t hash_pageoutrun = -1;
50 - // static uint32_t hash_pgactivate = -1;
51 - // static uint32_t hash_pgalloc_dma = -1;
52 - // static uint32_t hash_pgalloc_dma32 = -1;
53 - // static uint32_t hash_pgalloc_movable = -1;
54 - // static uint32_t hash_pgalloc_normal = -1;
55 - // static uint32_t hash_pgdeactivate = -1;
56 - static uint32_t hash_pgfault = -1;
57 - // static uint32_t hash_pgfree = -1;
58 - // static uint32_t hash_pginodesteal = -1;
59 - static uint32_t hash_pgmajfault = -1;
60 - static uint32_t hash_pgpgin = -1;
61 - static uint32_t hash_pgpgout = -1;
62 - // static uint32_t hash_pgrefill_dma = -1;
63 - // static uint32_t hash_pgrefill_dma32 = -1;
64 - // static uint32_t hash_pgrefill_movable = -1;
65 - // static uint32_t hash_pgrefill_normal = -1;
66 - // static uint32_t hash_pgrotated = -1;
67 - // static uint32_t hash_pgscan_direct_dma = -1;
68 - // static uint32_t hash_pgscan_direct_dma32 = -1;
69 - // static uint32_t hash_pgscan_direct_movable = -1;
70 - // static uint32_t hash_pgscan_direct_normal = -1;
71 - // static uint32_t hash_pgscan_kswapd_dma = -1;
72 - // static uint32_t hash_pgscan_kswapd_dma32 = -1;
73 - // static uint32_t hash_pgscan_kswapd_movable = -1;
74 - // static uint32_t hash_pgscan_kswapd_normal = -1;
75 - // static uint32_t hash_pgsteal_direct_dma = -1;
76 - // static uint32_t hash_pgsteal_direct_dma32 = -1;
77 - // static uint32_t hash_pgsteal_direct_movable = -1;
78 - // static uint32_t hash_pgsteal_direct_normal = -1;
79 - // static uint32_t hash_pgsteal_kswapd_dma = -1;
80 - // static uint32_t hash_pgsteal_kswapd_dma32 = -1;
81 - // static uint32_t hash_pgsteal_kswapd_movable = -1;
82 - // static uint32_t hash_pgsteal_kswapd_normal = -1;
83 - static uint32_t hash_pswpin = -1;
84 - static uint32_t hash_pswpout = -1;
85 - // static uint32_t hash_slabs_scanned = -1;
86 - // static uint32_t hash_thp_collapse_alloc = -1;
87 - // static uint32_t hash_thp_collapse_alloc_failed = -1;
88 - // static uint32_t hash_thp_fault_alloc = -1;
89 - // static uint32_t hash_thp_fault_fallback = -1;
90 - // static uint32_t hash_thp_split = -1;
91 - // static uint32_t hash_unevictable_pgs_cleared = -1;
92 - // static uint32_t hash_unevictable_pgs_culled = -1;
93 - // static uint32_t hash_unevictable_pgs_mlocked = -1;
94 - // static uint32_t hash_unevictable_pgs_mlockfreed = -1;
95 - // static uint32_t hash_unevictable_pgs_munlocked = -1;
96 - // static uint32_t hash_unevictable_pgs_rescued = -1;
97 - // static uint32_t hash_unevictable_pgs_scanned = -1;
98 - // static uint32_t hash_unevictable_pgs_stranded = -1;
102 + if(unlikely(do_swapio == -1)) {
103 + do_swapio = config_get_boolean_ondemand("plugin:proc:/proc/vmstat", "swap i/o", CONFIG_ONDEMAND_ONDEMAND);
104 + do_io = config_get_boolean("plugin:proc:/proc/vmstat", "disk i/o", 1);
105 + do_pgfaults = config_get_boolean("plugin:proc:/proc/vmstat", "memory page faults", 1);
106
100 - if(gen_hashes != 1) {
101 - gen_hashes = 1;
107 // hash_allocstall = simple_hash("allocstall");
108 // hash_compact_blocks_moved = simple_hash("compact_blocks_moved");
109 // hash_compact_fail = simple_hash("compact_fail");
@@ -193,21 +198,15 @@ int do_proc_vmstat(int update_every, unsigned long long dt) {
198 // hash_unevictable_pgs_stranded = simple_hash("unevictable_pgs_stranded");
199 }
200
196 - if(do_swapio == -1) do_swapio = config_get_boolean_ondemand("plugin:proc:/proc/vmstat", "swap i/o", CONFIG_ONDEMAND_ONDEMAND);
197 - if(do_io == -1) do_io = config_get_boolean("plugin:proc:/proc/vmstat", "disk i/o", 1);
198 - if(do_pgfaults == -1) do_pgfaults = config_get_boolean("plugin:proc:/proc/vmstat", "memory page faults", 1);
199 -
200 - (void)dt;
201 -
202 - if(!ff) {
201 + if(unlikely(!ff)) {
202 char filename[FILENAME_MAX + 1];
203 snprintfz(filename, FILENAME_MAX, "%s%s", global_host_prefix, "/proc/vmstat");
204 ff = procfile_open(config_get("plugin:proc:/proc/vmstat", "filename to monitor", filename), " \t:", PROCFILE_FLAG_DEFAULT);
205 + if(unlikely(!ff)) return 1;
206 }
207 - if(!ff) return 1;
207
208 ff = procfile_readall(ff);
210 - if(!ff) return 0; // we return 0, so that we will retry to open it next time
209 + if(unlikely(!ff)) return 0; // we return 0, so that we will retry to open it next time
210
211 uint32_t lines = procfile_lines(ff), l;
212 uint32_t words;
@@ -307,110 +306,110 @@ int do_proc_vmstat(int update_every, unsigned long long dt) {
306
307 for(l = 0; l < lines ;l++) {
308 words = procfile_linewords(ff, l);
310 - if(words < 2) {
311 - if(words) error("Cannot read /proc/vmstat line %u. Expected 2 params, read %u.", l, words);
309 + if(unlikely(words < 2)) {
310 + if(unlikely(words)) error("Cannot read /proc/vmstat line %u. Expected 2 params, read %u.", l, words);
311 continue;
312 }
313
314 char *name = procfile_lineword(ff, l, 0);
315 char * value = procfile_lineword(ff, l, 1);
317 - if(!name || !*name || !value || !*value) continue;
316 + if(unlikely(!name || !*name || !value || !*value)) continue;
317
318 uint32_t hash = simple_hash(name);
319
321 - if(0) ;
322 - // else if(hash == hash_allocstall && strcmp(name, "allocstall") == 0) allocstall = strtoull(value, NULL, 10);
323 - // else if(hash == hash_compact_blocks_moved && strcmp(name, "compact_blocks_moved") == 0) compact_blocks_moved = strtoull(value, NULL, 10);
324 - // else if(hash == hash_compact_fail && strcmp(name, "compact_fail") == 0) compact_fail = strtoull(value, NULL, 10);
325 - // else if(hash == hash_compact_pagemigrate_failed && strcmp(name, "compact_pagemigrate_failed") == 0) compact_pagemigrate_failed = strtoull(value, NULL, 10);
326 - // else if(hash == hash_compact_pages_moved && strcmp(name, "compact_pages_moved") == 0) compact_pages_moved = strtoull(value, NULL, 10);
327 - // else if(hash == hash_compact_stall && strcmp(name, "compact_stall") == 0) compact_stall = strtoull(value, NULL, 10);
328 - // else if(hash == hash_compact_success && strcmp(name, "compact_success") == 0) compact_success = strtoull(value, NULL, 10);
329 - // else if(hash == hash_htlb_buddy_alloc_fail && strcmp(name, "htlb_buddy_alloc_fail") == 0) htlb_buddy_alloc_fail = strtoull(value, NULL, 10);
330 - // else if(hash == hash_htlb_buddy_alloc_success && strcmp(name, "htlb_buddy_alloc_success") == 0) htlb_buddy_alloc_success = strtoull(value, NULL, 10);
331 - // 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);
332 - // else if(hash == hash_kswapd_inodesteal && strcmp(name, "kswapd_inodesteal") == 0) kswapd_inodesteal = strtoull(value, NULL, 10);
333 - // 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);
334 - // else if(hash == hash_kswapd_skip_congestion_wait && strcmp(name, "kswapd_skip_congestion_wait") == 0) kswapd_skip_congestion_wait = strtoull(value, NULL, 10);
335 - // else if(hash == hash_nr_active_anon && strcmp(name, "nr_active_anon") == 0) nr_active_anon = strtoull(value, NULL, 10);
336 - // else if(hash == hash_nr_active_file && strcmp(name, "nr_active_file") == 0) nr_active_file = strtoull(value, NULL, 10);
337 - // else if(hash == hash_nr_anon_pages && strcmp(name, "nr_anon_pages") == 0) nr_anon_pages = strtoull(value, NULL, 10);
338 - // else if(hash == hash_nr_anon_transparent_hugepages && strcmp(name, "nr_anon_transparent_hugepages") == 0) nr_anon_transparent_hugepages = strtoull(value, NULL, 10);
339 - // else if(hash == hash_nr_bounce && strcmp(name, "nr_bounce") == 0) nr_bounce = strtoull(value, NULL, 10);
340 - // else if(hash == hash_nr_dirtied && strcmp(name, "nr_dirtied") == 0) nr_dirtied = strtoull(value, NULL, 10);
341 - // else if(hash == hash_nr_dirty && strcmp(name, "nr_dirty") == 0) nr_dirty = strtoull(value, NULL, 10);
342 - // else if(hash == hash_nr_dirty_background_threshold && strcmp(name, "nr_dirty_background_threshold") == 0) nr_dirty_background_threshold = strtoull(value, NULL, 10);
343 - // else if(hash == hash_nr_dirty_threshold && strcmp(name, "nr_dirty_threshold") == 0) nr_dirty_threshold = strtoull(value, NULL, 10);
344 - // else if(hash == hash_nr_file_pages && strcmp(name, "nr_file_pages") == 0) nr_file_pages = strtoull(value, NULL, 10);
345 - // else if(hash == hash_nr_free_pages && strcmp(name, "nr_free_pages") == 0) nr_free_pages = strtoull(value, NULL, 10);
346 - // else if(hash == hash_nr_inactive_anon && strcmp(name, "nr_inactive_anon") == 0) nr_inactive_anon = strtoull(value, NULL, 10);
347 - // else if(hash == hash_nr_inactive_file && strcmp(name, "nr_inactive_file") == 0) nr_inactive_file = strtoull(value, NULL, 10);
348 - // else if(hash == hash_nr_isolated_anon && strcmp(name, "nr_isolated_anon") == 0) nr_isolated_anon = strtoull(value, NULL, 10);
349 - // else if(hash == hash_nr_isolated_file && strcmp(name, "nr_isolated_file") == 0) nr_isolated_file = strtoull(value, NULL, 10);
350 - // else if(hash == hash_nr_kernel_stack && strcmp(name, "nr_kernel_stack") == 0) nr_kernel_stack = strtoull(value, NULL, 10);
351 - // else if(hash == hash_nr_mapped && strcmp(name, "nr_mapped") == 0) nr_mapped = strtoull(value, NULL, 10);
352 - // else if(hash == hash_nr_mlock && strcmp(name, "nr_mlock") == 0) nr_mlock = strtoull(value, NULL, 10);
353 - // else if(hash == hash_nr_page_table_pages && strcmp(name, "nr_page_table_pages") == 0) nr_page_table_pages = strtoull(value, NULL, 10);
354 - // else if(hash == hash_nr_shmem && strcmp(name, "nr_shmem") == 0) nr_shmem = strtoull(value, NULL, 10);
355 - // else if(hash == hash_nr_slab_reclaimable && strcmp(name, "nr_slab_reclaimable") == 0) nr_slab_reclaimable = strtoull(value, NULL, 10);
356 - // else if(hash == hash_nr_slab_unreclaimable && strcmp(name, "nr_slab_unreclaimable") == 0) nr_slab_unreclaimable = strtoull(value, NULL, 10);
357 - // else if(hash == hash_nr_unevictable && strcmp(name, "nr_unevictable") == 0) nr_unevictable = strtoull(value, NULL, 10);
358 - // else if(hash == hash_nr_unstable && strcmp(name, "nr_unstable") == 0) nr_unstable = strtoull(value, NULL, 10);
359 - // else if(hash == hash_nr_vmscan_immediate_reclaim && strcmp(name, "nr_vmscan_immediate_reclaim") == 0) nr_vmscan_immediate_reclaim = strtoull(value, NULL, 10);
360 - // else if(hash == hash_nr_vmscan_write && strcmp(name, "nr_vmscan_write") == 0) nr_vmscan_write = strtoull(value, NULL, 10);
361 - // else if(hash == hash_nr_writeback && strcmp(name, "nr_writeback") == 0) nr_writeback = strtoull(value, NULL, 10);
362 - // else if(hash == hash_nr_writeback_temp && strcmp(name, "nr_writeback_temp") == 0) nr_writeback_temp = strtoull(value, NULL, 10);
363 - // else if(hash == hash_nr_written && strcmp(name, "nr_written") == 0) nr_written = strtoull(value, NULL, 10);
364 - // else if(hash == hash_pageoutrun && strcmp(name, "pageoutrun") == 0) pageoutrun = strtoull(value, NULL, 10);
365 - // else if(hash == hash_pgactivate && strcmp(name, "pgactivate") == 0) pgactivate = strtoull(value, NULL, 10);
366 - // else if(hash == hash_pgalloc_dma && strcmp(name, "pgalloc_dma") == 0) pgalloc_dma = strtoull(value, NULL, 10);
367 - // else if(hash == hash_pgalloc_dma32 && strcmp(name, "pgalloc_dma32") == 0) pgalloc_dma32 = strtoull(value, NULL, 10);
368 - // else if(hash == hash_pgalloc_movable && strcmp(name, "pgalloc_movable") == 0) pgalloc_movable = strtoull(value, NULL, 10);
369 - // else if(hash == hash_pgalloc_normal && strcmp(name, "pgalloc_normal") == 0) pgalloc_normal = strtoull(value, NULL, 10);
370 - // else if(hash == hash_pgdeactivate && strcmp(name, "pgdeactivate") == 0) pgdeactivate = strtoull(value, NULL, 10);
371 - else if(hash == hash_pgfault && strcmp(name, "pgfault") == 0) pgfault = strtoull(value, NULL, 10);
372 - // else if(hash == hash_pgfree && strcmp(name, "pgfree") == 0) pgfree = strtoull(value, NULL, 10);
373 - // else if(hash == hash_pginodesteal && strcmp(name, "pginodesteal") == 0) pginodesteal = strtoull(value, NULL, 10);
374 - else if(hash == hash_pgmajfault && strcmp(name, "pgmajfault") == 0) pgmajfault = strtoull(value, NULL, 10);
375 - else if(hash == hash_pgpgin && strcmp(name, "pgpgin") == 0) pgpgin = strtoull(value, NULL, 10);
376 - else if(hash == hash_pgpgout && strcmp(name, "pgpgout") == 0) pgpgout = strtoull(value, NULL, 10);
377 - // else if(hash == hash_pgrefill_dma && strcmp(name, "pgrefill_dma") == 0) pgrefill_dma = strtoull(value, NULL, 10);
378 - // else if(hash == hash_pgrefill_dma32 && strcmp(name, "pgrefill_dma32") == 0) pgrefill_dma32 = strtoull(value, NULL, 10);
379 - // else if(hash == hash_pgrefill_movable && strcmp(name, "pgrefill_movable") == 0) pgrefill_movable = strtoull(value, NULL, 10);
380 - // else if(hash == hash_pgrefill_normal && strcmp(name, "pgrefill_normal") == 0) pgrefill_normal = strtoull(value, NULL, 10);
381 - // else if(hash == hash_pgrotated && strcmp(name, "pgrotated") == 0) pgrotated = strtoull(value, NULL, 10);
382 - // else if(hash == hash_pgscan_direct_dma && strcmp(name, "pgscan_direct_dma") == 0) pgscan_direct_dma = strtoull(value, NULL, 10);
383 - // else if(hash == hash_pgscan_direct_dma32 && strcmp(name, "pgscan_direct_dma32") == 0) pgscan_direct_dma32 = strtoull(value, NULL, 10);
384 - // else if(hash == hash_pgscan_direct_movable && strcmp(name, "pgscan_direct_movable") == 0) pgscan_direct_movable = strtoull(value, NULL, 10);
385 - // else if(hash == hash_pgscan_direct_normal && strcmp(name, "pgscan_direct_normal") == 0) pgscan_direct_normal = strtoull(value, NULL, 10);
386 - // else if(hash == hash_pgscan_kswapd_dma && strcmp(name, "pgscan_kswapd_dma") == 0) pgscan_kswapd_dma = strtoull(value, NULL, 10);
387 - // else if(hash == hash_pgscan_kswapd_dma32 && strcmp(name, "pgscan_kswapd_dma32") == 0) pgscan_kswapd_dma32 = strtoull(value, NULL, 10);
388 - // else if(hash == hash_pgscan_kswapd_movable && strcmp(name, "pgscan_kswapd_movable") == 0) pgscan_kswapd_movable = strtoull(value, NULL, 10);
389 - // else if(hash == hash_pgscan_kswapd_normal && strcmp(name, "pgscan_kswapd_normal") == 0) pgscan_kswapd_normal = strtoull(value, NULL, 10);
390 - // else if(hash == hash_pgsteal_direct_dma && strcmp(name, "pgsteal_direct_dma") == 0) pgsteal_direct_dma = strtoull(value, NULL, 10);
391 - // else if(hash == hash_pgsteal_direct_dma32 && strcmp(name, "pgsteal_direct_dma32") == 0) pgsteal_direct_dma32 = strtoull(value, NULL, 10);
392 - // else if(hash == hash_pgsteal_direct_movable && strcmp(name, "pgsteal_direct_movable") == 0) pgsteal_direct_movable = strtoull(value, NULL, 10);
393 - // else if(hash == hash_pgsteal_direct_normal && strcmp(name, "pgsteal_direct_normal") == 0) pgsteal_direct_normal = strtoull(value, NULL, 10);
394 - // else if(hash == hash_pgsteal_kswapd_dma && strcmp(name, "pgsteal_kswapd_dma") == 0) pgsteal_kswapd_dma = strtoull(value, NULL, 10);
395 - // else if(hash == hash_pgsteal_kswapd_dma32 && strcmp(name, "pgsteal_kswapd_dma32") == 0) pgsteal_kswapd_dma32 = strtoull(value, NULL, 10);
396 - // else if(hash == hash_pgsteal_kswapd_movable && strcmp(name, "pgsteal_kswapd_movable") == 0) pgsteal_kswapd_movable = strtoull(value, NULL, 10);
397 - // else if(hash == hash_pgsteal_kswapd_normal && strcmp(name, "pgsteal_kswapd_normal") == 0) pgsteal_kswapd_normal = strtoull(value, NULL, 10);
398 - else if(hash == hash_pswpin && strcmp(name, "pswpin") == 0) pswpin = strtoull(value, NULL, 10);
399 - else if(hash == hash_pswpout && strcmp(name, "pswpout") == 0) pswpout = strtoull(value, NULL, 10);
400 - // else if(hash == hash_slabs_scanned && strcmp(name, "slabs_scanned") == 0) slabs_scanned = strtoull(value, NULL, 10);
401 - // else if(hash == hash_thp_collapse_alloc && strcmp(name, "thp_collapse_alloc") == 0) thp_collapse_alloc = strtoull(value, NULL, 10);
402 - // else if(hash == hash_thp_collapse_alloc_failed && strcmp(name, "thp_collapse_alloc_failed") == 0) thp_collapse_alloc_failed = strtoull(value, NULL, 10);
403 - // else if(hash == hash_thp_fault_alloc && strcmp(name, "thp_fault_alloc") == 0) thp_fault_alloc = strtoull(value, NULL, 10);
404 - // else if(hash == hash_thp_fault_fallback && strcmp(name, "thp_fault_fallback") == 0) thp_fault_fallback = strtoull(value, NULL, 10);
405 - // else if(hash == hash_thp_split && strcmp(name, "thp_split") == 0) thp_split = strtoull(value, NULL, 10);
406 - // else if(hash == hash_unevictable_pgs_cleared && strcmp(name, "unevictable_pgs_cleared") == 0) unevictable_pgs_cleared = strtoull(value, NULL, 10);
407 - // else if(hash == hash_unevictable_pgs_culled && strcmp(name, "unevictable_pgs_culled") == 0) unevictable_pgs_culled = strtoull(value, NULL, 10);
408 - // else if(hash == hash_unevictable_pgs_mlocked && strcmp(name, "unevictable_pgs_mlocked") == 0) unevictable_pgs_mlocked = strtoull(value, NULL, 10);
409 - // else if(hash == hash_unevictable_pgs_mlockfreed && strcmp(name, "unevictable_pgs_mlockfreed") == 0) unevictable_pgs_mlockfreed = strtoull(value, NULL, 10);
410 - // else if(hash == hash_unevictable_pgs_munlocked && strcmp(name, "unevictable_pgs_munlocked") == 0) unevictable_pgs_munlocked = strtoull(value, NULL, 10);
411 - // else if(hash == hash_unevictable_pgs_rescued && strcmp(name, "unevictable_pgs_rescued") == 0) unevictable_pgs_rescued = strtoull(value, NULL, 10);
412 - // else if(hash == hash_unevictable_pgs_scanned && strcmp(name, "unevictable_pgs_scanned") == 0) unevictable_pgs_scanned = strtoull(value, NULL, 10);
413 - // else if(hash == hash_unevictable_pgs_stranded && strcmp(name, "unevictable_pgs_stranded") == 0) unevictable_pgs_stranded = strtoull(value, NULL, 10);
320 + if(unlikely(0)) ;
321 + // else if(unlikely(hash == hash_allocstall && strcmp(name, "allocstall") == 0)) allocstall = strtoull(value, NULL, 10);
322 + // else if(unlikely(hash == hash_compact_blocks_moved && strcmp(name, "compact_blocks_moved") == 0)) compact_blocks_moved = strtoull(value, NULL, 10);
323 + // else if(unlikely(hash == hash_compact_fail && strcmp(name, "compact_fail") == 0)) compact_fail = strtoull(value, NULL, 10);
324 + // else if(unlikely(hash == hash_compact_pagemigrate_failed && strcmp(name, "compact_pagemigrate_failed") == 0)) compact_pagemigrate_failed = strtoull(value, NULL, 10);
325 + // else if(unlikely(hash == hash_compact_pages_moved && strcmp(name, "compact_pages_moved") == 0)) compact_pages_moved = strtoull(value, NULL, 10);
326 + // else if(unlikely(hash == hash_compact_stall && strcmp(name, "compact_stall") == 0)) compact_stall = strtoull(value, NULL, 10);
327 + // else if(unlikely(hash == hash_compact_success && strcmp(name, "compact_success") == 0)) compact_success = strtoull(value, NULL, 10);
328 + // else if(unlikely(hash == hash_htlb_buddy_alloc_fail && strcmp(name, "htlb_buddy_alloc_fail") == 0)) htlb_buddy_alloc_fail = strtoull(value, NULL, 10);
329 + // else if(unlikely(hash == hash_htlb_buddy_alloc_success && strcmp(name, "htlb_buddy_alloc_success") == 0)) htlb_buddy_alloc_success = strtoull(value, NULL, 10);
330 + // 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);
331 + // else if(unlikely(hash == hash_kswapd_inodesteal && strcmp(name, "kswapd_inodesteal") == 0)) kswapd_inodesteal = strtoull(value, NULL, 10);
332 + // 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);
333 + // else if(unlikely(hash == hash_kswapd_skip_congestion_wait && strcmp(name, "kswapd_skip_congestion_wait") == 0)) kswapd_skip_congestion_wait = strtoull(value, NULL, 10);
334 + // else if(unlikely(hash == hash_nr_active_anon && strcmp(name, "nr_active_anon") == 0)) nr_active_anon = strtoull(value, NULL, 10);
335 + // else if(unlikely(hash == hash_nr_active_file && strcmp(name, "nr_active_file") == 0)) nr_active_file = strtoull(value, NULL, 10);
336 + // else if(unlikely(hash == hash_nr_anon_pages && strcmp(name, "nr_anon_pages") == 0)) nr_anon_pages = strtoull(value, NULL, 10);
337 + // else if(unlikely(hash == hash_nr_anon_transparent_hugepages && strcmp(name, "nr_anon_transparent_hugepages") == 0)) nr_anon_transparent_hugepages = strtoull(value, NULL, 10);
338 + // else if(unlikely(hash == hash_nr_bounce && strcmp(name, "nr_bounce") == 0)) nr_bounce = strtoull(value, NULL, 10);
339 + // else if(unlikely(hash == hash_nr_dirtied && strcmp(name, "nr_dirtied") == 0)) nr_dirtied = strtoull(value, NULL, 10);
340 + // else if(unlikely(hash == hash_nr_dirty && strcmp(name, "nr_dirty") == 0)) nr_dirty = strtoull(value, NULL, 10);
341 + // else if(unlikely(hash == hash_nr_dirty_background_threshold && strcmp(name, "nr_dirty_background_threshold") == 0)) nr_dirty_background_threshold = strtoull(value, NULL, 10);
342 + // else if(unlikely(hash == hash_nr_dirty_threshold && strcmp(name, "nr_dirty_threshold") == 0)) nr_dirty_threshold = strtoull(value, NULL, 10);
343 + // else if(unlikely(hash == hash_nr_file_pages && strcmp(name, "nr_file_pages") == 0)) nr_file_pages = strtoull(value, NULL, 10);
344 + // else if(unlikely(hash == hash_nr_free_pages && strcmp(name, "nr_free_pages") == 0)) nr_free_pages = strtoull(value, NULL, 10);
345 + // else if(unlikely(hash == hash_nr_inactive_anon && strcmp(name, "nr_inactive_anon") == 0)) nr_inactive_anon = strtoull(value, NULL, 10);
346 + // else if(unlikely(hash == hash_nr_inactive_file && strcmp(name, "nr_inactive_file") == 0)) nr_inactive_file = strtoull(value, NULL, 10);
347 + // else if(unlikely(hash == hash_nr_isolated_anon && strcmp(name, "nr_isolated_anon") == 0)) nr_isolated_anon = strtoull(value, NULL, 10);
348 + // else if(unlikely(hash == hash_nr_isolated_file && strcmp(name, "nr_isolated_file") == 0)) nr_isolated_file = strtoull(value, NULL, 10);
349 + // else if(unlikely(hash == hash_nr_kernel_stack && strcmp(name, "nr_kernel_stack") == 0)) nr_kernel_stack = strtoull(value, NULL, 10);
350 + // else if(unlikely(hash == hash_nr_mapped && strcmp(name, "nr_mapped") == 0)) nr_mapped = strtoull(value, NULL, 10);
351 + // else if(unlikely(hash == hash_nr_mlock && strcmp(name, "nr_mlock") == 0)) nr_mlock = strtoull(value, NULL, 10);
352 + // else if(unlikely(hash == hash_nr_page_table_pages && strcmp(name, "nr_page_table_pages") == 0)) nr_page_table_pages = strtoull(value, NULL, 10);
353 + // else if(unlikely(hash == hash_nr_shmem && strcmp(name, "nr_shmem") == 0)) nr_shmem = strtoull(value, NULL, 10);
354 + // else if(unlikely(hash == hash_nr_slab_reclaimable && strcmp(name, "nr_slab_reclaimable") == 0)) nr_slab_reclaimable = strtoull(value, NULL, 10);
355 + // else if(unlikely(hash == hash_nr_slab_unreclaimable && strcmp(name, "nr_slab_unreclaimable") == 0)) nr_slab_unreclaimable = strtoull(value, NULL, 10);
356 + // else if(unlikely(hash == hash_nr_unevictable && strcmp(name, "nr_unevictable") == 0)) nr_unevictable = strtoull(value, NULL, 10);
357 + // else if(unlikely(hash == hash_nr_unstable && strcmp(name, "nr_unstable") == 0)) nr_unstable = strtoull(value, NULL, 10);
358 + // else if(unlikely(hash == hash_nr_vmscan_immediate_reclaim && strcmp(name, "nr_vmscan_immediate_reclaim") == 0)) nr_vmscan_immediate_reclaim = strtoull(value, NULL, 10);
359 + // else if(unlikely(hash == hash_nr_vmscan_write && strcmp(name, "nr_vmscan_write") == 0)) nr_vmscan_write = strtoull(value, NULL, 10);
360 + // else if(unlikely(hash == hash_nr_writeback && strcmp(name, "nr_writeback") == 0)) nr_writeback = strtoull(value, NULL, 10);
361 + // else if(unlikely(hash == hash_nr_writeback_temp && strcmp(name, "nr_writeback_temp") == 0)) nr_writeback_temp = strtoull(value, NULL, 10);
362 + // else if(unlikely(hash == hash_nr_written && strcmp(name, "nr_written") == 0)) nr_written = strtoull(value, NULL, 10);
363 + // else if(unlikely(hash == hash_pageoutrun && strcmp(name, "pageoutrun") == 0)) pageoutrun = strtoull(value, NULL, 10);
364 + // else if(unlikely(hash == hash_pgactivate && strcmp(name, "pgactivate") == 0)) pgactivate = strtoull(value, NULL, 10);
365 + // else if(unlikely(hash == hash_pgalloc_dma && strcmp(name, "pgalloc_dma") == 0)) pgalloc_dma = strtoull(value, NULL, 10);
366 + // else if(unlikely(hash == hash_pgalloc_dma32 && strcmp(name, "pgalloc_dma32") == 0)) pgalloc_dma32 = strtoull(value, NULL, 10);
367 + // else if(unlikely(hash == hash_pgalloc_movable && strcmp(name, "pgalloc_movable") == 0)) pgalloc_movable = strtoull(value, NULL, 10);
368 + // else if(unlikely(hash == hash_pgalloc_normal && strcmp(name, "pgalloc_normal") == 0)) pgalloc_normal = strtoull(value, NULL, 10);
369 + // else if(unlikely(hash == hash_pgdeactivate && strcmp(name, "pgdeactivate") == 0)) pgdeactivate = strtoull(value, NULL, 10);
370 + else if(unlikely(hash == hash_pgfault && strcmp(name, "pgfault") == 0)) pgfault = strtoull(value, NULL, 10);
371 + // else if(unlikely(hash == hash_pgfree && strcmp(name, "pgfree") == 0)) pgfree = strtoull(value, NULL, 10);
372 + // else if(unlikely(hash == hash_pginodesteal && strcmp(name, "pginodesteal") == 0)) pginodesteal = strtoull(value, NULL, 10);
373 + else if(unlikely(hash == hash_pgmajfault && strcmp(name, "pgmajfault") == 0)) pgmajfault = strtoull(value, NULL, 10);
374 + else if(unlikely(hash == hash_pgpgin && strcmp(name, "pgpgin") == 0)) pgpgin = strtoull(value, NULL, 10);
375 + else if(unlikely(hash == hash_pgpgout && strcmp(name, "pgpgout") == 0)) pgpgout = strtoull(value, NULL, 10);
376 + // else if(unlikely(hash == hash_pgrefill_dma && strcmp(name, "pgrefill_dma") == 0)) pgrefill_dma = strtoull(value, NULL, 10);
377 + // else if(unlikely(hash == hash_pgrefill_dma32 && strcmp(name, "pgrefill_dma32") == 0)) pgrefill_dma32 = strtoull(value, NULL, 10);
378 + // else if(unlikely(hash == hash_pgrefill_movable && strcmp(name, "pgrefill_movable") == 0)) pgrefill_movable = strtoull(value, NULL, 10);
379 + // else if(unlikely(hash == hash_pgrefill_normal && strcmp(name, "pgrefill_normal") == 0)) pgrefill_normal = strtoull(value, NULL, 10);
380 + // else if(unlikely(hash == hash_pgrotated && strcmp(name, "pgrotated") == 0)) pgrotated = strtoull(value, NULL, 10);
381 + // else if(unlikely(hash == hash_pgscan_direct_dma && strcmp(name, "pgscan_direct_dma") == 0)) pgscan_direct_dma = strtoull(value, NULL, 10);
382 + // else if(unlikely(hash == hash_pgscan_direct_dma32 && strcmp(name, "pgscan_direct_dma32") == 0)) pgscan_direct_dma32 = strtoull(value, NULL, 10);
383 + // else if(unlikely(hash == hash_pgscan_direct_movable && strcmp(name, "pgscan_direct_movable") == 0)) pgscan_direct_movable = strtoull(value, NULL, 10);
384 + // else if(unlikely(hash == hash_pgscan_direct_normal && strcmp(name, "pgscan_direct_normal") == 0)) pgscan_direct_normal = strtoull(value, NULL, 10);
385 + // else if(unlikely(hash == hash_pgscan_kswapd_dma && strcmp(name, "pgscan_kswapd_dma") == 0)) pgscan_kswapd_dma = strtoull(value, NULL, 10);
386 + // else if(unlikely(hash == hash_pgscan_kswapd_dma32 && strcmp(name, "pgscan_kswapd_dma32") == 0)) pgscan_kswapd_dma32 = strtoull(value, NULL, 10);
387 + // else if(unlikely(hash == hash_pgscan_kswapd_movable && strcmp(name, "pgscan_kswapd_movable") == 0)) pgscan_kswapd_movable = strtoull(value, NULL, 10);
388 + // else if(unlikely(hash == hash_pgscan_kswapd_normal && strcmp(name, "pgscan_kswapd_normal") == 0)) pgscan_kswapd_normal = strtoull(value, NULL, 10);
389 + // else if(unlikely(hash == hash_pgsteal_direct_dma && strcmp(name, "pgsteal_direct_dma") == 0)) pgsteal_direct_dma = strtoull(value, NULL, 10);
390 + // else if(unlikely(hash == hash_pgsteal_direct_dma32 && strcmp(name, "pgsteal_direct_dma32") == 0)) pgsteal_direct_dma32 = strtoull(value, NULL, 10);
391 + // else if(unlikely(hash == hash_pgsteal_direct_movable && strcmp(name, "pgsteal_direct_movable") == 0)) pgsteal_direct_movable = strtoull(value, NULL, 10);
392 + // else if(unlikely(hash == hash_pgsteal_direct_normal && strcmp(name, "pgsteal_direct_normal") == 0)) pgsteal_direct_normal = strtoull(value, NULL, 10);
393 + // else if(unlikely(hash == hash_pgsteal_kswapd_dma && strcmp(name, "pgsteal_kswapd_dma") == 0)) pgsteal_kswapd_dma = strtoull(value, NULL, 10);
394 + // else if(unlikely(hash == hash_pgsteal_kswapd_dma32 && strcmp(name, "pgsteal_kswapd_dma32") == 0)) pgsteal_kswapd_dma32 = strtoull(value, NULL, 10);
395 + // else if(unlikely(hash == hash_pgsteal_kswapd_movable && strcmp(name, "pgsteal_kswapd_movable") == 0)) pgsteal_kswapd_movable = strtoull(value, NULL, 10);
396 + // else if(unlikely(hash == hash_pgsteal_kswapd_normal && strcmp(name, "pgsteal_kswapd_normal") == 0)) pgsteal_kswapd_normal = strtoull(value, NULL, 10);
397 + else if(unlikely(hash == hash_pswpin && strcmp(name, "pswpin") == 0)) pswpin = strtoull(value, NULL, 10);
398 + else if(unlikely(hash == hash_pswpout && strcmp(name, "pswpout") == 0)) pswpout = strtoull(value, NULL, 10);
399 + // else if(unlikely(hash == hash_slabs_scanned && strcmp(name, "slabs_scanned") == 0)) slabs_scanned = strtoull(value, NULL, 10);
400 + // else if(unlikely(hash == hash_thp_collapse_alloc && strcmp(name, "thp_collapse_alloc") == 0)) thp_collapse_alloc = strtoull(value, NULL, 10);
401 + // else if(unlikely(hash == hash_thp_collapse_alloc_failed && strcmp(name, "thp_collapse_alloc_failed") == 0)) thp_collapse_alloc_failed = strtoull(value, NULL, 10);
402 + // else if(unlikely(hash == hash_thp_fault_alloc && strcmp(name, "thp_fault_alloc") == 0)) thp_fault_alloc = strtoull(value, NULL, 10);
403 + // else if(unlikely(hash == hash_thp_fault_fallback && strcmp(name, "thp_fault_fallback") == 0)) thp_fault_fallback = strtoull(value, NULL, 10);
404 + // else if(unlikely(hash == hash_thp_split && strcmp(name, "thp_split") == 0)) thp_split = strtoull(value, NULL, 10);
405 + // else if(unlikely(hash == hash_unevictable_pgs_cleared && strcmp(name, "unevictable_pgs_cleared") == 0)) unevictable_pgs_cleared = strtoull(value, NULL, 10);
406 + // else if(unlikely(hash == hash_unevictable_pgs_culled && strcmp(name, "unevictable_pgs_culled") == 0)) unevictable_pgs_culled = strtoull(value, NULL, 10);
407 + // else if(unlikely(hash == hash_unevictable_pgs_mlocked && strcmp(name, "unevictable_pgs_mlocked") == 0)) unevictable_pgs_mlocked = strtoull(value, NULL, 10);
408 + // else if(unlikely(hash == hash_unevictable_pgs_mlockfreed && strcmp(name, "unevictable_pgs_mlockfreed") == 0)) unevictable_pgs_mlockfreed = strtoull(value, NULL, 10);
409 + // else if(unlikely(hash == hash_unevictable_pgs_munlocked && strcmp(name, "unevictable_pgs_munlocked") == 0)) unevictable_pgs_munlocked = strtoull(value, NULL, 10);
410 + // else if(unlikely(hash == hash_unevictable_pgs_rescued && strcmp(name, "unevictable_pgs_rescued") == 0)) unevictable_pgs_rescued = strtoull(value, NULL, 10);
411 + // else if(unlikely(hash == hash_unevictable_pgs_scanned && strcmp(name, "unevictable_pgs_scanned") == 0)) unevictable_pgs_scanned = strtoull(value, NULL, 10);
412 + // else if(unlikely(hash == hash_unevictable_pgs_stranded && strcmp(name, "unevictable_pgs_stranded") == 0)) unevictable_pgs_stranded = strtoull(value, NULL, 10);
413 }
414
415 // --------------------------------------------------------------------
@@ -419,7 +418,7 @@ int do_proc_vmstat(int update_every, unsigned long long dt) {
418 do_swapio = CONFIG_ONDEMAND_YES;
419
420 static RRDSET *st_swapio = NULL;
422 - if(!st_swapio) {
421 + if(unlikely(!st_swapio)) {
422 st_swapio = rrdset_create("system", "swapio", NULL, "swap", NULL, "Swap I/O", "kilobytes/s", 250, update_every, RRDSET_TYPE_AREA);
423
424 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) {
435
436 if(do_io) {
437 static RRDSET *st_io = NULL;
439 - if(!st_io) {
438 + if(unlikely(!st_io)) {
439 st_io = rrdset_create("system", "io", NULL, "disk", NULL, "Disk I/O", "kilobytes/s", 150, update_every, RRDSET_TYPE_AREA);
440
441 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) {
452
453 if(do_pgfaults) {
454 static RRDSET *st_pgfaults = NULL;
456 - if(!st_pgfaults) {
455 + if(unlikely(!st_pgfaults)) {
456 st_pgfaults = rrdset_create("mem", "pgfaults", NULL, "system", NULL, "Memory Page Faults", "page faults/s", 500, update_every, RRDSET_TYPE_LINE);
457 st_pgfaults->isdetail = 1;
458
src/procfile.c
+3 -3
@@ -274,7 +274,7 @@ procfile *procfile_readall(procfile *ff) {
274 s = ff->len;
275 x = ff->size - s;
276
277 - if(!x) {
277 + if(unlikely(!x)) {
278 debug(D_PROCFILE, PF_PREFIX ": Expanding data buffer for file '%s'.", ff->filename);
279
280 ff = reallocz(ff, sizeof(procfile) + ff->size + PROCFILE_INCREMENT_BUFFER);
@@ -348,7 +348,7 @@ void procfile_set_quotes(procfile *ff, const char *quotes) {
348 // remove all quotes
349 int i;
350 for(i = 0; i < 256 ; i++)
351 - if(ff->separators[i] == PF_CHAR_IS_QUOTE)
351 + if(unlikely(ff->separators[i] == PF_CHAR_IS_QUOTE))
352 ff->separators[i] = PF_CHAR_IS_WORD;
353
354 // if nothing given, return
@@ -366,7 +366,7 @@ void procfile_set_open_close(procfile *ff, const char *open, const char *close)
366 // remove all open/close
367 int i;
368 for(i = 0; i < 256 ; i++)
369 - if(ff->separators[i] == PF_CHAR_IS_OPEN || ff->separators[i] == PF_CHAR_IS_CLOSE)
369 + if(unlikely(ff->separators[i] == PF_CHAR_IS_OPEN || ff->separators[i] == PF_CHAR_IS_CLOSE))
370 ff->separators[i] = PF_CHAR_IS_WORD;
371
372 // if nothing given, return
src/unit_test.c
+2 -2
@@ -915,7 +915,7 @@ int run_test(struct test *test)
915 (float)time_now / 1000000.0,
916 ((calculated_number)test->feed[c].value - (calculated_number)last) * (calculated_number)test->multiplier / (calculated_number)test->divisor,
917 (((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);
918 - rrdset_next_usec(st, test->feed[c].microseconds);
918 + rrdset_next_usec_unfiltered(st, test->feed[c].microseconds);
919 }
920 else {
921 fprintf(stderr, " > %s: feeding position %lu\n", test->name, c+1);
@@ -1073,7 +1073,7 @@ int unit_test(long delay, long shift)
1073
1074 fprintf(stderr, "\n\nLOOP = %lu, DELAY = %ld, VALUE = " COLLECTED_NUMBER_FORMAT "\n", c, delay, i);
1075 if(c) {
1076 - rrdset_next_usec(st, delay);
1076 + rrdset_next_usec_unfiltered(st, delay);
1077 }
1078 if(do_abs) rrddim_set(st, "absolute", i);
1079 if(do_inc) rrddim_set(st, "incremental", i);