@cryptotaxi247 / netdata-1 / commits / e4cc55d8c

fix(proc.plugin): fix read retry logic when reading interface speed (#13893)

Ilya Mashchenko committed Oct 26, 2022 at 21:40 UTC e4cc55d8cbe979fd332a47a6c6104605b71f2b96
1 file changed +5 -3
collectors/proc.plugin/proc_net_dev.c
+5 -3
@@ -1015,7 +1015,7 @@ int do_proc_net_dev(int update_every, usec_t dt) {
1015 (d->speed_file_exists || now_monotonic_sec() - d->speed_file_lost_time > READ_RETRY_PERIOD)) {
1016 ret = read_single_number_file(d->filename_speed, (unsigned long long *) &d->speed);
1017 } else {
1018 - d->speed = 0;
1018 + d->speed = 0; // TODO: this is wrong, shouldn't use 0 value, but NULL.
1019 }
1020
1021 if(ret) {
@@ -1057,8 +1057,10 @@ int do_proc_net_dev(int update_every, usec_t dt) {
1057 rrdsetvar_custom_chart_variable_set(
1058 d->st_bandwidth, d->chart_var_speed, (NETDATA_DOUBLE)d->speed * KILOBITS_IN_A_MEGABIT);
1059
1060 - d->speed_file_exists = 1;
1061 - d->speed_file_lost_time = 0;
1060 + if (d->speed) {
1061 + d->speed_file_exists = 1;
1062 + d->speed_file_lost_time = 0;
1063 + }
1064 }
1065 }
1066 }