@cryptotaxi247 / netdata-1 / commits / 222a3f59e

feat(proc/proc_net_dev): add dim per phys link state to the "Interface Physical Link State" chart (#13176)

* add dim per carrier state * fix down state

Ilya Mashchenko committed Jun 20, 2022 at 11:13 UTC 222a3f59e82434033297560511595d80ada0886f
2 files changed +9 -6
collectors/proc.plugin/proc_net_dev.c
+8 -4
@@ -183,7 +183,8 @@ static struct netdev {
183 RRDDIM *rd_operstate_testing;
184 RRDDIM *rd_operstate_dormant;
185 RRDDIM *rd_operstate_up;
186 - RRDDIM *rd_carrier;
186 + RRDDIM *rd_carrier_up;
187 + RRDDIM *rd_carrier_down;
188 RRDDIM *rd_mtu;
189
190 char *filename_speed;
@@ -250,7 +251,8 @@ static void netdev_charts_release(struct netdev *d) {
251 d->rd_duplex_full = NULL;
252 d->rd_duplex_half = NULL;
253 d->rd_duplex_unknown = NULL;
253 - d->rd_carrier = NULL;
254 + d->rd_carrier_up = NULL;
255 + d->rd_carrier_down = NULL;
256 d->rd_mtu = NULL;
257
258 d->rd_operstate_unknown = NULL;
@@ -1099,11 +1101,13 @@ int do_proc_net_dev(int update_every, usec_t dt) {
1101
1102 rrdset_update_rrdlabels(d->st_carrier, d->chart_labels);
1103
1102 - d->rd_carrier = rrddim_add(d->st_carrier, "carrier", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
1104 + d->rd_carrier_up = rrddim_add(d->st_carrier, "up", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
1105 + d->rd_carrier_down = rrddim_add(d->st_carrier, "down", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
1106 }
1107 else rrdset_next(d->st_carrier);
1108
1106 - rrddim_set_by_pointer(d->st_carrier, d->rd_carrier, (collected_number)d->carrier);
1109 + rrddim_set_by_pointer(d->st_carrier, d->rd_carrier_up, (collected_number)(d->carrier == 1));
1110 + rrddim_set_by_pointer(d->st_carrier, d->rd_carrier_down, (collected_number)(d->carrier != 1));
1111 rrdset_done(d->st_carrier);
1112 }
1113
web/gui/dashboard_info.js
+1 -2
@@ -1133,8 +1133,7 @@ const netOperstateInfo = '<p>The current ' +
1133 '<b>Testing</b> - the interface is in testing mode, e.g. cable test. It can’t be used for normal traffic until tests complete. ' +
1134 '<b>Dormant</b> - the interface is L1 up, but waiting for an external event, e.g. for a protocol to establish. ' +
1135 '<b>Up</b> - the interface is ready to pass packets and can be used.</p>'
1136 -const netCarrierInfo = '<p>The current physical link state of the interface.</p>' +
1137 - '<p><b>State map</b>: 0 - down, 1 - up.</p>'
1136 +const netCarrierInfo = 'The current physical link state of the interface.'
1137 const netSpeedInfo = 'The interface\'s latest or current speed that the network adapter ' +
1138 '<a href="https://en.wikipedia.org/wiki/Autonegotiation" target="_blank">negotiated</a> with the device it is connected to. ' +
1139 'This does not give the max supported speed of the NIC.'