]> arthur.barton.de Git - netdata.git/blob - src/proc_sys_kernel_random_entropy_avail.c
added more fping alarms; added the ability to have alarms that never send CLEAR notif...
[netdata.git] / src / proc_sys_kernel_random_entropy_avail.c
1 #include "common.h"
2
3 int do_proc_sys_kernel_random_entropy_avail(int update_every, usec_t dt) {
4     (void)dt;
5
6     static procfile *ff = NULL;
7
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     }
14
15     ff = procfile_readall(ff);
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 = str2ull(procfile_lineword(ff, 0, 0));
19
20     RRDSET *st = rrdset_find_bytype("system", "entropy");
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     }
25     else rrdset_next(st);
26
27     rrddim_set(st, "entropy", entropy);
28     rrdset_done(st);
29
30     return 0;
31 }