I'm trying get PRTG to give me the number of clients attached to our AP's.
I have an snmp command:
snmpwalk -v2c -c COMMUNITY ADDRESS SNMPv2-SMI::enterprises.14823.2.3.3.1.2.4.1.3 |
This will return a list of clients connected, so by adding | wc -l I can count them
snmpwalk -v2c -c xxx xxx SNMPv2-SMI::enterprises.14823.2.3.3.1.2.4.1.3 | wc -l |
But how do I make PRTG count the number of lines returned in SNMP?
I've tried asking just on the OID 1.3.6.1.4.1.14823.2.1.1.1
But of course it just returns a list of clients, so it doesn't understand it.
Is there a way to use the advanced snmp to count the lines, instead of building a giant custom sensor for this?
Article Comments
Ok, I got a script created, by butchering the BGP script elsewhere:
# Monitor Status of Aruba Wireless AP
#
# Parameters in PRTG should be:
# -hostaddr '%host' -community '%snmpcommunity' -port '161' -timeout '5'
# Alternatively (without placeholders):
# -hostaddr 'ap.domain.tld' -community 'public' -port '161' -timeout '5'
#
# Requites net-snmp installed and in the path since it will use snmpwalk.exe (http://www.net-snmp.org/)
#
# It's recommended to use large scanning intervals for exe/xml scripts. (Not below 300 seconds)
param(
[string]$hostaddr = "router.domain.tld",
[string]$community = "public",
[string]$port = "161",
[string]$timeout = "5",
[string]$troubleshooting = 0
)
$version = "0.1"
$queryMeasurement = [System.Diagnostics.Stopwatch]::StartNew()
$walkresult = (c:\snmpwalk\snmpwalk.exe -Ln -On -v 2c -c $community $hostaddr":"$port ".1.3.6.1.4.1.14823.2.3.3.1.2.4.1.3" -t $timeout -l | Measure-Object -Line | Select-Object -expand Lines)
if ($troubleshooting -eq 1){
c:\snmpwalk\snmpwalk.exe -Ln -On -v 2c -c $community $hostaddr":"$port "1.3.6.1.4.1.14823.2.1.1.1" -t $timeout | Measure-Object -Line | Select-Object -expand Lines
Exit
}
#Check if snmwalk.exe suceeded.
if ($LASTEXITCODE -ne 0 ){
write-host "<prtg>"
write-host "<error>1</error>"
write-host "<text>Error: $($walkresult) / ScriptV: $($version) / PSv: $($PSVersionTable.PSVersion)</text>"
write-host "</prtg>"
Exit
}
write-host "<prtg>"
write-host "<result>"
write-host "<channel>Clients connected</channel>"
write-host "<value>"$walkresult"</value>"
write-host "</result>"
write-host "</prtg>"
This will return the number of clients connected to the 'controllerless' instant AP Aruba system.
It requires an SNMPWALK.EXE to be placed in a c:\snmpwalk\ folder
Nov, 2018 - Permalink
Ok, I got a script created, by butchering the BGP script elsewhere:
This will return the number of clients connected to the 'controllerless' instant AP Aruba system. It requires an SNMPWALK.EXE to be placed in a c:\snmpwalk\ folder
Nov, 2018 - Permalink