diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-03-09 13:19:48 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-03-09 13:20:02 +0000 |
commit | 58daab21cd043e1dc37024a7f99b396788372918 (patch) | |
tree | 96771e43bb69f7c1c2b0b4f7374cb74d7866d0cb /collectors/apps.plugin/apps_plugin.c | |
parent | Releasing debian version 1.43.2-1. (diff) | |
download | netdata-58daab21cd043e1dc37024a7f99b396788372918.tar.xz netdata-58daab21cd043e1dc37024a7f99b396788372918.zip |
Merging upstream version 1.44.3.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'collectors/apps.plugin/apps_plugin.c')
-rw-r--r-- | collectors/apps.plugin/apps_plugin.c | 86 |
1 files changed, 43 insertions, 43 deletions
diff --git a/collectors/apps.plugin/apps_plugin.c b/collectors/apps.plugin/apps_plugin.c index 152038968..5bcda84f4 100644 --- a/collectors/apps.plugin/apps_plugin.c +++ b/collectors/apps.plugin/apps_plugin.c @@ -3750,7 +3750,7 @@ static void send_collected_data_to_netdata(struct target *root, const char *type struct target *w; for (w = root; w ; w = w->next) { - if (unlikely(!w->exposed && !w->is_other)) + if (unlikely(!w->exposed)) continue; send_BEGIN(type, w->clean_name, "processes", dt); @@ -3806,16 +3806,30 @@ static void send_collected_data_to_netdata(struct target *root, const char *type #endif #ifndef __FreeBSD__ - send_BEGIN(type, w->clean_name, "uptime", dt); - send_SET("uptime", (global_uptime > w->starttime) ? (global_uptime - w->starttime) : 0); - send_END(); + if (w->processes == 0) { + send_BEGIN(type, w->clean_name, "uptime", dt); + send_SET("uptime", 0); + send_END(); - if (enable_detailed_uptime_charts) { - send_BEGIN(type, w->clean_name, "uptime_summary", dt); - send_SET("min", w->uptime_min); - send_SET("avg", w->processes > 0 ? w->uptime_sum / w->processes : 0); - send_SET("max", w->uptime_max); + if (enable_detailed_uptime_charts) { + send_BEGIN(type, w->clean_name, "uptime_summary", dt); + send_SET("min", 0); + send_SET("avg", 0); + send_SET("max", 0); + send_END(); + } + } else { + send_BEGIN(type, w->clean_name, "uptime", dt); + send_SET("uptime", (global_uptime > w->starttime) ? (global_uptime - w->starttime) : 0); send_END(); + + if (enable_detailed_uptime_charts) { + send_BEGIN(type, w->clean_name, "uptime_summary", dt); + send_SET("min", w->uptime_min); + send_SET("avg", w->processes > 0 ? w->uptime_sum / w->processes : 0); + send_SET("max", w->uptime_max); + send_END(); + } } #endif @@ -3860,7 +3874,7 @@ static void send_charts_updates_to_netdata(struct target *root, const char *type if (debug_enabled) { for (w = root; w; w = w->next) { - if (unlikely(w->debug_enabled && !w->target && w->processes)) { + if (unlikely(!w->target && w->processes)) { struct pid_on_target *pid_on_target; fprintf(stderr, "apps.plugin: target '%s' has aggregated %u process(es):", w->name, w->processes); for (pid_on_target = w->root_pid; pid_on_target; pid_on_target = pid_on_target->next) { @@ -3878,7 +3892,7 @@ static void send_charts_updates_to_netdata(struct target *root, const char *type w->exposed = 1; fprintf(stdout, "CHART %s.%s_cpu_utilization '' '%s CPU utilization (100%% = 1 core)' 'percentage' cpu %s.cpu_utilization stacked 20001 %d\n", type, w->clean_name, title, type, update_every); - fprintf(stdout, "CLABEL '%s' '%s' 0\n", lbl_name, w->name); + fprintf(stdout, "CLABEL '%s' '%s' 1\n", lbl_name, w->name); fprintf(stdout, "CLABEL_COMMIT\n"); fprintf(stdout, "DIMENSION user '' absolute 1 %llu\n", time_factor * RATES_DETAIL / 100LLU); fprintf(stdout, "DIMENSION system '' absolute 1 %llu\n", time_factor * RATES_DETAIL / 100LLU); @@ -3886,84 +3900,84 @@ static void send_charts_updates_to_netdata(struct target *root, const char *type #ifndef __FreeBSD__ if (enable_guest_charts) { fprintf(stdout, "CHART %s.%s_cpu_guest_utilization '' '%s CPU guest utlization (100%% = 1 core)' 'percentage' cpu %s.cpu_guest_utilization line 20005 %d\n", type, w->clean_name, title, type, update_every); - fprintf(stdout, "CLABEL '%s' '%s' 0\n", lbl_name, w->name); + fprintf(stdout, "CLABEL '%s' '%s' 1\n", lbl_name, w->name); fprintf(stdout, "CLABEL_COMMIT\n"); fprintf(stdout, "DIMENSION guest '' absolute 1 %llu\n", time_factor * RATES_DETAIL / 100LLU); } fprintf(stdout, "CHART %s.%s_cpu_context_switches '' '%s CPU context switches' 'switches/s' cpu %s.cpu_context_switches stacked 20010 %d\n", type, w->clean_name, title, type, update_every); - fprintf(stdout, "CLABEL '%s' '%s' 0\n", lbl_name, w->name); + fprintf(stdout, "CLABEL '%s' '%s' 1\n", lbl_name, w->name); fprintf(stdout, "CLABEL_COMMIT\n"); fprintf(stdout, "DIMENSION voluntary '' absolute 1 %llu\n", RATES_DETAIL); fprintf(stdout, "DIMENSION involuntary '' absolute 1 %llu\n", RATES_DETAIL); fprintf(stdout, "CHART %s.%s_mem_private_usage '' '%s memory usage without shared' 'MiB' mem %s.mem_private_usage area 20050 %d\n", type, w->clean_name, title, type, update_every); - fprintf(stdout, "CLABEL '%s' '%s' 0\n", lbl_name, w->name); + fprintf(stdout, "CLABEL '%s' '%s' 1\n", lbl_name, w->name); fprintf(stdout, "CLABEL_COMMIT\n"); fprintf(stdout, "DIMENSION mem '' absolute %ld %ld\n", 1L, 1024L); #endif fprintf(stdout, "CHART %s.%s_mem_usage '' '%s memory RSS usage' 'MiB' mem %s.mem_usage area 20055 %d\n", type, w->clean_name, title, type, update_every); - fprintf(stdout, "CLABEL '%s' '%s' 0\n", lbl_name, w->name); + fprintf(stdout, "CLABEL '%s' '%s' 1\n", lbl_name, w->name); fprintf(stdout, "CLABEL_COMMIT\n"); fprintf(stdout, "DIMENSION rss '' absolute %ld %ld\n", 1L, 1024L); fprintf(stdout, "CHART %s.%s_mem_page_faults '' '%s memory page faults' 'pgfaults/s' mem %s.mem_page_faults stacked 20060 %d\n", type, w->clean_name, title, type, update_every); - fprintf(stdout, "CLABEL '%s' '%s' 0\n", lbl_name, w->name); + fprintf(stdout, "CLABEL '%s' '%s' 1\n", lbl_name, w->name); fprintf(stdout, "CLABEL_COMMIT\n"); fprintf(stdout, "DIMENSION major '' absolute 1 %llu\n", RATES_DETAIL); fprintf(stdout, "DIMENSION minor '' absolute 1 %llu\n", RATES_DETAIL); fprintf(stdout, "CHART %s.%s_vmem_usage '' '%s virtual memory size' 'MiB' mem %s.vmem_usage line 20065 %d\n", type, w->clean_name, title, type, update_every); - fprintf(stdout, "CLABEL '%s' '%s' 0\n", lbl_name, w->name); + fprintf(stdout, "CLABEL '%s' '%s' 1\n", lbl_name, w->name); fprintf(stdout, "CLABEL_COMMIT\n"); fprintf(stdout, "DIMENSION vmem '' absolute %ld %ld\n", 1L, 1024L); #ifndef __FreeBSD__ fprintf(stdout, "CHART %s.%s_swap_usage '' '%s swap usage' 'MiB' mem %s.swap_usage area 20065 %d\n", type, w->clean_name, title, type, update_every); - fprintf(stdout, "CLABEL '%s' '%s' 0\n", lbl_name, w->name); + fprintf(stdout, "CLABEL '%s' '%s' 1\n", lbl_name, w->name); fprintf(stdout, "CLABEL_COMMIT\n"); fprintf(stdout, "DIMENSION swap '' absolute %ld %ld\n", 1L, 1024L); #endif #ifndef __FreeBSD__ fprintf(stdout, "CHART %s.%s_disk_physical_io '' '%s disk physical IO' 'KiB/s' disk %s.disk_physical_io area 20100 %d\n", type, w->clean_name, title, type, update_every); - fprintf(stdout, "CLABEL '%s' '%s' 0\n", lbl_name, w->name); + fprintf(stdout, "CLABEL '%s' '%s' 1\n", lbl_name, w->name); fprintf(stdout, "CLABEL_COMMIT\n"); fprintf(stdout, "DIMENSION reads '' absolute 1 %llu\n", 1024LLU * RATES_DETAIL); fprintf(stdout, "DIMENSION writes '' absolute -1 %llu\n", 1024LLU * RATES_DETAIL); fprintf(stdout, "CHART %s.%s_disk_logical_io '' '%s disk logical IO' 'KiB/s' disk %s.disk_logical_io area 20105 %d\n", type, w->clean_name, title, type, update_every); - fprintf(stdout, "CLABEL '%s' '%s' 0\n", lbl_name, w->name); + fprintf(stdout, "CLABEL '%s' '%s' 1\n", lbl_name, w->name); fprintf(stdout, "CLABEL_COMMIT\n"); fprintf(stdout, "DIMENSION reads '' absolute 1 %llu\n", 1024LLU * RATES_DETAIL); fprintf(stdout, "DIMENSION writes '' absolute -1 %llu\n", 1024LLU * RATES_DETAIL); #else fprintf(stdout, "CHART %s.%s_disk_physical_io '' '%s disk physical IO' 'blocks/s' disk %s.disk_physical_block_io area 20100 %d\n", type, w->clean_name, title, type, update_every); - fprintf(stdout, "CLABEL '%s' '%s' 0\n", lbl_name, w->name); + fprintf(stdout, "CLABEL '%s' '%s' 1\n", lbl_name, w->name); fprintf(stdout, "CLABEL_COMMIT\n"); fprintf(stdout, "DIMENSION reads '' absolute 1 %llu\n", RATES_DETAIL); fprintf(stdout, "DIMENSION writes '' absolute -1 %llu\n", RATES_DETAIL); #endif fprintf(stdout, "CHART %s.%s_processes '' '%s processes' 'processes' processes %s.processes line 20150 %d\n", type, w->clean_name, title, type, update_every); - fprintf(stdout, "CLABEL '%s' '%s' 0\n", lbl_name, w->name); + fprintf(stdout, "CLABEL '%s' '%s' 1\n", lbl_name, w->name); fprintf(stdout, "CLABEL_COMMIT\n"); fprintf(stdout, "DIMENSION processes '' absolute 1 1\n"); fprintf(stdout, "CHART %s.%s_threads '' '%s threads' 'threads' processes %s.threads line 20155 %d\n", type, w->clean_name, title, type, update_every); - fprintf(stdout, "CLABEL '%s' '%s' 0\n", lbl_name, w->name); + fprintf(stdout, "CLABEL '%s' '%s' 1\n", lbl_name, w->name); fprintf(stdout, "CLABEL_COMMIT\n"); fprintf(stdout, "DIMENSION threads '' absolute 1 1\n"); if (enable_file_charts) { fprintf(stdout, "CHART %s.%s_fds_open_limit '' '%s open file descriptors limit' '%%' fds %s.fds_open_limit line 20200 %d\n", type, w->clean_name, title, type, update_every); - fprintf(stdout, "CLABEL '%s' '%s' 0\n", lbl_name, w->name); + fprintf(stdout, "CLABEL '%s' '%s' 1\n", lbl_name, w->name); fprintf(stdout, "CLABEL_COMMIT\n"); fprintf(stdout, "DIMENSION limit '' absolute 1 100\n"); fprintf(stdout, "CHART %s.%s_fds_open '' '%s open files descriptors' 'fds' fds %s.fds_open stacked 20210 %d\n", type, w->clean_name, title, type, update_every); - fprintf(stdout, "CLABEL '%s' '%s' 0\n", lbl_name, w->name); + fprintf(stdout, "CLABEL '%s' '%s' 1\n", lbl_name, w->name); fprintf(stdout, "CLABEL_COMMIT\n"); fprintf(stdout, "DIMENSION files '' absolute 1 1\n"); fprintf(stdout, "DIMENSION sockets '' absolute 1 1\n"); @@ -3978,13 +3992,13 @@ static void send_charts_updates_to_netdata(struct target *root, const char *type #ifndef __FreeBSD__ fprintf(stdout, "CHART %s.%s_uptime '' '%s uptime' 'seconds' uptime %s.uptime line 20250 %d\n", type, w->clean_name, title, type, update_every); - fprintf(stdout, "CLABEL '%s' '%s' 0\n", lbl_name, w->name); + fprintf(stdout, "CLABEL '%s' '%s' 1\n", lbl_name, w->name); fprintf(stdout, "CLABEL_COMMIT\n"); fprintf(stdout, "DIMENSION uptime '' absolute 1 1\n"); if (enable_detailed_uptime_charts) { fprintf(stdout, "CHART %s.%s_uptime_summary '' '%s uptime summary' 'seconds' uptime %s.uptime_summary area 20255 %d\n", type, w->clean_name, title, type, update_every); - fprintf(stdout, "CLABEL '%s' '%s' 0\n", lbl_name, w->name); + fprintf(stdout, "CLABEL '%s' '%s' 1\n", lbl_name, w->name); fprintf(stdout, "CLABEL_COMMIT\n"); fprintf(stdout, "DIMENSION min '' absolute 1 1\n"); fprintf(stdout, "DIMENSION avg '' absolute 1 1\n"); @@ -5234,25 +5248,11 @@ static void function_processes(const char *transaction, char *function __maybe_u static bool apps_plugin_exit = false; int main(int argc, char **argv) { - // debug_flags = D_PROCFILE; - stderror = stderr; - clocks_init(); + nd_log_initialize_for_external_plugins("apps.plugin"); pagesize = (size_t)sysconf(_SC_PAGESIZE); - // set the name for logging - program_name = "apps.plugin"; - - // disable syslog for apps.plugin - error_log_syslog = 0; - - // set errors flood protection to 100 logs per hour - error_log_errors_per_period = 100; - error_log_throttle_period = 3600; - - log_set_global_severity_for_external_plugins(); - bool send_resource_usage = true; { const char *s = getenv("NETDATA_INTERNALS_MONITORING"); @@ -5264,7 +5264,7 @@ int main(int argc, char **argv) { procfile_open_flags = O_RDONLY|O_NOFOLLOW; netdata_configured_host_prefix = getenv("NETDATA_HOST_PREFIX"); - if(verify_netdata_host_prefix() == -1) exit(1); + if(verify_netdata_host_prefix(true) == -1) exit(1); user_config_dir = getenv("NETDATA_USER_CONFIG_DIR"); if(user_config_dir == NULL) { |