noroadsleft000 / gnome-network-stats

Gnome extension for showing network speed and data usage.
MIT License
23 stars 7 forks source link

Restart does not help after first installation #54

Closed mindsuru closed 1 week ago

mindsuru commented 11 months ago
Aug 08 18:08:59 T470s gnome-shell[1642]: JS ERROR: Extension network-stats@gnome.noroadsleft.xyz: TypeError: device is null
                                         _getIPAddress@/home/alex/.local/share/gnome-shell/extensions/network-stats@gnome.noroadsleft.xyz/net/DeviceMonitor.js:176:13
                                         _loadDevices@/home/alex/.local/share/gnome-shell/extensions/network-stats@gnome.noroadsleft.xyz/net/DeviceMonitor.js:111:36
                                         init@/home/alex/.local/share/gnome-shell/extensions/network-stats@gnome.noroadsleft.xyz/net/DeviceMonitor.js:80:14
                                         DeviceMonitorClass@/home/alex/.local/share/gnome-shell/extensions/network-stats@gnome.noroadsleft.xyz/net/DeviceMonitor.js:23:14
                                         AppClass@/home/alex/.local/share/gnome-shell/extensions/network-stats@gnome.noroadsleft.xyz/App.js:24:31
                                         instance@/home/alex/.local/share/gnome-shell/extensions/network-stats@gnome.noroadsleft.xyz/App.js:13:52
                                         enable@/home/alex/.local/share/gnome-shell/extensions/network-stats@gnome.noroadsleft.xyz/extension.js:17:9
DEBUG net/DeviceMonitor.js::_loadDevices(100) 5 - wlp58s0:       0       0    0    0    0     0          0         0        0       0    0    0    0     0       0          0
INFO net/DeviceMonitor.js::_getIPAddress(188) No IP addresses found for device 'enp0s31f6'
INFO extension.js::init(10) initializing Network Stats
INFO extension.js::enable(15) enabling Network Stats
DEBUG net/DeviceMonitor.js::_loadDevices(100) 2 - lo:   20895     192    0    0    0     0          0         0    20895     192    0    0    0     0       0          0
DEBUG net/DeviceMonitor.js::_loadDevices(100) 3 - enp0s31f6:       0       0    0    0    0     0          0         0        0       0    0    0    0     0       0          0
DEBUG net/DeviceMonitor.js::_loadDevices(100) 4 - wwan0:  131761     270    0    0    0     0          0         0    64118     326    0    0    0     0       0          0
DEBUG net/DeviceMonitor.js::_loadDevices(100) 5 - wlp58s0:       0       0    0    0    0     0          0         0        0       0    0    0    0     0       0          0
DEBUG net/DeviceMonitor.js::_loadDevices(100) 6 - tun0:   58068     111    0    0    0     0          0         0    30081     139    0    0    0     0       0          0
INFO net/DeviceMonitor.js::_getIPAddress(188) No IP addresses found for device 'enp0s31f6'
mindsuru commented 11 months ago

I don't understand exactly why it is the way it was, but at least it works now. As far as I know, the Java framework works with nmcli and reads the data from /proc/net/dev and there is a small problem with me. My modem is called wwan0 in the path mentioned. With nmcli device status, however, I get the name cdc-wdm0 for the interface. Therefore I got an error in the file deviceMonitor.js that device = null. I have therefore changed the function _loadDevices() slightly. It is anything but nice, but it works for now.

        for (const name of devices) {
            let deviceObj;
            if (name == 'wwan0'){
                deviceObj = this._client.get_device_by_iface('cdc-wdm0');
            } else {
                deviceObj = this._client.get_device_by_iface(name);
            }
            const addresses = this._getIPAddress(deviceObj, GLib.SYSDEF_AF_INET);
            const type = this.getDeviceTypeFromDevice(deviceObj);
            this._devices[name] = {
                name,
                type,
                device: deviceObj,
                ip: addresses[0] || ""
            };
        }
noroadsleft000 commented 2 months ago

@mindsuru Can you check what does below comands print ? ifconfig ls /sys/class/net If these commands are giving us correct value we can think of using it depending on compatibility and consistency, otherwise we will add a safety check to avoid the crash.

mindsuru commented 2 months ago

`ifconfig enp0s31f6: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500 ether 54:e1:ad:b4:7b:d3 txqueuelen 1000 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 device interrupt 16 memory 0xdc200000-dc220000

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10 loop txqueuelen 1000 (Lokale Schleife) RX packets 109135 bytes 11480053 (11.4 MB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 109135 bytes 11480053 (11.4 MB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

lxcbr0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500 inet ----------- netmask 255.255.255.0 broadcast ----------- ether ----------- txqueuelen 1000 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

tun0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST> mtu 1330 inet ----------- netmask 255.255.255.0 destination ----------- inet6 ----------- prefixlen 64 scopeid 0x20 unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen 500 (UNSPEC) RX packets 19840 bytes 7264648 (7.2 MB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 20863 bytes 4083116 (4.0 MB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

wlp58s0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500 ether 9c:da:3e:7c:cb:2b txqueuelen 1000 (Ethernet) RX packets 59920 bytes 69032469 (69.0 MB) RX errors 0 dropped 3421 overruns 0 frame 0 TX packets 20997 bytes 5852551 (5.8 MB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

wwan0: flags=4291<UP,BROADCAST,RUNNING,NOARP,MULTICAST> mtu 1430 inet ----------- netmask 255.255.255.224 broadcast ----------- inet6 ----------- prefixlen 64 scopeid 0x0 inet6 ----------- prefixlen 64 scopeid 0x0 inet6 ----------- prefixlen 64 scopeid 0x0 ether ----------- txqueuelen 1000 (Ethernet) RX packets 34362 bytes 26771948 (26.7 MB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 28481 bytes 6411450 (6.4 MB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0`

ls /sys/class/net enp0s31f6 lo lxcbr0 tun0 wlp58s0 wwan0

noroadsleft000 commented 1 week ago

Doesn't look like a problem with the output inteface names are correct. I don't think we can add some workaround for this. But will add safety check in next release.