openwrt extended stats on switch0

I”ve got openwrt router netgear WNDR4300v1.
it contains switch. switch is controled by swconfig command :

root@my-home-wrt:~# swconfig list
Found: switch0 - ag71xx-mdio.0

default config of that switch doesn’t show any stats :

root@my-home-wrt:~# swconfig dev switch0 port 1 get mib
Failed to get attribute: Operation not supported

to enable stats on that switch you have to use command :

swconfig dev switch0 get ar8xxx_mib_poll_interval
swconfig dev switch0 set ar8xxx_mib_poll_interval 300

or to make this permanent change between reboots – use UCI:

uci set network.@switch[0].ar8xxx_mib_poll_interval='300'
uci set network.@switch[0].ar8xxx_mib_type='1'

now stats per port looks like this :

root@my-home-wrt:~# swconfig dev switch0 port 1 get mib
MIB counters
RxBroad : 779875
RxPause : 7771
RxMulti : 504114
RxFcsErr : 0
RxAlignErr : 0
RxRunt : 0
RxFragment : 0
Rx64Byte : 31376455
Rx128Byte : 71930802
Rx256Byte : 16088904
Rx512Byte : 1562670
Rx1024Byte : 998867
Rx1518Byte : 190126272
RxMaxByte : 0
RxTooLong : 0
RxGoodByte : 298938600957 (278.4 GiB)
RxBadByte : 497344
RxOverFlow : 0
Filtered : 6
TxBroad : 600681
TxPause : 953
TxMulti : 1282565
TxUnderRun : 0
Tx64Byte : 10658772
Tx128Byte : 54503715
Tx256Byte : 22269258
Tx512Byte : 4973296
Tx1024Byte : 4133447
Tx1518Byte : 324100239
TxMaxByte : 0
TxOverSize : 0
TxByte : 500203601610 (465.8 GiB)
TxCollision : 0
TxAbortCol : 0
TxMultiCol : 0
TxSingleCol : 0
TxExcDefer : 0
TxDefer : 0
TxLateCol : 0

now I’ve to pass this stats to librenms 🙂