X-Git-Url: https://arthur.barton.de/gitweb/?a=blobdiff_plain;f=src%2Fproc_sys_kernel_random_entropy_avail.c;h=fea8900d33cc7ef0c89fbc3a81e3da4b1e9db575;hb=9dccc16d3763392f0b13349de18c3a838a667653;hp=b576968b0240e1b561669dfcedb947b5d8df9a03;hpb=6372ed837298a34f6d16e0cde929822879863195;p=netdata.git diff --git a/src/proc_sys_kernel_random_entropy_avail.c b/src/proc_sys_kernel_random_entropy_avail.c old mode 100755 new mode 100644 index b576968b..fea8900d --- a/src/proc_sys_kernel_random_entropy_avail.c +++ b/src/proc_sys_kernel_random_entropy_avail.c @@ -1,41 +1,32 @@ -#ifdef HAVE_CONFIG_H -#include -#endif -#include -#include - #include "common.h" -#include "appconfig.h" -#include "procfile.h" -#include "rrd.h" -#include "plugin_proc.h" -int do_proc_sys_kernel_random_entropy_avail(int update_every, unsigned long long dt) { - static procfile *ff = NULL; +int do_proc_sys_kernel_random_entropy_avail(int update_every, usec_t dt) { + (void)dt; - if(dt) {} ; + static procfile *ff = NULL; - if(!ff) { - char filename[FILENAME_MAX + 1]; - snprintf(filename, FILENAME_MAX, "%s%s", global_host_prefix, "/proc/sys/kernel/random/entropy_avail"); - ff = procfile_open(config_get("plugin:proc:/proc/sys/kernel/random/entropy_avail", "filename to monitor", filename), "", PROCFILE_FLAG_DEFAULT); - } - if(!ff) return 1; + if(unlikely(!ff)) { + char filename[FILENAME_MAX + 1]; + snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/proc/sys/kernel/random/entropy_avail"); + ff = procfile_open(config_get("plugin:proc:/proc/sys/kernel/random/entropy_avail", "filename to monitor", filename), "", PROCFILE_FLAG_DEFAULT); + if(unlikely(!ff)) return 1; + } - ff = procfile_readall(ff); - if(!ff) return 0; // we return 0, so that we will retry to open it next time + ff = procfile_readall(ff); + if(unlikely(!ff)) return 0; // we return 0, so that we will retry to open it next time - unsigned long long entropy = strtoull(procfile_lineword(ff, 0, 0), NULL, 10); + unsigned long long entropy = str2ull(procfile_lineword(ff, 0, 0)); - RRDSET *st = rrdset_find_bytype("system", "entropy"); - if(!st) { - st = rrdset_create("system", "entropy", NULL, "system", "Available Entropy", "entropy", 1000, update_every, RRDSET_TYPE_LINE); - rrddim_add(st, "entropy", NULL, 1, 1, RRDDIM_ABSOLUTE); - } - else rrdset_next(st); + RRDSET *st = rrdset_find_bytype_localhost("system", "entropy"); + if(unlikely(!st)) { + st = rrdset_create_localhost("system", "entropy", NULL, "entropy", NULL, "Available Entropy", "entropy", 1000 + , update_every, RRDSET_TYPE_LINE); + rrddim_add(st, "entropy", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); + } + else rrdset_next(st); - rrddim_set(st, "entropy", entropy); - rrdset_done(st); + rrddim_set(st, "entropy", entropy); + rrdset_done(st); - return 0; + return 0; }