+14
-19
@@ -85,12 +85,9 @@ static int metrics_on_query_reply(
|
||||
log_info("Varlink timed out");
|
||||
else
|
||||
log_error("Varlink error: %s", error_id);
|
||||
} else {
|
||||
if (context->n_metrics >= METRICS_MAX) {
|
||||
context->n_skipped_metrics++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
} else if (context->n_metrics >= METRICS_MAX)
|
||||
context->n_skipped_metrics++;
|
||||
else {
|
||||
/* Collect metrics for later sorting */
|
||||
if (!GREEDY_REALLOC(context->metrics, context->n_metrics + 1))
|
||||
return log_oom();
|
||||
@@ -200,7 +197,7 @@ static int metrics_query(void) {
|
||||
if (!d) {
|
||||
if (errno != ENOENT)
|
||||
return log_error_errno(errno, "Failed to open metrics directory %s: %m", metrics_path);
|
||||
} else {
|
||||
} else
|
||||
FOREACH_DIRENT(de, d,
|
||||
return log_warning_errno(errno, "Failed to read %s: %m", metrics_path)) {
|
||||
|
||||
@@ -218,7 +215,6 @@ static int metrics_query(void) {
|
||||
|
||||
(void) metrics_call(&context, p);
|
||||
}
|
||||
}
|
||||
|
||||
if (set_isempty(context.links))
|
||||
log_info("No metrics sources found.");
|
||||
@@ -230,18 +226,17 @@ static int metrics_query(void) {
|
||||
r = metrics_output_sorted(&context);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (n_skipped_sources > 0)
|
||||
log_warning("Too many metrics sources, only %u sources contacted, %zu sources skipped.", set_size(context.links), n_skipped_sources);
|
||||
if (context.n_skipped_metrics > 0)
|
||||
log_warning("Too many metrics, only %zu metrics collected, %zu metrics skipped.", context.n_metrics, context.n_skipped_metrics);
|
||||
|
||||
if (n_skipped_sources > 0 ||
|
||||
context.n_skipped_metrics > 0)
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
if (n_skipped_sources > 0)
|
||||
return log_warning_errno(SYNTHETIC_ERRNO(EUCLEAN),
|
||||
"Too many metrics sources, only %u sources contacted, %zu sources skipped.",
|
||||
set_size(context.links), n_skipped_sources);
|
||||
if (context.n_skipped_metrics > 0)
|
||||
return log_warning_errno(SYNTHETIC_ERRNO(EUCLEAN),
|
||||
"Too many metrics, only %zu metrics collected, %zu metrics skipped.",
|
||||
context.n_metrics, context.n_skipped_metrics);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int help(void) {
|
||||
@@ -342,4 +337,4 @@ static int run(int argc, char *argv[]) {
|
||||
return metrics_query();
|
||||
}
|
||||
|
||||
DEFINE_MAIN_FUNCTION_WITH_POSITIVE_FAILURE(run);
|
||||
DEFINE_MAIN_FUNCTION(run);
|
||||
|
||||
Reference in New Issue
Block a user