I want to know if it is possible to monitor the amount of connected clients and their corresponding IP addresses?

Is there a solution for that particular scenario?


Article Comments

This article applies to PRTG Network Monitor 16 or later

Monitoring the Connected Clients of a bintec Access Point

If you want to monitor the connected clients of a bintec access point, use the following PowerShell (.ps1) script.

  • The script basically retrieves all entries under a specific OID, counts them, and exports the IP addresses.
  • The script uses the Net-SNMP library. You have to install it on the PRTG Core Server or the Remote Probe system you want to use the script on.

Requirements


How to Use the Script

  • Install the Net-SNMP library.
  • Save the script as a .ps1 file in the \Custom Sensors\EXEXML\ subdirectory of the PRTG program directory on the probe machine from where you want to check the access point.
#    ____  ____  ____________
#   / __ \/ __ \/_  __/ ____/
#  / /_/ / /_/ / / / / / __  
# / ____/ _, _/ / / / /_/ /  
#/_/   /_/ |_| /_/  \____/                         
#    NETWORK MONITOR
#-------------------
#(c) 2017 Dariusz Gorka, Paessler AG
#
# This script checks the connected clients of a bintec access point.
#

# Parameter "-hostaddr" for the remote host (bintec access point)
# Parameter "-community" for the SNMP v2c Community
# Parameter "-port" for the SNMP port of the device
# Parameter "-timeout" for the timeout of the request
# Parameter "-troubleshoot" for the troubleshooting of this script
param(
    [string]$hostaddr = "localhost",
    [string]$community = "public",
    [string]$port = "161",
    [string]$timeout = "5",
    [int]$troubleshoot = 0
)

$regex_string = "(STRING:..)(\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b)"
$regex_ipaddr = "(IpAddress:.)(\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b)"

[string[]] $walkresult = @(C:\usr\bin\snmpwalk.exe -Cc -Ln -On -v 2c -c $community $hostaddr":"$port ".1.3.6.1.4.1.272.4.46.5.1.54" -t $timeout 2>&1)

if ($troubleshoot -eq 1){
$walkresult_trouble = $walkresult -join ''
}

if (!($walkresult  -like "*= IpAddress: *" -or $walkresult  -like "*= String: *")){
    $clients = 0
} else {
    $clients = $walkresult.count

    for($i=0; $i -lt $walkresult.count; $i++){
        if ($walkresult  -like "*= IpAddress: *"){
            $walkresult[$i] = $walkresult[$i] -match $regex_ipaddr
        } else {
            $walkresult[$i] = $walkresult[$i] -match $regex_string
        }
        if ($i -eq ($walkresult.count -1)) {
            [string] $walkresult[$i] = $matches[2]
        } else {
            [string] $walkresult[$i] = $matches[2] + " - "
        }
    }

    [string]$walkresult_result = $walkresult -join ''
}


write-host "<prtg>"

write-host "<result>"
write-host "<channel>Connected Clients</channel>"
write-host "<value>$($clients)</value>"
write-host "</result>"

if($troubleshoot -eq 0){
    if (!($clients -eq 0)){
        write-host "<text>Clients: $($walkresult_result)</text>"
    }
}

if ($troubleshoot -eq 1){
write-host "<text>$($walkresult_trouble)</text>"
}

write-host "</prtg>"
  • Add an EXE/Script Advanced sensor.
  • In the sensor settings, select the above script from the dropdown list and provide the following under Parameters:

-hostaddr "<device-ip>" -community "<device-snmp-community>" -port "<device-snmp-port>"

  • Adjust the <device-ip>, <device-snmp-community>, and <device-snmp-port> parameters like in the examples below, depending on your scenario:
    • <device-ip>: 123.123.123.123
    • <device-snmp-community>: public
    • <device-snmp-port>: 161
  • You can also use the following placeholders:
    • <device-ip>: %host
    • <device-snmp-community>: %snmpcommunity
  • Click Continue to save your settings. You can now monitor the connected clients of a bintec access point.

Feb, 2017 - Permalink