summaryrefslogtreecommitdiffstats
path: root/collectors/macos.plugin
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2022-06-09 04:52:39 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2022-06-09 04:52:39 +0000
commit89f3604407aff8f4cb2ed958252c61e23c767e24 (patch)
tree7fbf408102cab051557d38193524d8c6e991d070 /collectors/macos.plugin
parentAdding upstream version 1.34.1. (diff)
downloadnetdata-89f3604407aff8f4cb2ed958252c61e23c767e24.tar.xz
netdata-89f3604407aff8f4cb2ed958252c61e23c767e24.zip
Adding upstream version 1.35.0.upstream/1.35.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'collectors/macos.plugin')
-rw-r--r--collectors/macos.plugin/plugin_macos.c100
1 files changed, 12 insertions, 88 deletions
diff --git a/collectors/macos.plugin/plugin_macos.c b/collectors/macos.plugin/plugin_macos.c
index 4566c09ee..10472bdb8 100644
--- a/collectors/macos.plugin/plugin_macos.c
+++ b/collectors/macos.plugin/plugin_macos.c
@@ -9,7 +9,6 @@ static struct macos_module {
int enabled;
int (*func)(int update_every, usec_t dt);
- usec_t duration;
RRDDIM *rd;
@@ -22,8 +21,14 @@ static struct macos_module {
{.name = NULL, .dim = NULL, .enabled = 0, .func = NULL}
};
+#if WORKER_UTILIZATION_MAX_JOB_TYPES < 3
+#error WORKER_UTILIZATION_MAX_JOB_TYPES has to be at least 3
+#endif
+
static void macos_main_cleanup(void *ptr)
{
+ worker_unregister();
+
struct netdata_static_thread *static_thread = (struct netdata_static_thread *)ptr;
static_thread->enabled = NETDATA_MAIN_THREAD_EXITING;
@@ -34,17 +39,18 @@ static void macos_main_cleanup(void *ptr)
void *macos_main(void *ptr)
{
- netdata_thread_cleanup_push(macos_main_cleanup, ptr);
+ worker_register("MACOS");
- int vdo_cpu_netdata = config_get_boolean("plugin:macos", "netdata server resources", CONFIG_BOOLEAN_YES);
+ netdata_thread_cleanup_push(macos_main_cleanup, ptr);
// check the enabled status for each module
for (int i = 0; macos_modules[i].name; i++) {
struct macos_module *pm = &macos_modules[i];
pm->enabled = config_get_boolean("plugin:macos", pm->name, pm->enabled);
- pm->duration = 0ULL;
pm->rd = NULL;
+
+ worker_register_job_name(i, macos_modules[i].dim);
}
usec_t step = localhost->rrd_update_every * USEC_PER_SEC;
@@ -52,10 +58,8 @@ void *macos_main(void *ptr)
heartbeat_init(&hb);
while (!netdata_exit) {
+ worker_is_idle();
usec_t hb_dt = heartbeat_next(&hb, step);
- usec_t duration = 0ULL;
-
- // BEGIN -- the job to be done
for (int i = 0; macos_modules[i].name; i++) {
struct macos_module *pm = &macos_modules[i];
@@ -64,92 +68,12 @@ void *macos_main(void *ptr)
debug(D_PROCNETDEV_LOOP, "macos calling %s.", pm->name);
+ worker_is_busy(i);
pm->enabled = !pm->func(localhost->rrd_update_every, hb_dt);
- pm->duration = heartbeat_monotonic_dt_to_now_usec(&hb) - duration;
- duration += pm->duration;
if (unlikely(netdata_exit))
break;
}
-
- // END -- the job is done
-
- if (vdo_cpu_netdata) {
- static RRDSET *st_cpu_thread = NULL, *st_duration = NULL;
- static RRDDIM *rd_user = NULL, *rd_system = NULL;
-
- // ----------------------------------------------------------------
-
- struct rusage thread;
- getrusage(RUSAGE_THREAD, &thread);
-
- if (unlikely(!st_cpu_thread)) {
- st_cpu_thread = rrdset_create_localhost(
- "netdata",
- "plugin_macos_cpu",
- NULL,
- "macos",
- NULL,
- "Netdata macOS plugin CPU usage",
- "milliseconds/s",
- "macos.plugin",
- "stats",
- 132000,
- localhost->rrd_update_every,
- RRDSET_TYPE_STACKED);
-
- rd_user = rrddim_add(st_cpu_thread, "user", NULL, 1, USEC_PER_MS, RRD_ALGORITHM_INCREMENTAL);
- rd_system = rrddim_add(st_cpu_thread, "system", NULL, 1, USEC_PER_MS, RRD_ALGORITHM_INCREMENTAL);
- } else {
- rrdset_next(st_cpu_thread);
- }
-
- rrddim_set_by_pointer(
- st_cpu_thread, rd_user, thread.ru_utime.tv_sec * USEC_PER_SEC + thread.ru_utime.tv_usec);
- rrddim_set_by_pointer(
- st_cpu_thread, rd_system, thread.ru_stime.tv_sec * USEC_PER_SEC + thread.ru_stime.tv_usec);
- rrdset_done(st_cpu_thread);
-
- // ----------------------------------------------------------------
-
- if (unlikely(!st_duration)) {
- st_duration = rrdset_find_active_bytype_localhost("netdata", "plugin_macos_modules");
-
- if (!st_duration) {
- st_duration = rrdset_create_localhost(
- "netdata",
- "plugin_macos_modules",
- NULL,
- "macos",
- NULL,
- "Netdata macOS plugin modules durations",
- "milliseconds/run",
- "macos.plugin",
- "stats",
- 132001,
- localhost->rrd_update_every,
- RRDSET_TYPE_STACKED);
-
- for (int i = 0; macos_modules[i].name; i++) {
- struct macos_module *pm = &macos_modules[i];
- if (unlikely(!pm->enabled))
- continue;
-
- pm->rd = rrddim_add(st_duration, pm->dim, NULL, 1, 1000, RRD_ALGORITHM_ABSOLUTE);
- }
- }
- } else
- rrdset_next(st_duration);
-
- for (int i = 0; macos_modules[i].name; i++) {
- struct macos_module *pm = &macos_modules[i];
- if (unlikely(!pm->enabled))
- continue;
-
- rrddim_set_by_pointer(st_duration, pm->rd, pm->duration);
- }
- rrdset_done(st_duration);
- }
}
netdata_thread_cleanup_pop(1);