int enabled;
int (*func)(int update_every, usec_t dt);
- usec_t last_run_usec;
usec_t duration;
RRDDIM *rd;
{ .name = "/proc/meminfo", .dim = "meminfo", .func = do_proc_meminfo },
{ .name = "/sys/kernel/mm/ksm", .dim = "ksm", .func = do_sys_kernel_mm_ksm },
{ .name = "/sys/devices/system/edac/mc", .dim = "ecc", .func = do_proc_sys_devices_system_edac_mc },
+ { .name = "/sys/devices/system/node", .dim = "numa", .func = do_proc_sys_devices_system_node },
// network metrics
{ .name = "/proc/net/dev", .dim = "netdev", .func = do_proc_net_dev },
struct proc_module *pm = &proc_modules[i];
pm->enabled = config_get_boolean("plugin:proc", pm->name, 1);
- pm->last_run_usec = 0ULL;
pm->duration = 0ULL;
pm->rd = NULL;
}
usec_t step = rrd_update_every * USEC_PER_SEC;
- for(;;) {
- usec_t now = now_monotonic_usec();
- usec_t next = now - (now % step) + step;
+ heartbeat_t hb;
+ heartbeat_init(&hb);
- while(now < next) {
- sleep_usec(next - now);
- now = now_monotonic_usec();
- }
+ for(;;) {
+ usec_t hb_dt = heartbeat_next(&hb, step);
+ usec_t duration = 0ULL;
if(unlikely(netdata_exit)) break;
debug(D_PROCNETDEV_LOOP, "PROC calling %s.", pm->name);
- pm->enabled = !pm->func(rrd_update_every, (pm->last_run_usec > 0)?now - pm->last_run_usec:0ULL);
- pm->last_run_usec = now;
-
- now = now_monotonic_usec();
- pm->duration = now - pm->last_run_usec;
+ pm->enabled = !pm->func(rrd_update_every, hb_dt);
+ pm->duration = heartbeat_dt_usec(&hb) - duration;
+ duration += pm->duration;
if(unlikely(netdata_exit)) break;
}
pthread_exit(NULL);
return NULL;
}
+
+int get_numa_node_count(void)
+{
+ static int numa_node_count = -1;
+
+ if (numa_node_count != -1)
+ return numa_node_count;
+
+ numa_node_count = 0;
+
+ char name[FILENAME_MAX + 1];
+ snprintfz(name, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/sys/devices/system/node");
+ char *dirname = config_get("plugin:proc:/sys/devices/system/node", "directory to monitor", name);
+
+ DIR *dir = opendir(dirname);
+ if(dir) {
+ struct dirent *de = NULL;
+ while((de = readdir(dir))) {
+ if(de->d_type != DT_DIR)
+ continue;
+
+ if(strncmp(de->d_name, "node", 4) != 0)
+ continue;
+
+ if(!isdigit(de->d_name[4]))
+ continue;
+
+ numa_node_count++;
+ }
+ closedir(dir);
+ }
+
+ return numa_node_count;
+}