RPi-Monitor icon indicating copy to clipboard operation
RPi-Monitor copied to clipboard

Enhancement : display WiFi bitrate, transmission power and signal level

Open Bbox77 opened this issue 6 years ago • 1 comments

It is based on this other request . Those values are displayed under Wifi on the Status tab and in the same graph on the Statistics tab. It is based on wlan.conf


#######################################################################
# Extract WiFi information
#  Page: 1
#  Information               Status     Statistics
#  - received                - yes      - yes
#  - sent                    - yes      - yes
#  - bitrate                 - yes      - yes
#  - TX power                - yes      - yes
#  - signal strength         - yes      - yes
########################################################################

dynamic.1.name=wifi_received
dynamic.1.source=/sys/class/net/wlan0/statistics/rx_bytes
dynamic.1.regexp=(.*)
dynamic.1.postprocess=$1*-1
dynamic.1.rrd=DERIVE
dynamic.1.max=0

dynamic.2.name=wifi_send
dynamic.2.source=/sys/class/net/wlan0/statistics/tx_bytes
dynamic.2.regexp=(.*)
dynamic.2.postprocess=
dynamic.2.rrd=DERIVE
dynamic.2.min=0

dynamic.3.name=wifi_bitrate
dynamic.3.source=iwconfig wlan0 | grep Bit
dynamic.3.regexp=Bit Rate=(\d*\.?\d)
dynamic.3.postprocess=
dynamic.3.rrd=GAUGE

dynamic.4.name=wifi_txpower
dynamic.4.source=iwconfig wlan0 | grep Power
dynamic.4.regexp=Power=(\d*)
dynamic.4.postprocess=
dynamic.4.rrd=GAUGE

dynamic.5.name=wifi_signallevel
dynamic.5.source=iwconfig wlan0 | grep Signal
dynamic.5.regexp=Signal level=(-?\d*)
dynamic.5.postprocess=
dynamic.5.rrd=GAUGE

web.status.1.content.1.name=WiFi
web.status.1.content.1.icon=wifi.png
web.status.1.content.1.line.1="WiFi Sent: <b>"+KMG(data.wifi_send)+"<i class='icon-arrow-up'></i></b> Received: <b>"+KMG(Math.abs(data.wifi_received)) + "<i class='icon-arrow-down'></i></b>"
web.status.1.content.1.line.2="Bit Rate: <b>"+data.wifi_bitrate+" Mb/s</b>"
web.status.1.content.1.line.3="Tx Power: <b>"+data.wifi_txpower+" dBm</b>"
web.status.1.content.1.line.4="Signal level: <b>"+data.wifi_signallevel+" dBm</b>"

web.statistics.1.content.1.name=WiFi
web.statistics.1.content.1.graph.1=wifi_send
web.statistics.1.content.1.graph.2=wifi_received
web.statistics.1.content.1.graph_options.yaxis={ tickFormatter: function (v) { if (Math.abs(v) > 1048576) return (Math.round(v*10/1024/1024)/10) + " MiB/s" ; if (Math.abs(v) > 1024) return (Math.round(v*10/1024)/10) + " KiB/s" ; else return v + " B/s" }, }
web.statistics.1.content.1.ds_graph_options.wifi_send.label=Upload bandwidth (bits)
web.statistics.1.content.1.ds_graph_options.wifi_send.lines={ fill: true }
web.statistics.1.content.1.ds_graph_options.wifi_send.color="#FF7777"
web.statistics.1.content.1.ds_graph_options.wifi_received.label=Download bandwidth (bits)
web.statistics.1.content.1.ds_graph_options.wifi_received.lines={ fill: true }
web.statistics.1.content.1.ds_graph_options.wifi_received.color="#77FF77"

web.statistics.1.content.2.name=Wifi stats
web.statistics.1.content.2.graph.1=wifi_bitrate
web.statistics.1.content.2.ds_graph_options.wifi_bitrate.label=speed
web.statistics.1.content.2.graph.2=wifi_txpower
web.statistics.1.content.2.ds_graph_options.wifi_txpower.label=tx power
web.statistics.1.content.2.graph.3=wifi_signallevel
web.statistics.1.content.2.ds_graph_options.wifi_signallevel.label=signal strength

Bbox77 avatar Apr 02 '18 23:04 Bbox77

The proposed code doesn't work with every Wifi Adapter. For example on mine the Bit Rate is displayed on iwconfig as "Bit Rate:54 Mb/s" instead of "Bit Rate=54 Mb/s" as your code seem to expect. Also, my wifi adapter doesn't support power management, and it showed up as "Tx Power: dBm" on the status page, I like "Tx Power: 0 dBm" more.

Here is an improved version:

#######################################################################
# Extract WiFi information
#  Page: 1
#  Information               Status     Statistics
#  - received                - yes      - yes
#  - sent                    - yes      - yes
#  - bitrate                 - yes      - yes
#  - TX power                - yes      - yes
#  - signal strength         - yes      - yes
########################################################################

dynamic.1.name=wifi_received
dynamic.1.source=/sys/class/net/wlan0/statistics/rx_bytes
dynamic.1.regexp=(.*)
dynamic.1.postprocess=$1*-1
dynamic.1.rrd=DERIVE
dynamic.1.max=0

dynamic.2.name=wifi_send
dynamic.2.source=/sys/class/net/wlan0/statistics/tx_bytes
dynamic.2.regexp=(.*)
dynamic.2.postprocess=
dynamic.2.rrd=DERIVE
dynamic.2.min=0

dynamic.3.name=wifi_bitrate
dynamic.3.source=iwconfig wlan0 | grep Bit
dynamic.3.regexp=Bit Rate=|\:(\d*\.?\d)
dynamic.3.postprocess=
dynamic.3.rrd=GAUGE

dynamic.4.name=wifi_txpower
dynamic.4.source=iwconfig wlan0 | grep Power
dynamic.4.regexp=Power=|\:(\d*)
dynamic.4.postprocess=
dynamic.4.rrd=GAUGE

dynamic.5.name=wifi_signallevel
dynamic.5.source=iwconfig wlan0 | grep Signal
dynamic.5.regexp=Signal level=|\:(-?\d*)
dynamic.5.postprocess=
dynamic.5.rrd=GAUGE

web.status.1.content.1.name=WiFi
web.status.1.content.1.icon=wifi.png
web.status.1.content.1.line.1="WiFi Sent: <b>"+KMG(data.wifi_send)+"<i class='icon-arrow-up'></i></b> Received: <b>"+KMG(Math.abs(data.wifi_received)) + "<i class='icon-arrow-down'></i></b>"
web.status.1.content.1.line.2="Bit Rate: <b>"+Math.abs(data.wifi_bitrate)+" Mb/s</b>"
web.status.1.content.1.line.3="Tx Power: <b>"+Math.abs(data.wifi_txpower)+" dBm</b>"
web.status.1.content.1.line.4="Signal level: <b>"+Math.abs(data.wifi_signallevel)+" dBm</b>"

web.statistics.1.content.1.name=WiFi
web.statistics.1.content.1.graph.1=wifi_send
web.statistics.1.content.1.graph.2=wifi_received
web.statistics.1.content.1.graph_options.yaxis={ tickFormatter: function (v) { if (Math.abs(v) > 1048576) return (Math.round(v*10/1024/1024)/10) + " MiB/s" ; if (Math.abs(v) > 1024) return (Math.round(v*10/1024)/10) + " KiB/s" ; else return v + " B/s" }, }
web.statistics.1.content.1.ds_graph_options.wifi_send.label=Upload bandwidth (bits)
web.statistics.1.content.1.ds_graph_options.wifi_send.lines={ fill: true }
web.statistics.1.content.1.ds_graph_options.wifi_send.color="#FF7777"
web.statistics.1.content.1.ds_graph_options.wifi_received.label=Download bandwidth (bits)
web.statistics.1.content.1.ds_graph_options.wifi_received.lines={ fill: true }
web.statistics.1.content.1.ds_graph_options.wifi_received.color="#77FF77"

web.statistics.1.content.2.name=Wifi stats
web.statistics.1.content.2.graph.1=wifi_bitrate
web.statistics.1.content.2.ds_graph_options.wifi_bitrate.label=speed
web.statistics.1.content.2.graph.2=wifi_txpower
web.statistics.1.content.2.ds_graph_options.wifi_txpower.label=tx power
web.statistics.1.content.2.graph.3=wifi_signallevel
web.statistics.1.content.2.ds_graph_options.wifi_signallevel.label=signal strength

NeoPolus avatar Jul 03 '18 10:07 NeoPolus