@cryptotaxi247 / netdata-1 / commits / 78abc5998

properly parse network interface names with colon on them (#4653)

Costa Tsaousis committed Nov 14, 2018 at 01:32 UTC 78abc5998c74675c376118ac6f23a2cd6155a2b8
4 files changed +24 -6
collectors/proc.plugin/proc_net_dev.c
+21 -5
@@ -440,12 +440,15 @@ int do_proc_net_dev(int update_every, usec_t dt) {
440 static procfile *ff = NULL;
441 static int enable_new_interfaces = -1;
442 static int do_bandwidth = -1, do_packets = -1, do_errors = -1, do_drops = -1, do_fifo = -1, do_compressed = -1, do_events = -1;
443 - static char *path_to_sys_devices_virtual_net = NULL, *path_to_sys_class_net_speed = NULL;
443 + static char *path_to_sys_devices_virtual_net = NULL, *path_to_sys_class_net_speed = NULL, *proc_net_dev_filename = NULL;
444 static long long int dt_to_refresh_speed = 0;
445
446 if(unlikely(enable_new_interfaces == -1)) {
447 char filename[FILENAME_MAX + 1];
448
449 + snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, (*netdata_configured_host_prefix)?"/proc/1/net/dev":"/proc/net/dev");
450 + proc_net_dev_filename = config_get(CONFIG_SECTION_PLUGIN_PROC_NETDEV, "filename to monitor", filename);
451 +
452 snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/sys/devices/virtual/net/%s");
453 path_to_sys_devices_virtual_net = config_get(CONFIG_SECTION_PLUGIN_PROC_NETDEV, "path to get virtual interfaces", filename);
454
@@ -469,9 +472,7 @@ int do_proc_net_dev(int update_every, usec_t dt) {
472 }
473
474 if(unlikely(!ff)) {
472 - char filename[FILENAME_MAX + 1];
473 - snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, (*netdata_configured_host_prefix)?"/proc/1/net/dev":"/proc/net/dev");
474 - ff = procfile_open(config_get(CONFIG_SECTION_PLUGIN_PROC_NETDEV, "filename to monitor", filename), " \t,:|", PROCFILE_FLAG_DEFAULT);
475 + ff = procfile_open(proc_net_dev_filename, " \t,|", PROCFILE_FLAG_DEFAULT);
476 if(unlikely(!ff)) return 1;
477 }
478
@@ -492,7 +493,11 @@ int do_proc_net_dev(int update_every, usec_t dt) {
493 // require 17 words on each line
494 if(unlikely(procfile_linewords(ff, l) < 17)) continue;
495
495 - struct netdev *d = get_netdev(procfile_lineword(ff, l, 0));
496 + char *name = procfile_lineword(ff, l, 0);
497 + size_t len = strlen(name);
498 + if(name[len - 1] == ':') name[len - 1] = '\0';
499 +
500 + struct netdev *d = get_netdev(name);
501 d->updated = 1;
502 netdev_found++;
503
@@ -583,6 +588,17 @@ int do_proc_net_dev(int update_every, usec_t dt) {
588 d->tcarrier = str2kernel_uint_t(procfile_lineword(ff, l, 15));
589 }
590
591 + //info("PROC_NET_DEV: %s speed %zu, bytes %zu/%zu, packets %zu/%zu/%zu, errors %zu/%zu, drops %zu/%zu, fifo %zu/%zu, compressed %zu/%zu, rframe %zu, tcollisions %zu, tcarrier %zu"
592 + // , d->name, d->speed
593 + // , d->rbytes, d->tbytes
594 + // , d->rpackets, d->tpackets, d->rmulticast
595 + // , d->rerrors, d->terrors
596 + // , d->rdrops, d->tdrops
597 + // , d->rfifo, d->tfifo
598 + // , d->rcompressed, d->tcompressed
599 + // , d->rframe, d->tcollisions, d->tcarrier
600 + // );
601 +
602 // --------------------------------------------------------------------
603
604 if(unlikely((d->do_bandwidth == CONFIG_BOOLEAN_AUTO && (d->rbytes || d->tbytes))))
web/gui/dashboard.js
+1
@@ -637,6 +637,7 @@ if (typeof String.prototype.startsWith !== 'function') {
637 NETDATA.name2id = function (s) {
638 return s
639 .replace(/ /g, '_')
640 + .replace(/:/g, '_')
641 .replace(/\(/g, '_')
642 .replace(/\)/g, '_')
643 .replace(/\./g, '_')
web/gui/index.html
+1 -1
@@ -1298,6 +1298,6 @@
1298 </div>
1299 </div>
1300 <div id="hiddenDownloadLinks" style="display: none;" hidden></div>
1301 - <script type="text/javascript" src="dashboard.js?v20181013-2"></script>
1301 + <script type="text/javascript" src="dashboard.js?v20181114-1"></script>
1302 </body>
1303 </html>
web/gui/src/dashboard.js/compatibility.js
+1
@@ -32,6 +32,7 @@ if (typeof String.prototype.startsWith !== 'function') {
32 NETDATA.name2id = function (s) {
33 return s
34 .replace(/ /g, '_')
35 + .replace(/:/g, '_')
36 .replace(/\(/g, '_')
37 .replace(/\)/g, '_')
38 .replace(/\./g, '_')