iControl Apps - #13 - System PVA Statistics

Continuing on with my series of applications on system level statistics, this application will look into the insides of the Packet Velocity ASIC (PVA) subsystem and dump out the available statistics for client and server based hardware offloaded processing.

Usage

The arguments for this application are the address, username, and password of the BIG-IP.  This is declared in the top of the script with the following param statement.  There is also a Write-Usage function to display the arguments to the user.

param (
  $g_bigip = $null,
  $g_uid = $null,
  $g_pwd = $null
);

Set-PSDebug -strict;

function Write-Usage()
{
  Write-Host "Usage: PsSystemPVAStats.ps1 host uid pwd";
  exit;
}

Initialization

As is with all of my PowerShell scripts, the initialization component will look to see if the iControlSnapIn is loaded into the current PowerShell session.  If not, the Add-PSSnapIn Cmdlet is called to add the snapin into the runtime.  Then a call to the Initialize-F5.iControl cmdlet to setup the connection to the BIG-IP.  If this succeeds, then a call to the Get-SystemPVAStatistics function is called to query the client and server PVA Statistics and output them to the console.

function Do-Initialize()
{
  if ( (Get-PSSnapin | Where-Object { $_.Name -eq "iControlSnapIn"}) -eq $null )
  {
    Add-PSSnapIn iControlSnapIn
  }
  $success = Initialize-F5.iControl -HostName $g_bigip -Username $g_uid -Password $g_pwd;
  
  return $success;
}

#-------------------------------------------------------------------------
# Main Application Logic
#-------------------------------------------------------------------------
if ( ($g_bigip -eq $null) -or ($g_uid -eq $null) -or ($g_pwd -eq $null) )
{
  Write-Usage;
}

if ( Do-Initialize )
{
  Get-SystemPVAStatistics;
}
else
{
  Write-Error "ERROR: iControl subsystem not initialized"
}

Querying PVA Statistics

The PVA statistics can be retrieved individually for each PVA in the system with the get_pva_statistics method, or the entire list can be queried with the get_all_pva_statistics() method. In this example, I'll use the get_all_pva_statistics method to query a list of all statistics for each PVA on the system.

A foreach loop is entered for each PVAStatisticEntry in the returned structure.  From the PVAStatisticEntry, the PVA id is extracted as well as the list of statistics for that specific PVA.

A subsequent foreach loop is then run on the list of statistics within each PVAStatisticEntry.  The 64-bit statistic value is calculated, a label is created, and the name/value pair is added to the local hash table.

When all loops are completed, the hash is sorted and displayed to the console.  This is done by accessing the hash's enumerator with the GetEnumerator() accessor and that value is passed through the PowerShell pipeline through an ascii sort and then on to the Format-Table cmdlet.

function Get-SystemPVAStatistics()
{
  $PVAStatistics = (Get-F5.iControl).SystemStatistics.get_all_pva_statistics();
  $t = Get-TimeFromTimeStamp $PVAStatistics.time_stamp;
 
  $hash = @{};
 
  $hash.Add("* Time Stamp", $t);
 
  $PVAStatisticEntries = $PVAStatistics.statistics;
  foreach($PVAStatisticEntry in $PVAStatisticEntries)
  {
    $pva_id = $PVAStatisticEntry.pva_id;
    $Statistics = $PVAStatisticEntry.statistics;
    foreach($Statistic in $Statistics)
    {
        $val = Convert-To64Bit $Statistic.value.high $Statistic.value.low;
        $label = Get-StatisticLabel $Statistic.type;
        $hash.Add("[$pva_id] $label", $val);
    }
  }
  $hash.GetEnumerator() | Sort-Object -Property Name | Format-Table -autosize
}
function Get-StatisticLabel()
{
  param($type);
  $label = "";
 
  switch($type)
  {
    "STATISTIC_PVA_CLIENT_SIDE_BYTES_IN" {
      $label = "Bytes - Client In";
    }
    "STATISTIC_PVA_CLIENT_SIDE_BYTES_OUT" {
      $label = "Bytes - Client Out";
    }
    "STATISTIC_PVA_CLIENT_SIDE_PACKETS_IN" {
      $label = "Packets - Client In";
    }
    "STATISTIC_PVA_CLIENT_SIDE_PACKETS_OUT" {
      $label = "Packets - Client Out";
    }
    "STATISTIC_PVA_CLIENT_SIDE_CURRENT_CONNECTIONS" {
      $label = "Connections - Client Current";
    }
    "STATISTIC_PVA_CLIENT_SIDE_MAXIMUM_CONNECTIONS" {
      $label = "Connections - Client Maximum";
    }
    "STATISTIC_PVA_CLIENT_SIDE_TOTAL_CONNECTIONS" {
      $label = "Connections - Client Total";
    }
    "STATISTIC_PVA_SERVER_SIDE_BYTES_IN" {
      $label = "Bytes - Server In";
    }
    "STATISTIC_PVA_SERVER_SIDE_BYTES_OUT" {
      $label = "Bytes - Server Out";
    }
    "STATISTIC_PVA_SERVER_SIDE_PACKETS_IN" {
      $label = "Packets - Server In";
    }
    "STATISTIC_PVA_SERVER_SIDE_PACKETS_OUT" {
      $label = "Packets - Server Out";
    }
    "STATISTIC_PVA_SERVER_SIDE_CURRENT_CONNECTIONS" {
      $label = "Connections - Server Current";
    }
    "STATISTIC_PVA_SERVER_SIDE_MAXIMUM_CONNECTIONS" {
      $label = "Connections - Server Maximum";
    }
    "STATISTIC_PVA_SERVER_SIDE_TOTAL_CONNECTIONS" {
      $label = "Connections - Server Total";
    }
    "STATISTIC_TOTAL_PVA_ASSISTED_CONNECTIONS" {
      $label = "Connections - Total Assisted";
    }
    "STATISTIC_CURRENT_PVA_ASSISTED_CONNECTIONS" {
      $label = "Connections - Current Assisted";
    }
    "STATISTIC_HARDWARE_SYN_COOKIES_GENERATED" {
      $label = "Hardware - Syn Cookies Generated";
    }
    "STATISTIC_HARDWARE_SYN_COOKIES_DETECTED" {
      $label = "Hardware - Syn Cookies Detected";
    }
    default {
      $label = "***UNKNOWN***";
    }
  }
  return $label;
}

Running the code

The following command line will execute the code and display the output.  Since I do not have PVA enabled on my test system, the data here is pretty boring.  But, give it a shot on your active site and you'll see the data presented.

PS C:\> .\PsSystemPVAStats.ps1 bigip_address username password

Name                                Value
----                                -----
* Time Stamp                        10/9/2008 3:20:17 PM
[] Bytes - Client In                0
[] Bytes - Client Out               0
[] Bytes - Server In                0
[] Bytes - Server Out               0
[] Connections - Client Current     0
[] Connections - Client Maximum     0
[] Connections - Client Total       0
[] Connections - Current Assisted   0
[] Connections - Server Current     0
[] Connections - Server Maximum     0
[] Connections - Server Total       0
[] Connections - Total Assisted     0
[] Hardware - Syn Cookies Detected  0
[] Hardware - Syn Cookies Generated 0
[] Packets - Client In              0
[] Packets - Client Out             0
[] Packets - Server In              0
[] Packets - Server Out             0

Conclusion

As with all the other methods in the System.Statistics interface, you'll find a lot of hidden data that you may or may not be aware of.  Explore these global PVA statistics methods and all the others to help you monitor and manage your systems.

The full application can be found in the iControl CodeShare under PsSystemPvaStatistics.

 

Published Oct 09, 2008
Version 1.0

Was this article helpful?

No CommentsBe the first to comment