Continuing on with my series of applications on system level statistics, this application will look into the insides of the global system level statistics for the device.  The global statistics contain information on Auth, Bytes, Connections, CPU, Denials, Errors, Hardware, HTTP, Memory, Packets, and the TMM.

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: PsSystemStats.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-GlobalStatistics function is called to query the system 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-GlobalStatistics;
}
else
{
  Write-Error "ERROR: iControl subsystem not initialized"
}

Querying Global Statistics

The global system statistics can be retrieved with a single call to the get_global_statistics method located in the System.Statistics interface.  This method takes no arguments and returns a System.Statistics structure containing the timestamp for the statistics along with an array of Common.Statistics structures which in turn contain the type and value for each individual statistic.

In the Get-GlobalStatistics function, a call is made to the get_global_statistics() method and the returned value is stored in the GlobalStats variable.  A hash is then created to store all the statistics values.  Next, a foreach loop is run over all of the stats in the GlobalStats variable and for each stat the 64 bit value is calculated, a label is created, and that name/value pair is added to the hash table.

When all of the statistics have been processed, the hash's enumerator is accessed and that is passed through the PowerShell pipeline to the Sort-Object Cmdlet and then the Format-Table Cmdlet to display the results to the console.

function Get-GlobalStatistics()
{
  $GlobalStats = (Get-F5.iControl).SystemStatistics.get_global_statistics();
  $t = Get-TimeFromTimeStamp $GlobalStats.time_stamp;
  
  $hash = @{};
  
  $hash.Add("* Time Stamp", $t);
  
  $Statistics = $GlobalStats.statistics;
  foreach($Statistic in $Statistics)
  {
    $val = Convert-To64Bit $Statistic.value.high $Statistic.value.low;
    $label = Get-StatisticLabel $Statistic.type;
    $hash.Add($label, $val);
  }

  $hash.GetEnumerator() | Sort-Object -Property Name | Format-Table -autosize
}
function Get-StatisticLabel()
{
  param($type);
  $label = "";
  
  switch($type)
  {
    "STATISTIC_CLIENT_SIDE_BYTES_IN" {
      $label = "Bytes - Client In";
    }
    "STATISTIC_CLIENT_SIDE_BYTES_OUT" {
      $label = "Bytes - Client Out";
    }
    "STATISTIC_CLIENT_SIDE_PACKETS_IN" {
      $label = "Packets - Client In";
    }
    "STATISTIC_CLIENT_SIDE_PACKETS_OUT" {
      $label = "Packets - Client Out";
    }
    "STATISTIC_CLIENT_SIDE_CURRENT_CONNECTIONS" {
      $label = "Connections - Client Current";
    }
    "STATISTIC_CLIENT_SIDE_MAXIMUM_CONNECTIONS" {
      $label = "Connections - Client Maximum";
    }
    "STATISTIC_CLIENT_SIDE_TOTAL_CONNECTIONS" {
      $label = "Connections - Client Total";
    }
    "STATISTIC_SERVER_SIDE_BYTES_IN" {
      $label = "Bytes - Server In";
    }
    "STATISTIC_SERVER_SIDE_BYTES_OUT" {
      $label = "Bytes - Server Out";
    }
    "STATISTIC_SERVER_SIDE_PACKETS_IN" {
      $label = "Packets - Server In";
    }
    "STATISTIC_SERVER_SIDE_PACKETS_OUT" {
      $label = "Packets - Server Out";
    }
    "STATISTIC_SERVER_SIDE_CURRENT_CONNECTIONS" {
      $label = "Connections - Server Current";
    }
    "STATISTIC_SERVER_SIDE_MAXIMUM_CONNECTIONS" {
      $label = "Connections - Server Maximum";
    }
    "STATISTIC_SERVER_SIDE_TOTAL_CONNECTIONS" {
      $label = "Connections - Server Total";
    }
    "STATISTIC_PVA_CLIENT_SIDE_BYTES_IN" {
      $label = "Bytes - PVA Client In";
    }
    "STATISTIC_PVA_CLIENT_SIDE_BYTES_OUT" {
      $label = "Bytes - PVA Client Out";
    }
    "STATISTIC_PVA_CLIENT_SIDE_PACKETS_IN" {
      $label = "Packets - PVA Client In";
    }
    "STATISTIC_PVA_CLIENT_SIDE_PACKETS_OUT" {
      $label = "Packets - PVA Client Out";
    }
    "STATISTIC_PVA_CLIENT_SIDE_CURRENT_CONNECTIONS" {
      $label = "Connections - PVA Client Current";
    }
    "STATISTIC_PVA_CLIENT_SIDE_MAXIMUM_CONNECTIONS" {
      $label = "Connections - PVA Client Maximum";
    }
    "STATISTIC_PVA_CLIENT_SIDE_TOTAL_CONNECTIONS" {
      $label = "Connections - PVA Client Total";
    }
    "STATISTIC_PVA_SERVER_SIDE_BYTES_IN" {
      $label = "Bytes - PVA Server In";
    }
    "STATISTIC_PVA_SERVER_SIDE_BYTES_OUT" {
      $label = "Bytes - PVA Server Out";
    }
    "STATISTIC_PVA_SERVER_SIDE_PACKETS_IN" {
      $label = "Packets - PVA Server In";
    }
    "STATISTIC_PVA_SERVER_SIDE_PACKETS_OUT" {
      $label = "Packets - PVA Server Out";
    }
    "STATISTIC_PVA_SERVER_SIDE_CURRENT_CONNECTIONS" {
      $label = "Connections - PVA Server Current";
    }
    "STATISTIC_PVA_SERVER_SIDE_MAXIMUM_CONNECTIONS" {
      $label = "Connections - PVA Server Maximum";
    }
    "STATISTIC_PVA_SERVER_SIDE_TOTAL_CONNECTIONS" {
      $label = "Connections - PVA Server Total";
    }
    "STATISTIC_TOTAL_PVA_ASSISTED_CONNECTIONS" {
      $label = "Connections - PVA Assisted Total";
    }
    "STATISTIC_CURRENT_PVA_ASSISTED_CONNECTIONS" {
      $label = "Connections - PVA Assisted Current";
    }
    "STATISTIC_TM_TOTAL_CYCLES" {
      $label = "TMM - Total Cycles";
    }
    "STATISTIC_TM_IDLE_CYCLES" {
      $label = "TMM - Idle Cycles";
    }
    "STATISTIC_TM_SLEEP_CYCLES" {
      $label = "TMM - Sleep Cycles";
    }
    "STATISTIC_MAINTENANCE_MODE_DENIALS" {
      $label = "Denials - Maintence Mode";
    }
    "STATISTIC_VIRTUAL_ADDRESS_MAXIMUM_CONNECTION_DENIALS" {
      $label = "Denials - VA Maximum Connection";
    }
    "STATISTIC_VIRTUAL_SERVER_MAXIMUM_CONNECTION_DENIALS" {
      $label = "Denials - VS Maximum Connection";
    }
    "STATISTIC_VIRTUAL_SERVER_NON_SYN_DENIALS" {
      $label = "Denials - VS Non SYN";
    }
    "STATISTIC_NO_HANDLER_DENIALS" {
      $label = "Denials - No Handler";
    }
    "STATISTIC_LICENSE_DENIALS" {
      $label = "Denials - License";
    }
    "STATISTIC_CONNECTION_FAILED_MEMORY_ERRORS" {
      $label = "Errors - Connection Failed Memory";
    }
    "STATISTIC_CPU_COUNT" {
      $label = "CPU - Count";
    }
    "STATISTIC_ACTIVE_CPU_COUNT" {
      $label = "CPU - Active Count";
    }
    "STATISTIC_MULTI_PROCESSOR_MODE" {
      $label = "CPU - Multi Processor Mode";
    }
    "STATISTIC_MEMORY_TOTAL_BYTES" {
      $label = "Memory - Total Bytes";
    }
    "STATISTIC_MEMORY_USED_BYTES" {
      $label = "Memory - Used Bytes";
    }
    "STATISTIC_DROPPED_PACKETS_TOTAL" {
      $label = "Packets - Total Dropped";
    }
    "STATISTIC_ERRORS_IN" {
      $label = "Errors - In";
    }
    "STATISTIC_ERRORS_OUT" {
      $label = "Errors - Out";
    }
    "STATISTIC_AUTH_TOTAL_SESSIONS" {
      $label = "Auth - Total Sessions";
    }
    "STATISTIC_AUTH_CURRENT_SESSIONS" {
      $label = "Auth - Current Sessions";
    }
    "STATISTIC_AUTH_MAXIMUM_SESSIONS" {
      $label = "Auth - Maximum Sessions";
    }
    "STATISTIC_AUTH_SUCCESS_RESULTS" {
      $label = "Auth - Success Results";
    }
    "STATISTIC_AUTH_FAILURE_RESULTS" {
      $label = "Auth - Failure Results";
    }
    "STATISTIC_AUTH_WANT_CREDENTIAL_RESULTS" {
      $label = "Auth - Want Credentials Results";
    }
    "STATISTIC_AUTH_ERROR_RESULTS" {
      $label = "Auth - Error Results";
    }
    "STATISTIC_HTTP_TOTAL_REQUESTS" {
      $label = "HTTP - Total Request";
    }
    "STATISTIC_HARDWARE_SYN_COOKIES_GENERATED" {
      $label = "Hardware - SYN Cookies Generated";
    }
    "STATISTIC_HARDWARE_SYN_COOKIES_DETECTED" {
      $label = "Hardware - SYN Cookies Detected";
    }
    default {
      Write-Error "Unknown Label $type"
      $label = "***UNKNOWN***";
    }
  }
  return $label;
}

Running the code

The following command line will execute the code and display the output.  My device is not very active so there are not that many statistics to display but you will see that even for an idle machine  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:\> .\PsGlobalStatistics.ps1 bigip_address username password

Name                               Value
----                               -----
* Time Stamp                       10/16/2008 12:37:36 PM
Auth - Current Sessions            0
Auth - Error Results               0
Auth - Failure Results             0
Auth - Maximum Sessions            0
Auth - Success Results             0
Auth - Total Sessions              0
Auth - Want Credentials Results    0
Bytes - Client In                  212559442
Bytes - Client Out                 6372270
Bytes - PVA Client In              0
Bytes - PVA Client Out             0
Bytes - PVA Server In              0
Bytes - PVA Server Out             0
Bytes - Server In                  11975422
Bytes - Server Out                 6372270
Connections - Client Current       63
Connections - Client Maximum       64
Connections - Client Total         117795
Connections - PVA Assisted Current 0
Connections - PVA Assisted Total   0
Connections - PVA Client Current   0
Connections - PVA Client Maximum   0
Connections - PVA Client Total     0
Connections - PVA Server Current   0
Connections - PVA Server Maximum   0
Connections - PVA Server Total     0
Connections - Server Current       62
Connections - Server Maximum       63
Connections - Server Total         117794
CPU - Active Count                 2
CPU - Count                        2
CPU - Multi Processor Mode         1
Denials - License                  0
Denials - VS Non SYN               0
Denials - Maintence Mode           0
Denials - No Handler               2020
Denials - VA Maximum Connection    0
Denials - VS Maximum Connection    0
Errors - Connection Failed Memory  0
Errors - In                        0
Errors - Out                       0
Hardware - SYN Cookies Detected    0
Hardware - SYN Cookies Generated   0
HTTP - Total Request               0
Memory - Total Bytes               931135488
Memory - Used Bytes                24899536
Packets - Client In                1357519
Packets - Client Out               118005
Packets - PVA Client In            0
Packets - PVA Client Out           0
Packets - PVA Server In            0
Packets - PVA Server Out           0
Packets - Server In                177613
Packets - Server Out               118005
Packets - Total Dropped            0
TMM - Idle Cycles                  939236910286802
TMM - Sleep Cycles                 0
TMM - Total Cycles                 940529569438863

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 statistics and all the others to help you monitor and manage your systems.

 

 

Get the Flash Player to see this player.