luci
luci copied to clipboard
luci-mod-status: introduce ethernet port status view
This commit adds an ethernet port status overview to the main status page.
The design should theoretically scale to many ports. Below is a mock up created by repeating the six original ports multiple times:
Logical network membership and detailled statistics are exposed as tooltips:
Original forum topic: https://forum.openwrt.org/t/ethernet-port-icons-on-openwrt/130799
I used wrt32x test, lan zone does not display correctly. I guess is it possible to make the port image not refresh, only the data?
I used wrt32x test, lan zone does not display correctly.
~~Could your share your /etc/config/network and /etc/config/firewall so I can figure out why?~~
I think I could reproduce the issue, should be fixed now.
I guess is it possible to make the port image not refresh, only the data?
It could certainly be implemented but it would complicate the code somewhat (it's easier to render everything from scratch all the time). Apart from that, we do want to image to update, e.g. when cable is plugged or unplugged.
Is it causing flickering in your case or why do you want to prevent the refresh?
I used wrt32x test, lan zone does not display correctly.
~Could your share your /etc/config/network and /etc/config/firewall so I can figure out why?~
I think I could reproduce the issue, should be fixed now.
I guess is it possible to make the port image not refresh, only the data?
It could certainly be implemented but it would complicate the code somewhat (it's easier to render everything from scratch all the time). Apart from that, we do want to image to update, e.g. when cable is plugged or unplugged.
Is it causing flickering in your case or why do you want to prevent the refresh?
Tested, Lan zone is displayed correctly.
In a router with a built-in switch, plugging and unplugging the network cable does not display the port status correctly, so I think it is possible to prohibit refreshing the port picture to avoid the page flickering problem.
In a router with a built-in switch, plugging and unplugging the network cable does not display the port status correctly
This might be something special about the WRT32x actually. On my er-x and mir3g devices (both mediatek with builtin switch) the port status does correctly update. I'll think some more about it.
Tested with an x86 multi-NIC router today and found that only two ports are displayed.
Nice improvement, seems to work well for me:
Tested with an x86 multi-NIC router today and found that only two ports are displayed.
Yes, this is expected. Can you try to add the missing eth interfaces to /etc/board.json
?
Tested with an x86 multi-NIC router today and found that only two ports are displayed.
Yes, this is expected. Can you try to add the missing eth interfaces to
/etc/board.json
?
Yes, it can be displayed normally after manually adding /etc/board.json information.
Hi, For Linksys WRT1200AC it is OK, but for ZTE MF286D it looks unusual (I had LAN3 connected to my computer).
@jow- How can I add a translation file for this add-on?
What's the contents of /etc/board.json for the ZTE MF286D?
What's the contents of /etc/board.json for the ZTE MF286D?
{
"model": {
"id": "zte,mf286d",
"name": "ZTE MF286D"
},
"network": {
"lan": {
"device": "eth0",
"protocol": "static"
},
"wan": {
"device": "eth1",
"protocol": "dhcp"
}
},
"switch": {
"switch0": {
"enable": true,
"reset": true,
"ports": [
{
"num": 0,
"device": "eth0",
"need_tag": false,
"want_untag": true
},
{
"num": 2,
"role": "lan",
"index": 4
},
{
"num": 3,
"role": "lan",
"index": 3
},
{
"num": 4,
"role": "lan",
"index": 2
},
{
"num": 0,
"device": "eth1",
"need_tag": false,
"want_untag": true
},
{
"num": 5,
"role": "wan"
}
],
"roles": [
{
"role": "lan",
"ports": "2 3 4 0",
"device": "eth0"
},
{
"role": "wan",
"ports": "5 0",
"device": "eth1"
}
]
}
},
"gpioswitch": {
"power_btn_block": {
"name": "Power button blocker",
"pin": "421",
"default": 0
}
}
}
Ah, swconfig. That'll be harder to support since most switches do not expose per-port stats. Can you provide the output of swconfig dev switch0 help
and swconfig dev switch0 show
too?
No problem, please here are the command results:
swconfig dev switch0 help
switch0: 90000.mdio-1(QCA AR40xx), ports: 6 (cpu @ 0), vlans: 128
--switch
Attribute 1 (int): enable_vlan (Enable VLAN mode)
Attribute 2 (none): reset_mibs (Reset all MIB counters)
Attribute 3 (int): enable_mirror_rx (Enable mirroring of RX packets)
Attribute 4 (int): enable_mirror_tx (Enable mirroring of TX packets)
Attribute 5 (int): mirror_monitor_port (Mirror monitor port)
Attribute 6 (int): mirror_source_port (Mirror source port)
Attribute 7 (int): linkdown (Link down all the PHYs)
Attribute 8 (none): apply (Activate changes in the hardware)
Attribute 9 (none): reset (Reset the switch)
--vlan
Attribute 1 (int): vid (VLAN ID (0-4094))
Attribute 2 (ports): ports (VLAN port mapping)
--port
Attribute 1 (none): reset_mib (Reset single port MIB counters)
Attribute 2 (string): mib (Get port's MIB counters)
Attribute 3 (int): pvid (Primary VLAN ID)
Attribute 4 (unknown): link (Get port link information)
swconfig dev switch0 show
Global attributes:
enable_vlan: 1
enable_mirror_rx: 0
enable_mirror_tx: 0
mirror_monitor_port: 0
mirror_source_port: 0
linkdown: ???
Port 0:
mib: Port 0 MIB counters
RxBroad : 7
RxPause : 0
RxMulti : 39
RxFcsErr : 0
RxAlignErr : 0
RxRunt : 0
RxFragment : 0
Rx64Byte : 323
Rx128Byte : 562
Rx256Byte : 185
Rx512Byte : 128
Rx1024Byte : 151
Rx1518Byte : 2019
RxMaxByte : 0
RxTooLong : 0
RxGoodByte : 3143831
RxBadByte : 0
RxOverFlow : 0
Filtered : 0
TxBroad : 167
TxPause : 0
TxMulti : 1200
TxUnderRun : 0
Tx64Byte : 9
Tx128Byte : 2602
Tx256Byte : 626
Tx512Byte : 83
Tx1024Byte : 189
Tx1518Byte : 64
TxMaxByte : 0
TxOverSize : 0
TxByte : 574409
TxCollision : 0
TxAbortCol : 0
TxMultiCol : 0
TxSingleCol : 0
TxExcDefer : 0
TxDefer : 0
TxLateCol : 0
pvid: 2
link: port:0 link:up speed:1000baseT full-duplex txflow rxflow
Port 1:
mib: Port 1 MIB counters
RxBroad : 0
RxPause : 0
RxMulti : 0
RxFcsErr : 0
RxAlignErr : 0
RxRunt : 0
RxFragment : 0
Rx64Byte : 0
Rx128Byte : 0
Rx256Byte : 0
Rx512Byte : 0
Rx1024Byte : 0
Rx1518Byte : 0
RxMaxByte : 0
RxTooLong : 0
RxGoodByte : 0
RxBadByte : 0
RxOverFlow : 0
Filtered : 0
TxBroad : 0
TxPause : 0
TxMulti : 0
TxUnderRun : 0
Tx64Byte : 0
Tx128Byte : 0
Tx256Byte : 0
Tx512Byte : 0
Tx1024Byte : 0
Tx1518Byte : 0
TxMaxByte : 0
TxOverSize : 0
TxByte : 0
TxCollision : 0
TxAbortCol : 0
TxMultiCol : 0
TxSingleCol : 0
TxExcDefer : 0
TxDefer : 0
TxLateCol : 0
pvid: 1
link: port:1 link:down
Port 2:
mib: Port 2 MIB counters
RxBroad : 0
RxPause : 0
RxMulti : 0
RxFcsErr : 0
RxAlignErr : 0
RxRunt : 0
RxFragment : 0
Rx64Byte : 0
Rx128Byte : 0
Rx256Byte : 0
Rx512Byte : 0
Rx1024Byte : 0
Rx1518Byte : 0
RxMaxByte : 0
RxTooLong : 0
RxGoodByte : 0
RxBadByte : 0
RxOverFlow : 0
Filtered : 0
TxBroad : 0
TxPause : 0
TxMulti : 0
TxUnderRun : 0
Tx64Byte : 0
Tx128Byte : 0
Tx256Byte : 0
Tx512Byte : 0
Tx1024Byte : 0
Tx1518Byte : 0
TxMaxByte : 0
TxOverSize : 0
TxByte : 0
TxCollision : 0
TxAbortCol : 0
TxMultiCol : 0
TxSingleCol : 0
TxExcDefer : 0
TxDefer : 0
TxLateCol : 0
pvid: 1
link: port:2 link:down
Port 3:
mib: Port 3 MIB counters
RxBroad : 0
RxPause : 0
RxMulti : 0
RxFcsErr : 0
RxAlignErr : 0
RxRunt : 0
RxFragment : 0
Rx64Byte : 0
Rx128Byte : 0
Rx256Byte : 0
Rx512Byte : 0
Rx1024Byte : 0
Rx1518Byte : 0
RxMaxByte : 0
RxTooLong : 0
RxGoodByte : 0
RxBadByte : 0
RxOverFlow : 0
Filtered : 0
TxBroad : 0
TxPause : 0
TxMulti : 0
TxUnderRun : 0
Tx64Byte : 0
Tx128Byte : 0
Tx256Byte : 0
Tx512Byte : 0
Tx1024Byte : 0
Tx1518Byte : 0
TxMaxByte : 0
TxOverSize : 0
TxByte : 0
TxCollision : 0
TxAbortCol : 0
TxMultiCol : 0
TxSingleCol : 0
TxExcDefer : 0
TxDefer : 0
TxLateCol : 0
pvid: 1
link: port:3 link:down
Port 4:
mib: Port 4 MIB counters
RxBroad : 167
RxPause : 0
RxMulti : 1200
RxFcsErr : 0
RxAlignErr : 0
RxRunt : 0
RxFragment : 0
Rx64Byte : 1019
Rx128Byte : 1608
Rx256Byte : 626
Rx512Byte : 76
Rx1024Byte : 189
Rx1518Byte : 63
RxMaxByte : 0
RxTooLong : 0
RxGoodByte : 561117
RxBadByte : 0
RxOverFlow : 0
Filtered : 0
TxBroad : 7
TxPause : 0
TxMulti : 39
TxUnderRun : 0
Tx64Byte : 323
Tx128Byte : 583
Tx256Byte : 178
Tx512Byte : 128
Tx1024Byte : 154
Tx1518Byte : 2018
TxMaxByte : 0
TxOverSize : 0
TxByte : 3136499
TxCollision : 0
TxAbortCol : 0
TxMultiCol : 0
TxSingleCol : 0
TxExcDefer : 0
TxDefer : 0
TxLateCol : 0
pvid: 1
link: port:4 link:up speed:1000baseT full-duplex auto
Port 5:
mib: Port 5 MIB counters
RxBroad : 0
RxPause : 0
RxMulti : 0
RxFcsErr : 0
RxAlignErr : 0
RxRunt : 0
RxFragment : 0
Rx64Byte : 0
Rx128Byte : 0
Rx256Byte : 0
Rx512Byte : 0
Rx1024Byte : 0
Rx1518Byte : 0
RxMaxByte : 0
RxTooLong : 0
RxGoodByte : 0
RxBadByte : 0
RxOverFlow : 0
Filtered : 0
TxBroad : 0
TxPause : 0
TxMulti : 0
TxUnderRun : 0
Tx64Byte : 0
Tx128Byte : 0
Tx256Byte : 0
Tx512Byte : 0
Tx1024Byte : 0
Tx1518Byte : 0
TxMaxByte : 0
TxOverSize : 0
TxByte : 0
TxCollision : 0
TxAbortCol : 0
TxMultiCol : 0
TxSingleCol : 0
TxExcDefer : 0
TxDefer : 0
TxLateCol : 0
pvid: 2
link: port:5 link:down
VLAN 1:
vid: 1
ports: 0t 2 3 4
VLAN 2:
vid: 2
ports: 0 5
The topic seems to have died, so I will answer myself the question I asked (maybe it will be useful to someone), to adjust the language we modify the file:
feeds / luci / modules / luci-base / po / language / base.po
Tested with an x86 multi-NIC router today and found that only two ports are displayed.
Yes, this is expected. Can you try to add the missing eth interfaces to
/etc/board.json
?Yes, it can be displayed normally after manually adding /etc/board.json information.
Can you share your board.json file as a reference for others?
Hey folks - I was curious if this could be extended for wireless interfaces as well as the generic ethernet devices? - I'm actually a ethernet only user on OpenWRT but I know for others it would be nice to have them in the same list but maybe with a slightly different logo?
Seems to scale nicely (pretty much unconfigured rtl8382 device).
@jow-
Yes, this is expected. Can you try to add the missing eth interfaces to /etc/board.json ?
I am also on X86_64, any chances to do it automatically through ifconfig?
My /etc/board.json also only containing 2 interface :
{
"model": {
"id": "default-string-default-string",
"name": "Default string Default string"
},
"network": {
"lan": {
"device": "eth0",
"protocol": "static"
},
"wan": {
"device": "eth1",
"protocol": "dhcp"
}
}
}
ifconfig :
br-lan Link encap:Ethernet HWaddr 00:xx:xx:xx:xx:25
inet addr:10.10.8.1 Bcast:10.10.15.255 Mask:255.255.248.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1001766 errors:0 dropped:118 overruns:0 frame:0
TX packets:43468988 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:75132293 (71.6 MiB) TX bytes:44377419208 (41.3 GiB)
docker0 Link encap:Ethernet HWaddr 02:42:94:F4:68:91
inet addr:172.17.0.1 Bcast:172.17.255.255 Mask:255.255.0.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
eth0 Link encap:Ethernet HWaddr 00:xx:xx:xx:xx:25
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:82881080 errors:0 dropped:242 overruns:0 frame:0
TX packets:138359957 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:54534987023 (50.7 GiB) TX bytes:94009168265 (87.5 GiB)
Memory:51400000-514fffff
eth1 Link encap:Ethernet HWaddr 00:xx:xx:xx:xx:26
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1858746 errors:0 dropped:2 overruns:0 frame:0
TX packets:2927515 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:479067399 (456.8 MiB) TX bytes:3306156566 (3.0 GiB)
Memory:51100000-511fffff
eth2 Link encap:Ethernet HWaddr 00:xx:xx:xx:xx:27
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Memory:50e00000-50efffff
eth3 Link encap:Ethernet HWaddr 00:xx:xx:xx:xx:28
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Memory:50b00000-50bfffff
eth4 Link encap:Ethernet HWaddr 00:xx:xx:xx:xx:29
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Memory:50800000-508fffff
eth5 Link encap:Ethernet HWaddr 00:xx:xx:xx:xx:2A
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:43450662 errors:0 dropped:0 overruns:0 frame:0
TX packets:84742190 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:42200567054 (39.3 GiB) TX bytes:55712328254 (51.8 GiB)
Memory:50500000-505fffff
ifb4pppoe-wan Link encap:Ethernet HWaddr xx:xx:xx:xx:xx:xx
inet6 addr: xxxx::xxxx:xxxx:xxxx:xxxx/64 Scope:Link
UP BROADCAST RUNNING NOARP MTU:1500 Metric:1
RX packets:5501217 errors:0 dropped:129 overruns:0 frame:0
TX packets:5501088 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:32
RX bytes:7876408660 (7.3 GiB) TX bytes:7876404532 (7.3 GiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:2074140 errors:0 dropped:0 overruns:0 frame:0
TX packets:2074140 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:96686777464 (90.0 GiB) TX bytes:96686777464 (90.0 GiB)
pppoe-wan Link encap:Point-to-Point Protocol
inet addr:123.123.123.123 P-t-P:123.123.123.1 Mask:255.255.255.255
inet6 addr: xxxx::xxxx:xxxx:xxxx:xxxx/128 Scope:Link
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1492 Metric:1
RX packets:5549923 errors:0 dropped:0 overruns:0 frame:0
TX packets:10269671 errors:0 dropped:129 overruns:0 carrier:0
collisions:0 txqueuelen:3
RX bytes:7949047123 (7.4 GiB) TX bytes:746020183 (711.4 MiB)
I am also on X86_64, any chances to do it automatically through ifconfig?
Through ifconfig, no. Personally I'm carrying this patch locally:
--- a/target/linux/x86/base-files/etc/board.d/02_network
+++ b/target/linux/x86/base-files/etc/board.d/02_network
@@ -29,6 +29,9 @@ pc-engines-apu1|pc-engines-apu2|pc-engin
roqos-roqos-core-rc10)
ucidef_set_interfaces_lan_wan "eth1" "eth0"
;;
+r-s-cybersecurity-gateprotect-gmbh-gp-7543)
+ ucidef_set_interfaces_lan_wan "eth0 eth1 eth2" "eth3"
+ ;;
sophos-sg-105r1|sophos-xg-105r1| \
sophos-sg-105wr1|sophos-xg-105wr1| \
sophos-sg-105r2|sophos-xg-105r2| \
How to make the interface display centered, the current one is on the left, and it is too close to the left border!
In 22.03, the luci mod status index.json file does not correspond to the location of "/etc/board. json": ["read"]. Where should luci mod status index.json be filled in?
{
"model": {
"id": "default-string-default-string",
"name": "Default string Default string"
},
"network": {
"lan": {
"device": "eth0",
"protocol": "static"
},
"wan": {
"device": "eth3",
"protocol": "pppoe"
}
}
}
Only two interfaces can be displayed
Can this be merged before the planned 23.xx branch?
This is a very good feature for routers using DSA. :clap: The swconfig could be unsupported for now and someone could add the support later. In the meantime, there is the possibility that it would be said that this is only a DSA feature. Because of that, I advise to merge this so it is included in the upcoming OpenWrt 23.xx version as suggested by @Borromini.
@jow- Do you consider this ready for merge or is the swconfig incompatibility an issue? I suppose a check for DSA could be provided so the port status view only appears on DSA targets?
Tested this PR on April snapshot on Fritz!Box 7530.
Changes made
wget -O /www/luci-static/resources/view/status/include/29_ports.js \
https://raw.githubusercontent.com/openwrt/luci/ee6e9d5835a30caa9ac1870cbd2d1a16a0e8457f/\
modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/29_ports.js
vim /usr/share/rpcd/acl.d/luci-mod-status-index.json
# make manual line insertion here
service uhttpd restart
service rpcd restart
If there's a better way to test PRs I'd like to hear about it.
Result
Success.
File contents
# cat /etc/board.json
{
"model": {
"id": "avm,fritzbox-7530",
"name": "AVM FRITZ!Box 7530"
},
"led": {
"dsl": {
"name": "DSL",
"sysfs": "green:info",
"type": "netdev",
"device": "dsl0",
"mode": "link tx rx"
},
"wlan": {
"name": "WLAN",
"sysfs": "green:wlan",
"trigger": "phy0tpt"
}
},
"network": {
"lan": {
"ports": [
"lan1",
"lan2",
"lan3",
"lan4"
],
"protocol": "static"
},
"wan": {
"device": "dsl0",
"protocol": "pppoe",
"macaddr": "foo"
}
},
"dsl": {
"atmbridge": {
"vpi": 1,
"vci": 32,
"encaps": "llc",
"payload": "bridged",
"nameprefix": "dsl"
},
"modem": {
"type": "vdsl",
"annex": "j",
"tone": "b",
"xfer_mode": ""
}
},
"system": {
"compat_version": "1.1"
}
}
would be nice to see this on 23.xx w/ DSA yeah
Downloaded 23.x snapshot earlier today and it isnt there, would be nice, as DSA makes it harder to see port status now.
Will this be in the release of 23.xx?
@sjkhsl According to the above two code modifications, I displayed an error in OpenWrt-21.02! How did you solve it?