New Question
 
 
PRTG Network Monitor

Intuitive to Use.
Easy to manage.

200.000 administrators have chosen PRTG to monitor their network. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free PRTG
Download >>

 

What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general. You are invited to get involved by asking and answering questions!

Learn more

 

Top Tags


View all Tags


Aerohive AP client Count

Votes:

0

Your Vote:

Up

Down

Hi,

I'm trying to monitor my client count on each AP, Optionnally, splitting values between SSID

here is the needed Table OID : 1.3.6.1.4.1.26928.1.1.1.2.1.2

In this table there is a row per connected client.

The way to know numbers of client is to count entry 1.3.6.1.4.1.26928.1.1.1.2.1.2.1.2 (client IP) and group by 1.3.6.1.4.1.26928.1.1.1.2.1.2.1.10 (SSID)

My question is how to process in PRTG for at least to count rows af this table, or count rows grouped by SSID ?

Thanks for your help

aerohive prtg row-count snmp table

Created on Apr 1, 2016 1:37:16 PM by  Erwann PENCREACH (60) 1 1



Best Answer

Accepted Answer

Votes:

1

Your Vote:

Up

Down

Here is My script (using http://vwiki.co.uk/SNMP_and_PowerShell#PowerShell_v1_and_v2 informations) :

param(
[string]$pIP
)

[reflection.assembly]::LoadFrom( (Resolve-Path "C:\MA_Scripts\lib\SharpSnmpLib.dll") )

function New-GenericObject {
    # Creates an object of a generic type - see http://www.leeholmes.com/blog/2006/08/18/creating-generic-types-in-powershell/
 
    param(
        [string] $typeName = $(throw “Please specify a generic type name”),
        [string[]] $typeParameters = $(throw “Please specify the type parameters”),
        [object[]] $constructorParameters
        )
 
    ## Create the generic type name
    $genericTypeName = $typeName + ‘`’ + $typeParameters.Count
    $genericType = [Type] $genericTypeName
 
    if(-not $genericType)
        {
        throw “Could not find generic type $genericTypeName”
        }
 
    ## Bind the type arguments to it
    [type[]] $typedParameters = $typeParameters
    $closedType = $genericType.MakeGenericType($typedParameters)
    if(-not $closedType)
        {
        throw “Could not make closed type $genericType”
        }
 
    ## Create the closed version of the generic type
    ,[Activator]::CreateInstance($closedType, $constructorParameters)
}


function Invoke-SnmpWalk ([string]$sIP, $sOIDstart, [string]$Community = "public", [int]$UDPport = 161, [int]$TimeOut=3000) {
    # $sOIDstart
    # $TimeOut is in msec, 0 or -1 for infinite
 
    # Create OID object
    $oid = New-Object Lextm.SharpSnmpLib.ObjectIdentifier ($sOIDstart)
 
    # Create list for results
    $results = New-GenericObject System.Collections.Generic.List Lextm.SharpSnmpLib.Variable                       # PowerShell v1 and v2
    # $results = New-Object 'System.Collections.Generic.List[Lextm.SharpSnmpLib.Variable]'                         # PowerShell v3
 
    # Create endpoint for SNMP server
    $ip = [System.Net.IPAddress]::Parse($sIP)
    $svr = New-Object System.Net.IpEndPoint ($ip, 161)
 
    # Use SNMP v2 and walk mode WithinSubTree (as opposed to Default)
    $ver = [Lextm.SharpSnmpLib.VersionCode]::V2
    $walkMode = [Lextm.SharpSnmpLib.Messaging.WalkMode]::WithinSubtree
 
    # Perform SNMP Get
    try {
        [Lextm.SharpSnmpLib.Messaging.Messenger]::Walk($ver, $svr, $Community, $oid, $results, $TimeOut, $walkMode)
    } catch {
        Write-Host "SNMP Walk error: $_"
        Return $null
    }
 
    $ClientsSSID = @{}

    foreach ($var in $results) {
	    if( $var.Id.ToString().StartsWith(".1.3.6.1.4.1.26928.1.1.1.2.1.2.1.10.") ) {
        	$SSID = $var.Data.ToString()
		    if($ClientsSSID.ContainsKey($SSID)){
			    $ClientsSSID.Set_Item($SSID,$ClientsSSID.Get_Item($SSID)+1)
		    }else{
			    $ClientsSSID.add($SSID,1)
		    }
	    }
    }


    write-host '<?xml version="1.0" encoding="Windows-1252" ?>'
    write-host '<prtg>'
    ForEach($client in $ClientsSSID.keys){
        write-host "   <result>"
        write-host "      <channel>$client</channel>"
        write-host "      <value>",$ClientsSSID.Get_Item($client),"</value>"
        write-host "   </result>"
    }
    write-host "</prtg>"
}

Invoke-SnmpWalk $pIP "1.3.6.1.4.1.26928.1.1.1.2.1.2" "xxxx"

this works well

Created on May 18, 2016 2:55:49 PM by  Erwann PENCREACH (60) 1 1

Last change on May 19, 2016 6:35:36 AM by  Stephan Linke [Paessler Support]



12 Replies

Votes:

0

Your Vote:

Up

Down

Have you tried the SNMP Custom Table Sensor with those OIDs already? Please also have a look at the corresponding KB article :)

Created on Apr 5, 2016 11:28:02 AM by  Stephan Linke [Paessler Support]



Votes:

0

Your Vote:

Up

Down

Hi,

Yes I have, but, SNMP Custom Table sensor is monitring predefined rows of a table (you choose rows during setup using one column as index and some other clumns as value fields).

It doesn't allow you to monitor row count.

In the specific case of that table, rows are corresponding to a name device connected to the AP. So as device list connected to each AP is changing, monitoring each device on each AP won't be a solution ( about 20 APs connect about 200 devices in corp, and some guest devices)

Thanks fr your reply

regards

Created on Apr 6, 2016 9:17:15 AM by  Erwann PENCREACH (60) 1 1



Votes:

0

Your Vote:

Up

Down

You probably need to come up with a script that parses the number of entries in the table, the sensor is unable to do so. Do the APs have a webinterface that offers some stats? Maybe you could parse this as well...

Created on Apr 6, 2016 11:58:27 AM by  Stephan Linke [Paessler Support]



Votes:

0

Your Vote:

Up

Down

Hi, Sorry, I wasn't notified of your response.

I will have a look in Writing a script. I think it will be easier than accessing the Hivemanager

regards

Created on May 18, 2016 10:21:08 AM by  Erwann PENCREACH (60) 1 1



Accepted Answer

Votes:

1

Your Vote:

Up

Down

Here is My script (using http://vwiki.co.uk/SNMP_and_PowerShell#PowerShell_v1_and_v2 informations) :

param(
[string]$pIP
)

[reflection.assembly]::LoadFrom( (Resolve-Path "C:\MA_Scripts\lib\SharpSnmpLib.dll") )

function New-GenericObject {
    # Creates an object of a generic type - see http://www.leeholmes.com/blog/2006/08/18/creating-generic-types-in-powershell/
 
    param(
        [string] $typeName = $(throw “Please specify a generic type name”),
        [string[]] $typeParameters = $(throw “Please specify the type parameters”),
        [object[]] $constructorParameters
        )
 
    ## Create the generic type name
    $genericTypeName = $typeName + ‘`’ + $typeParameters.Count
    $genericType = [Type] $genericTypeName
 
    if(-not $genericType)
        {
        throw “Could not find generic type $genericTypeName”
        }
 
    ## Bind the type arguments to it
    [type[]] $typedParameters = $typeParameters
    $closedType = $genericType.MakeGenericType($typedParameters)
    if(-not $closedType)
        {
        throw “Could not make closed type $genericType”
        }
 
    ## Create the closed version of the generic type
    ,[Activator]::CreateInstance($closedType, $constructorParameters)
}


function Invoke-SnmpWalk ([string]$sIP, $sOIDstart, [string]$Community = "public", [int]$UDPport = 161, [int]$TimeOut=3000) {
    # $sOIDstart
    # $TimeOut is in msec, 0 or -1 for infinite
 
    # Create OID object
    $oid = New-Object Lextm.SharpSnmpLib.ObjectIdentifier ($sOIDstart)
 
    # Create list for results
    $results = New-GenericObject System.Collections.Generic.List Lextm.SharpSnmpLib.Variable                       # PowerShell v1 and v2
    # $results = New-Object 'System.Collections.Generic.List[Lextm.SharpSnmpLib.Variable]'                         # PowerShell v3
 
    # Create endpoint for SNMP server
    $ip = [System.Net.IPAddress]::Parse($sIP)
    $svr = New-Object System.Net.IpEndPoint ($ip, 161)
 
    # Use SNMP v2 and walk mode WithinSubTree (as opposed to Default)
    $ver = [Lextm.SharpSnmpLib.VersionCode]::V2
    $walkMode = [Lextm.SharpSnmpLib.Messaging.WalkMode]::WithinSubtree
 
    # Perform SNMP Get
    try {
        [Lextm.SharpSnmpLib.Messaging.Messenger]::Walk($ver, $svr, $Community, $oid, $results, $TimeOut, $walkMode)
    } catch {
        Write-Host "SNMP Walk error: $_"
        Return $null
    }
 
    $ClientsSSID = @{}

    foreach ($var in $results) {
	    if( $var.Id.ToString().StartsWith(".1.3.6.1.4.1.26928.1.1.1.2.1.2.1.10.") ) {
        	$SSID = $var.Data.ToString()
		    if($ClientsSSID.ContainsKey($SSID)){
			    $ClientsSSID.Set_Item($SSID,$ClientsSSID.Get_Item($SSID)+1)
		    }else{
			    $ClientsSSID.add($SSID,1)
		    }
	    }
    }


    write-host '<?xml version="1.0" encoding="Windows-1252" ?>'
    write-host '<prtg>'
    ForEach($client in $ClientsSSID.keys){
        write-host "   <result>"
        write-host "      <channel>$client</channel>"
        write-host "      <value>",$ClientsSSID.Get_Item($client),"</value>"
        write-host "   </result>"
    }
    write-host "</prtg>"
}

Invoke-SnmpWalk $pIP "1.3.6.1.4.1.26928.1.1.1.2.1.2" "xxxx"

this works well

Created on May 18, 2016 2:55:49 PM by  Erwann PENCREACH (60) 1 1

Last change on May 19, 2016 6:35:36 AM by  Stephan Linke [Paessler Support]



Votes:

0

Your Vote:

Up

Down

Cool, thanks for sharing! :)

Created on May 19, 2016 6:35:50 AM by  Stephan Linke [Paessler Support]



Votes:

0

Your Vote:

Up

Down

I still have a problem on my remote probes.

I copied needed Dll and ps1 file in the good directories.

Why I run the script on command line, it works well, But Prtg returns an invalid xml syntax.

I supposed there is something about remote execution of powershell ?

regards

Created on May 19, 2016 1:34:11 PM by  Erwann PENCREACH (60) 1 1



Votes:

0

Your Vote:

Up

Down

Did you execute Set-ExecutionPolicy RemoteSigned in an administrative PowerShell (x86) already?

Created on May 20, 2016 6:20:40 AM by  Stephan Linke [Paessler Support]



Votes:

0

Your Vote:

Up

Down

That's it, thanks a lots, everything is working well

to use it, create un custom sensor (Exe sensor upgraded) and then set IP in parameter field.

regards

Created on May 20, 2016 6:33:10 AM by  Erwann PENCREACH (60) 1 1



Votes:

0

Your Vote:

Up

Down

How Can I mark this topic as solved ?

Created on May 20, 2016 6:35:00 AM by  Erwann PENCREACH (60) 1 1



Votes:

0

Your Vote:

Up

Down

That's not necessary, glad it worked :)

Created on May 20, 2016 7:02:59 AM by  Stephan Linke [Paessler Support]



Votes:

0

Your Vote:

Up

Down

See also this thread using the REST Custom Sensor to retrieve the amount of connected clients per AP through Aerohive's REST API.

Created on Feb 2, 2018 10:16:01 AM by  Erhard Mikulik [Paessler Support]



Please log in or register to enter your reply.


Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.