diff options
author | Austin S. Hemmelgarn <austin@netdata.cloud> | 2020-04-13 08:39:52 -0400 |
---|---|---|
committer | Austin S. Hemmelgarn <austin@netdata.cloud> | 2020-04-13 08:42:22 -0400 |
commit | e2874320fc027f7ab51ab3e115d5b1889b8fd747 (patch) | |
tree | cd755ef9b8522634c61aed9888239c9b67394157 /exporting/send_internal_metrics.c | |
parent | 353780082c0ac8525e5b52aa8a29bbf5b70871e8 (diff) |
Revert changes since v1.21 in pereparation for hotfix release.
Diffstat (limited to 'exporting/send_internal_metrics.c')
-rw-r--r-- | exporting/send_internal_metrics.c | 166 |
1 files changed, 6 insertions, 160 deletions
diff --git a/exporting/send_internal_metrics.c b/exporting/send_internal_metrics.c index e4111a587b..b93918695b 100644 --- a/exporting/send_internal_metrics.c +++ b/exporting/send_internal_metrics.c @@ -3,170 +3,16 @@ #include "exporting_engine.h" /** - * Create a chart for the main exporting thread CPU usage - * - * @param st_rusage the thead CPU usage chart - * @param rd_user a dimension for user CPU usage - * @param rd_system a dimension for system CPU usage - */ -void create_main_rusage_chart(RRDSET **st_rusage, RRDDIM **rd_user, RRDDIM **rd_system) -{ - if (*st_rusage && *rd_user && *rd_system) - return; - - *st_rusage = rrdset_create_localhost( - "netdata", "exporting_main_thread_cpu", NULL, "exporting", NULL, "Netdata Main Exporting Thread CPU Usage", - "milliseconds/s", "exporting", NULL, 130600, localhost->rrd_update_every, RRDSET_TYPE_STACKED); - - *rd_user = rrddim_add(*st_rusage, "user", NULL, 1, 1000, RRD_ALGORITHM_INCREMENTAL); - *rd_system = rrddim_add(*st_rusage, "system", NULL, 1, 1000, RRD_ALGORITHM_INCREMENTAL); -} - -/** - * Send the main exporting thread CPU usage - * - * @param st_rusage a thead CPU usage chart - * @param rd_user a dimension for user CPU usage - * @param rd_system a dimension for system CPU usage - */ -void send_main_rusage(RRDSET *st_rusage, RRDDIM *rd_user, RRDDIM *rd_system) -{ - struct rusage thread; - getrusage(RUSAGE_THREAD, &thread); - - if (likely(st_rusage->counter_done)) - rrdset_next(st_rusage); - - rrddim_set_by_pointer(st_rusage, rd_user, thread.ru_utime.tv_sec * 1000000ULL + thread.ru_utime.tv_usec); - rrddim_set_by_pointer(st_rusage, rd_system, thread.ru_stime.tv_sec * 1000000ULL + thread.ru_stime.tv_usec); - - rrdset_done(st_rusage); -} - -/** - * Send internal metrics for an instance + * Send internal metrics * * Send performance metrics for the operation of exporting engine itself to the Netdata database. * - * @param instance an instance data structure. + * @param engine an engine data structure. + * @return Returns 0 on success, 1 on failure. */ -void send_internal_metrics(struct instance *instance) +int send_internal_metrics(struct engine *engine) { - struct stats *stats = &instance->stats; - - // ------------------------------------------------------------------------ - // create charts for monitoring the exporting operations - - if (!stats->initialized) { - char id[RRD_ID_LENGTH_MAX + 1]; - BUFFER *family = buffer_create(0); - - buffer_sprintf(family, "exporting_%s", instance->config.name); - - snprintf(id, RRD_ID_LENGTH_MAX, "exporting_%s_metrics", instance->config.name); - netdata_fix_chart_id(id); - - stats->st_metrics = rrdset_create_localhost( - "netdata", id, NULL, buffer_tostring(family), NULL, "Netdata Buffered Metrics", "metrics", "exporting", NULL, - 130610, instance->config.update_every, RRDSET_TYPE_LINE); - - stats->rd_buffered_metrics = rrddim_add(stats->st_metrics, "buffered", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); - stats->rd_lost_metrics = rrddim_add(stats->st_metrics, "lost", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); - stats->rd_sent_metrics = rrddim_add(stats->st_metrics, "sent", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); - - // ------------------------------------------------------------------------ - - snprintf(id, RRD_ID_LENGTH_MAX, "exporting_%s_bytes", instance->config.name); - netdata_fix_chart_id(id); - - stats->st_bytes = rrdset_create_localhost( - "netdata", id, NULL, buffer_tostring(family), NULL, "Netdata Exporting Data Size", "KiB", "exporting", NULL, - 130620, instance->config.update_every, RRDSET_TYPE_AREA); - - stats->rd_buffered_bytes = rrddim_add(stats->st_bytes, "buffered", NULL, 1, 1024, RRD_ALGORITHM_ABSOLUTE); - stats->rd_lost_bytes = rrddim_add(stats->st_bytes, "lost", NULL, 1, 1024, RRD_ALGORITHM_ABSOLUTE); - stats->rd_sent_bytes = rrddim_add(stats->st_bytes, "sent", NULL, 1, 1024, RRD_ALGORITHM_ABSOLUTE); - stats->rd_received_bytes = rrddim_add(stats->st_bytes, "received", NULL, 1, 1024, RRD_ALGORITHM_ABSOLUTE); - - // ------------------------------------------------------------------------ - - snprintf(id, RRD_ID_LENGTH_MAX, "exporting_%s_ops", instance->config.name); - netdata_fix_chart_id(id); - - stats->st_ops = rrdset_create_localhost( - "netdata", id, NULL, buffer_tostring(family), NULL, "Netdata Exporting Operations", "operations", "exporting", - NULL, 130630, instance->config.update_every, RRDSET_TYPE_LINE); - - stats->rd_transmission_successes = rrddim_add(stats->st_ops, "write", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); - stats->rd_data_lost_events = rrddim_add(stats->st_ops, "discard", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); - stats->rd_reconnects = rrddim_add(stats->st_ops, "reconnect", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); - stats->rd_transmission_failures = rrddim_add(stats->st_ops, "failure", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); - stats->rd_receptions = rrddim_add(stats->st_ops, "read", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); - - // ------------------------------------------------------------------------ - - snprintf(id, RRD_ID_LENGTH_MAX, "exporting_%s_thread_cpu", instance->config.name); - netdata_fix_chart_id(id); - - stats->st_rusage = rrdset_create_localhost( - "netdata", id, NULL, buffer_tostring(family), NULL, "Netdata Exporting Instance Thread CPU Usage", - "milliseconds/s", "exporting", NULL, 130640, instance->config.update_every, RRDSET_TYPE_STACKED); - - stats->rd_user = rrddim_add(stats->st_rusage, "user", NULL, 1, 1000, RRD_ALGORITHM_INCREMENTAL); - stats->rd_system = rrddim_add(stats->st_rusage, "system", NULL, 1, 1000, RRD_ALGORITHM_INCREMENTAL); - - buffer_free(family); - - stats->initialized = 1; - } - - // ------------------------------------------------------------------------ - // update the monitoring charts - - if (likely(stats->st_metrics->counter_done)) - rrdset_next(stats->st_metrics); - - rrddim_set_by_pointer(stats->st_metrics, stats->rd_buffered_metrics, stats->buffered_metrics); - rrddim_set_by_pointer(stats->st_metrics, stats->rd_lost_metrics, stats->lost_metrics); - rrddim_set_by_pointer(stats->st_metrics, stats->rd_sent_metrics, stats->sent_metrics); - - rrdset_done(stats->st_metrics); - - // ------------------------------------------------------------------------ - - if (likely(stats->st_bytes->counter_done)) - rrdset_next(stats->st_bytes); - - rrddim_set_by_pointer(stats->st_bytes, stats->rd_buffered_bytes, stats->buffered_bytes); - rrddim_set_by_pointer(stats->st_bytes, stats->rd_lost_bytes, stats->lost_bytes); - rrddim_set_by_pointer(stats->st_bytes, stats->rd_sent_bytes, stats->sent_bytes); - rrddim_set_by_pointer(stats->st_bytes, stats->rd_received_bytes, stats->received_bytes); - - rrdset_done(stats->st_bytes); - - // ------------------------------------------------------------------------ - - if (likely(stats->st_ops->counter_done)) - rrdset_next(stats->st_ops); - - rrddim_set_by_pointer(stats->st_ops, stats->rd_transmission_successes, stats->transmission_successes); - rrddim_set_by_pointer(stats->st_ops, stats->rd_data_lost_events, stats->data_lost_events); - rrddim_set_by_pointer(stats->st_ops, stats->rd_reconnects, stats->reconnects); - rrddim_set_by_pointer(stats->st_ops, stats->rd_transmission_failures, stats->transmission_failures); - rrddim_set_by_pointer(stats->st_ops, stats->rd_receptions, stats->receptions); - - rrdset_done(stats->st_ops); - - // ------------------------------------------------------------------------ - - struct rusage thread; - getrusage(RUSAGE_THREAD, &thread); - - if (likely(stats->st_rusage->counter_done)) - rrdset_next(stats->st_rusage); - - rrddim_set_by_pointer(stats->st_rusage, stats->rd_user, thread.ru_utime.tv_sec * 1000000ULL + thread.ru_utime.tv_usec); - rrddim_set_by_pointer(stats->st_rusage, stats->rd_system, thread.ru_stime.tv_sec * 1000000ULL + thread.ru_stime.tv_usec); + (void)engine; - rrdset_done(stats->st_rusage); + return 0; } |