How to monitor wifi signal strength and speed with PRTG Network Monitor

Two days ago I set up 4 low-cost Windows 10 tablets to become cheap monitoring stations (we call them “remote probes”) for my personal instance of PRTG Network Monitor.

Today I have set up a custom sensor that reads out the wifi signal strength from the system, so I can now monitor the quality of my wireless network in 4 different areas of my house when I distribute the tablets in different rooms.

The sensor can be used with all Windows 10 PCs, laptops, or tablets, as long as they are connected to the network via wifi. It also displays the transmit and receive rate which the wifi module has chosen to connect to the access point and the wifi channel.

Preparing the monitoring station (64bit Windows only)

Before you can use the custom sensor you must set a policy.

Note: If your probe system is running 64bit Windows you need to explicitly perform the following step with the 32-bit Powershell, see this knowledge base article for instructions.

To do this start Powershell with administration rights (hit the Windows key, enter “powershell”, right click the powershell icon and choose “Run as Administrator”) and paste the following command into the shell:

Set-ExecutionPolicy RemoteSigned

The result looks like this:

 PS C:\WINDOWS\system32> Set-ExecutionPolicy RemoteSigned 

Execution Policy Change The execution policy helps protect you from 
scripts that you do not trust. Changing the execution policy might 
expose you to the security risks described in the 
about_Execution_Policies help topic at 
http://go.microsoft.com/fwlink/?LinkID=135170. Do you want to 
change the execution policy? 
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help 
(default is "N"):

Hit “A” and press return.

Now you can already test the sensor code: paste the sensor code from below and hit return. You should see a result similar to this:

signal-2

If you see an error message then either the wifi is not properly connected or your Windows installation is not using English for its output (then you need to adapt some localized strings in the script).

The script

For this I am using the Exe/Script Advanced Sensor which gives me the possibility to write scripts in Powershell (or any other language, as long as it can send its results to the standard console).

This is the script:

try{
 $adapter = (netsh wlan show interfaces)
 $state = $adapter -match '^\s+State' -Replace '^\s+State\s+:\s+','' 
 
 if ($state -eq 'connected'){

 $SSID = $adapter -match '^\s+SSID' -Replace '^\s+SSID\s+:\s+','' 
 $channel = $adapter -match '^\s+Channel' -Replace '^\s+Channel\s+:\s+',''
 foreach ($el in $adapter -match '^\s+Signal' -Replace '^\s+Signal\s+:\s+','' -replace '%',''){
 $signal = $el.ToString()
 }

 $rx = ($adapter -match '^\s+Receive' -Replace '^\s+Receive\s+:\s+','').split(":")[1]
 $tx = ($adapter -match '^\s+Transmit' -Replace '^\s+Transmit\s+:\s+','').split(":")[1]
 

 Write-Host "<prtg>"
 Write-Host "<result>"
 Write-Host("<channel>Signal Strength</channel>")
 Write-Host("<value>{0}</value>" -f $signal.Trim())
 Write-Host("<unit>Percent</unit>")
 Write-Host "</result>"
 Write-Host "<result>"
 Write-Host("<channel>Channel</channel>")
 Write-Host("<value>{0}</value>" -f $channel)
 Write-Host "</result>"
 Write-Host "<result>"
 Write-Host("<channel>Receive Rate (Mbps) </channel>")
 Write-Host("<value>{0}</value>" -f $rx.ToString().Trim())
 Write-Host("<unit>Custom</unit>")
 Write-Host("<CustomUnit>Mbps</CustomUnit>")
 Write-Host "</result>"
 Write-Host "<result>"
 Write-Host("<channel>Transmit Rate (Mbps)</channel>")
 Write-Host("<value>{0}</value>" -f $tx.ToString().Trim())
 Write-Host("<unit>Custom</unit>")
 Write-Host("<CustomUnit>Mbps</CustomUnit>")
 Write-Host "</result>"
 Write-Host("<text>Current Network: {0}</text>" -f $SSID)
 Write-Host "</prtg>"
 }
 else{
 Write-Host "<prtg>"
 Write-Host "<error>1</error>"
 Write-Host "<text>Adapter disconnected</text>"
 Write-Host "</prtg>"
 }
} 
catch{
 Write-Host "<prtg>"
 Write-Host "<error>1</error>"
 Write-Host "<text>Something went wrong</text>"
 Write-Host "</prtg>"

}

This script (I am using the filename wifi signal strength.ps1) must be placed into the folder

C:\Program Files\PRTG Network Monitor\Custom Sensors\EXEXML

Now you can add a new “EXE/Script Advanced” sensor (I would recommend adding the sensor to the probe device) and select “wifi signal strength.ps1” in the dropdown for the “EXE/Script” setting. That’s it. You are now monitoring the wifi.

Author: Dirk Paessler

CEO Carbon Drawdown Initiative -- VP Negative Emissions Platform -- Founder and Chairman Paessler AG