Skip to content

Commit 69634a4

Browse files
cosmo0920edsiper
authored andcommitted
in_node_exporter_metrics: Update metrics value only if succeeded
Signed-off-by: Hiroshi Hatake <[email protected]>
1 parent 3fb4126 commit 69634a4

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

plugins/in_node_exporter_metrics/ne_cpu_linux.c

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -152,15 +152,15 @@ static int cpu_thermal_update(struct flb_ne *ctx, uint64_t ts)
152152
"CPU is missing core_throttle_count: %s",
153153
entry->str);
154154
}
155-
156-
snprintf(tmp1, sizeof(tmp1) -1, "%" PRIu64, core_id);
157-
snprintf(tmp2, sizeof(tmp2) -1, "%" PRIu64, physical_package_id);
158-
159-
/* Set new value */
160-
cmt_counter_set(ctx->cpu_core_throttles, ts,
161-
(double) core_throttle_count,
162-
2, (char *[]) {tmp1, tmp2});
163-
155+
else {
156+
snprintf(tmp1, sizeof(tmp1) -1, "%" PRIu64, core_id);
157+
snprintf(tmp2, sizeof(tmp2) -1, "%" PRIu64, physical_package_id);
158+
159+
/* Set new value */
160+
cmt_counter_set(ctx->cpu_core_throttles, ts,
161+
(double) core_throttle_count,
162+
2, (char *[]) {tmp1, tmp2});
163+
}
164164

165165
/* Only update this entry once */
166166
if (package_throttles_set[physical_package_id] != 0) {
@@ -178,11 +178,12 @@ static int cpu_thermal_update(struct flb_ne *ctx, uint64_t ts)
178178
"CPU is missing package_throttle_count: %s",
179179
entry->str);
180180
}
181-
182-
/* Set new value */
183-
cmt_counter_set(ctx->cpu_package_throttles, ts,
184-
(double) package_throttle_count,
185-
1, (char *[]) {tmp2});
181+
else {
182+
/* Set new value */
183+
cmt_counter_set(ctx->cpu_package_throttles, ts,
184+
(double) package_throttle_count,
185+
1, (char *[]) {tmp2});
186+
}
186187
}
187188
flb_slist_destroy(&list);
188189

0 commit comments

Comments
 (0)