feat(proc/proc_net_dev): add dim per duplex state to the "Interface Duplex State" chart (#13165)
Ilya Mashchenko committed
Jun 17, 2022 at 16:51 UTC
a483ead88b694a176d705ef191cba633ca692942
2 files changed
+22
-9
collectors/proc.plugin/proc_net_dev.c
+21
-7
@@ -7,6 +7,12 @@
7
8
#define STATE_LENGTH_MAX 32
9
10
+enum {
11
+ NETDEV_DUPLEX_UNKNOWN,
12
+ NETDEV_DUPLEX_HALF,
13
+ NETDEV_DUPLEX_FULL
14
+};
15
+
16
enum {
17
NETDEV_OPERSTATE_UNKNOWN,
18
NETDEV_OPERSTATE_NOTPRESENT,
@@ -167,7 +173,9 @@ static struct netdev {
173
RRDDIM *rd_tcompressed;
174
175
RRDDIM *rd_speed;
170
- RRDDIM *rd_duplex;
176
+ RRDDIM *rd_duplex_full;
177
+ RRDDIM *rd_duplex_half;
178
+ RRDDIM *rd_duplex_unknown;
179
RRDDIM *rd_operstate_unknown;
180
RRDDIM *rd_operstate_notpresent;
181
RRDDIM *rd_operstate_down;
@@ -239,7 +247,9 @@ static void netdev_charts_release(struct netdev *d) {
247
d->rd_tcompressed = NULL;
248
249
d->rd_speed = NULL;
242
- d->rd_duplex = NULL;
250
+ d->rd_duplex_full = NULL;
251
+ d->rd_duplex_half = NULL;
252
+ d->rd_duplex_unknown = NULL;
253
d->rd_carrier = NULL;
254
d->rd_mtu = NULL;
255
@@ -840,11 +850,11 @@ int do_proc_net_dev(int update_every, usec_t dt) {
850
} else {
851
// values can be unknown, half or full -- just check the first letter for speed
852
if (buffer[0] == 'f')
843
- d->duplex = 2;
853
+ d->duplex = NETDEV_DUPLEX_FULL;
854
else if (buffer[0] == 'h')
845
- d->duplex = 1;
855
+ d->duplex = NETDEV_DUPLEX_HALF;
856
else
847
- d->duplex = 0;
857
+ d->duplex = NETDEV_DUPLEX_UNKNOWN;
858
}
859
} else {
860
d->duplex = 0;
@@ -1011,11 +1021,15 @@ int do_proc_net_dev(int update_every, usec_t dt) {
1021
1022
rrdset_update_rrdlabels(d->st_duplex, d->chart_labels);
1023
1014
- d->rd_duplex = rrddim_add(d->st_duplex, "duplex", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
1024
+ d->rd_duplex_full = rrddim_add(d->st_duplex, "full", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
1025
+ d->rd_duplex_half = rrddim_add(d->st_duplex, "half", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
1026
+ d->rd_duplex_unknown = rrddim_add(d->st_duplex, "unknown", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
1027
}
1028
else rrdset_next(d->st_duplex);
1029
1018
- rrddim_set_by_pointer(d->st_duplex, d->rd_duplex, (collected_number)d->duplex);
1030
+ rrddim_set_by_pointer(d->st_duplex, d->rd_duplex_full, (collected_number)(d->duplex == NETDEV_DUPLEX_FULL));
1031
+ rrddim_set_by_pointer(d->st_duplex, d->rd_duplex_half, (collected_number)(d->duplex == NETDEV_DUPLEX_HALF));
1032
+ rrddim_set_by_pointer(d->st_duplex, d->rd_duplex_unknown, (collected_number)(d->duplex == NETDEV_DUPLEX_UNKNOWN));
1033
rrdset_done(d->st_duplex);
1034
}
1035
web/gui/dashboard_info.js
+1
-2
@@ -1123,8 +1123,7 @@ const netDuplexInfo = '<p>The interface\'s latest or current ' +
1123
'<a href="https://en.wikipedia.org/wiki/Autonegotiation" target="_blank">negotiated</a> with the device it is connected to.</p>' +
1124
'<p><b>Unknown</b> - the duplex mode can not be determined. ' +
1125
'<b>Half duplex</b> - the communication is one direction at a time. ' +
1126
- '<b>Full duplex</b> - the interface is able to send and receive data simultaneously.</p>' +
1127
- '<p><b>State map</b>: 0 - unknown, 1 - half, 2 - full.</p>'
1126
+ '<b>Full duplex</b> - the interface is able to send and receive data simultaneously.</p>'
1127
const netOperstateInfo = '<p>The current ' +
1128
'<a href="https://datatracker.ietf.org/doc/html/rfc2863" target="_blank">operational state</a> of the interface.</p>' +
1129
'<p><b>Unknown</b> - the state can not be determined. ' +