microsoft powershell with icontrol
44 TopicsBIG-IP Report
Problem this snippet solves: Overview This is a script which will generate a report of the BIG-IP LTM configuration on all your load balancers making it easy to find information and get a comprehensive overview of virtual servers and pools connected to them. This information is used to relay information to NOC and developers to give them insight in where things are located and to be able to plan patching and deploys. I also use it myself as a quick way get information or gather data used as a foundation for RFC's, ie get a list of all external virtual servers without compression profiles. The script has been running on 13 pairs of load balancers, indexing over 1200 virtual servers for several years now and the report is widely used across the company and by many companies and governments across the world. It's easy to setup and use and only requires auditor (read-only) permissions on your devices. Demo/Preview Interactive demo http://loadbalancing.se/bigipreportdemo/ Screen shots The main report: The device overview: Certificate details: How to use this snippet: Installation instructions BigipReport REST This is the only branch we're updating since middle of 2020 and it supports 12.x and upwards (maybe even 11.6). Downloads: https://loadbalancing.se/downloads/bigipreport-v5.7.13.zip Documentation, installation instructions and troubleshooting:https://loadbalancing.se/bigipreport-rest/ Docker support https://loadbalancing.se/2021/01/05/running-bigipreport-on-docker/ Kubernetes support https://loadbalancing.se/2021/04/16/bigipreport-on-kubernetes/ BIG-IP Report (Legacy) Older version of the report that only runs on Windows and is depending on a Powershell plugin originally written by Joe Pruitt (F5) BIG-IP Report (only download this if you have v10 devices): https://loadbalancing.se/downloads/bigipreport-5.4.0-beta.zip iControl Snapin https://loadbalancing.se/downloads/f5-icontrol.zip Documentation and Installation Instructions https://loadbalancing.se/bigip-report/ Upgrade instructions Protect the report using APM and active directory Written by DevCentral member Shann_P: https://loadbalancing.se/2018/04/08/protecting-bigip-report-behind-an-apm-by-shannon-poole/ Got issues/problems/feedback? Still have issues? Drop a comment below. We usually reply quite fast. Any bugs found, issues detected or ideas contributed makes the report better for everyone, so it's always appreciated. --- Join us on Discord: https://discord.gg/7JJvPMYahA Code : BigIP Report Tested this on version: 12, 13, 14, 15, 1613KViews20likes96CommentsPowerShell module for the F5 LTM REST API
Problem this snippet solves: To report an issue with the F5-LTM or F5-BIGIP modules, please use the Issues sections of the GitHub repos (here and here) instead of commenting here. Thanks! This PowerShell module uses the iControlREST API to manipulate and query pools, pool members, virtual servers, and iRules. It aims to support version 11.5.1 and higher, and to conform to the schedule for technical support of versions, though this may eventually prove to become difficult. The module currently includes some functionality that, strictly speaking, is outside the scope of the LTM module. Hence, there is an active effort to wrap this LTM module into a larger BIG-IP module, and relocate that functionality elsewhere within that parent module, as well as expand the scope of functionality to include BIG-IP DNS (formerly GTM) and possibly other areas. Both the LTM module and the parent BIG-IP module are projects on github. Please use these projects to report any issues you discover. Thanks! The module contains the following functions. Add-iRuleToVirtualServer Add-iRuleToVirtualServer Add-PoolMember Add-PoolMonitor Disable-PoolMember Disable-VirtualServer Enable-PoolMember Enable-VirtualServer Get-CurrentConnectionCount (deprecated; use Get-PoolMemberStats | Select-Object -ExpandProperty 'serverside.curConns') Get-F5Session (will be deprecated in future versions. use New-F5Session) Get-F5Status Get-HealthMonitor Get-HealthMonitorType Get-iRule Get-iRuleCollection (deprecated; use Get-iRule) Get-Node Get-BIGIPPartition Get-Pool Get-PoolList (deprecated; use Get-Pool) Get-PoolMember Get-PoolMemberCollection (deprecated; use Get-PoolMember) Get-PoolMemberCollectionStatus Get-PoolMemberDescription (deprecated; use Get-PoolMember) Get-PoolMemberIP (deprecated; use Get-PoolMember) Get-PoolMembers (deprecated; use Get-PoolMember) Get-PoolMemberStats Get-PoolMemberStatus (deprecated; use Get-PoolMember) Get-PoolMonitor Get-PoolsForMember Get-StatusShape Get-VirtualServer Get-VirtualServeriRuleCollection (deprecated; use Get-VirtualServer | Where rules | Select -ExpandProperty rules) Get-VirtualServerList (deprecated; use Get-VirtualServer) Invoke-RestMethodOverride New-F5Session New-HealthMonitor New-Node New-Pool New-VirtualServer Remove-HealthMonitor Remove-iRule Remove-iRuleFromVirtualServer Remove-Pool Remove-PoolMember Remove-PoolMonitor Remove-ProfileRamCache Remove-Node Remove-VirtualServer Set-iRule Set-PoolLoadBalancingMode (deprecated; use Set-Pool) Set-PoolMemberDescription Set-Pool Set-VirtualServer Sync-DeviceToGroup Test-F5Session Test-Functionality Test-HealthMonitor Test-Node Test-Pool Test-VirtualServer How to use this snippet: To use the module, click 'Download Zip', extract the files, and place them in a folder named F5-LTM beneath your PowerShell modules folder. By default, this is %USERPROFILE%\Documents\WindowsPowerShell\Modules. The WindowsPowerShell and Modules folders may need to be created. You will most likely need to unblock the files after extracting them. Use the Unblock-File PS cmdlet to accomplish this. The Validation.cs class file (based on code posted by Brian Scholer) allows for using the REST API with LTM devices with self-signed SSL certificates. Nearly all of the functions require an F5 session object as a parameter, which contains the base URL for the F5 LTM and a credential object for a user with privileges to manipulate the F5 LTM via the REST API. Use the New-F5session function to create this object. This function expects the following parameters: The name or IP address of the F5 LTM device A credential object for a user with rights to use the REST API An optional TokenLifespan value for extending the life of the authentication token past the default 20 minutes You can create a credential object using Get-Credential and entering the username and password at the prompts, or programmatically like this: $secpasswd = ConvertTo-SecureString "PlainTextPassword" -AsPlainText -Force $mycreds = New-Object System.Management.Automation.PSCredential "username", $secpasswd Thanks to Kotesh Bandhamravuri and his blog entry for this snippet. There is a function called Test-Functionality that takes an F5Session object, a new pool name, a new virtual server, an IP address for the virtual server, and a computer name as a pool member, and validates nearly all the functions in the module. I've also contributed this code sample for how to gather some basic info about your LTM with this PS module. The module has been tested on: 11.5.1 Build 8.0.175 Hotfix 8 and later 11.6.0 Build 5.0.429 Hotfix 4 and later 12.0 / 12.1 13.0 Code : https://github.com/joel74/POSH-LTM-Rest Tested this on version: 11.519KViews2likes150CommentsPs ARX Monitor
Problem this snippet solves: These examples show how to use PowerShell to monitor an ARX through the iControl interfaces. The attached zip file includes the following scripts libArxApi.ps1 is the common library used by all examples. arxApiCpu.ps1 monitors the ARX CPU usages. arxApiVolume.ps1 monitors the ARX volumes. arxApiVs.ps1 monitors the ARX virtual services. csv.ps1 is an utility to merge multiple csv files generated by the above examples into one. How to use this snippet: Run arxApiCpu.ps1, arxApiVolume.ps1 and arxApiVs.ps1 without arguments, and they will print out the usage. Prerequisites Powershell 2.0 or later iControl-ARX assembly 6.02 or later. The common library at c:\dev\ps\libArxApi.ps1. An F5 ARX system running release V6.02.000 or later. Management access on the ARX must be permitted for HTTPs-API or HTTP-API services.210Views0likes0CommentsBigIP Report Old
Problem this snippet solves: This codeshare has been deprecated due to a hosting platform corruption. I have movedcode and conversation to a new record (on the same original URL) https://devcentral.f5.com/s/articles/bigip-report can be Overview This is a script which will generate a report of the BigIP LTM configuration on all your load balancers making it easy to find information and get a comprehensive overview of virtual servers and pools connected to them. This information is used to relay information to our NOC and developers to give them insight in where things are located and to be able to plan patching and deploys. I also use it myself as a quick way get information or gather data used as a foundation for RFC's, ie get a list of all external virtual servers without compression profiles. The script has been running on 13 pairs of load balancers, indexing over 1200 virtual servers for several years now and the report is widely used across the company and by many companies and governments across the world. It's easy to setup and use and only requires guest permissions on your devices. Demo/Preview Please note that it takes time to make these so sometimes they're a bit outdated and they only cover one HA pair. However, they still serve the purpose of showing what you can expect from the report. Interactive demo http://loadbalancing.se/bigipreportdemo/ Screen shots The main report: The device overview: Certificate details: How to use this snippet: This codeshare has been deprecated due to a hosting platform corruption. I have movedcode and conversation to a new record (on the same original URL) https://devcentral.f5.com/s/articles/bigip-report Installation instructions BigipReport REST This is the only branch we're updating since middle of 2020 and it supports 12.x and upwards (maybe even 11.6). Download:https://loadbalancing.se/downloads/bigipreport-v5.5.4.zip Documentation, installation instructions and troubleshooting:https://loadbalancing.se/bigipreport-rest/ Docker support This will be the recommended way of running bigipreport in the near future. It's still undergoing testing but it's looking really good so far. https://loadbalancing.se/2021/01/05/running-bigipreport-on-docker/ BigipReport (Legacy) Older version of the report that only runs on Windows and is depending on a Powershell plugin originally written by Joe Pruitt (F5). BigipReport (Stable): https://loadbalancing.se/downloads/bigipreport-5.3.1.zip BigipReport (BETA): https://loadbalancing.se/downloads/bigipreport-5.4.0-beta.zip iControl Snapin: https://loadbalancing.se/downloads/f5-icontrol.zip Documentation and installation instructions: https://loadbalancing.se/bigip-report/ Upgrade instructions Protect the report using APM and active directory Written by DevCentral member Shann_P: https://loadbalancing.se/2018/04/08/protecting-bigip-report-behind-an-apm-by-shannon-poole/ Got issues/problems/feedback? Still have issues? Drop a comment below. We usually reply quite fast. Any bugs found, issues detected or ideas contributed makes the report better for everyone, so it's always appreciated. --- Also trying out a Discord channel now. You're welcome to hang out with us there: https://discord.gg/7JJvPMYahA Code : 85931,86647,90730 Tested this on version: 13.026KViews16likes974CommentsPowerShell Setup Snapin
Problem this snippet solves: This PowerShell script will register the iControl Snapin on 32 and 64 bit platforms. Code : param([switch]$force) function Is-SnapinRegistered() { $registered = $false; if ( $null -ne (Get-PSSnapIn -Registered | where { $_.Name -eq "iControlSnapIn" } ) ) { $registered = $true; } $registered; } function Install-Snapin() { param( [string]$assembly = $null ); foreach ($platform in ("", "64") ) { Write-Host "Registering $assembly on platform '$platform'"; $installUtil = "$env:windir\Microsoft.Net\Framework${platform}\v2.0.50727\installUtil.exe"; if ( [System.IO.File]::Exists($installUtil) ) { Set-Alias installUtil $installUtil; installUtil $assembly /LogToConsole=false /LogFile=; } } } function Remove-Snapin() { param( [string]$assembly = $null ); foreach ($platform in ("", "64") ) { Write-Host "Unregistering $assembly on platform '$platform'"; $installUtil = "$env:windir\Microsoft.Net\Framework${platform}\v2.0.50727\installUtil.exe"; if ( [System.IO.File]::Exists($installUtil) ) { Set-Alias installUtil $installUtil; installUtil /u $assembly /LogToConsole=false /LogFile=; } } } if ( ($force) -or !(Is-SnapinRegistered) ) { Install-Snapin -assembly iControlSnapin.dll; } else { Write-Host "iControlSnapIn already registered..." }1.2KViews0likes1CommentPs Local Traffic Map
Problem this snippet solves: This application will replicate the network map functionality found in the BIG-IP management GUI with a PowerShell console implementation. The BIG-IP Management GUI has a feature called the Network Map that includes a hierarchical summary of the objects on the system and their current statuses. This tech tip will take that GUI component and break it down into the underlying iControl method calls and present an alternative implementation from within Windows PowerShell. Code : #---------------------------------------------------------------------------- # The contents of this file are subject to the "END USER LICENSE AGREEMENT FOR F5 # Software Development Kit for iControl"; you may not use this file except in # compliance with the License. The License is included in the iControl # Software Development Kit. # # Software distributed under the License is distributed on an "AS IS" # basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See # the License for the specific language governing rights and limitations # under the License. # # The Original Code is iControl Code and related documentation # distributed by F5. # # The Initial Developer of the Original Code is F5 Networks, # Inc. Seattle, WA, USA. Portions created by F5 are Copyright (C) 1996-2008 F5 Networks, # Inc. All Rights Reserved. iControl (TM) is a registered trademark of F5 Networks, Inc. # # Alternatively, the contents of this file may be used under the terms # of the GNU General Public License (the "GPL"), in which case the # provisions of GPL are applicable instead of those above. If you wish # to allow use of your version of this file only under the terms of the # GPL and not to allow others to use your version of this file under the # License, indicate your decision by deleting the provisions above and # replace them with the notice and other provisions required by the GPL. # If you do not delete the provisions above, a recipient may use your # version of this file under either the License or the GPL. #---------------------------------------------------------------------------- param ( $g_bigip = $null, $g_uid = $null, $g_pwd = $null ) Set-PSDebug -strict; $g_vs_list = $null; $g_vs_pool_list = $null; $g_vs_rule_list = $null; #------------------------------------------------------------------------- # function Show-Usage #------------------------------------------------------------------------- function Show-Usage() { Write-Host "Usage: LocalTrafficSummary.ps1 host uid pwd"; exit; } #------------------------------------------------------------------------- # #------------------------------------------------------------------------- function Sanitize-Array() { param ( [string[]]$in ); $out = $null; foreach ($item in $in) { if ( $item.Length -gt 0 ) { if ( $null -eq $out ) { $out = (, $item) } else { $out += $item } } } return $out; } #------------------------------------------------------------------------- # #------------------------------------------------------------------------- function Get-VSList() { if ( $null -eq $g_vs_list ) { $g_vs_list = (Get-F5.iControl).LocalLBVirtualServer.get_list(); } return $g_vs_list; } #------------------------------------------------------------------------- # #------------------------------------------------------------------------- function Get-VSPoolList() { if ( $null -eq $g_vs_pool_list ) { $g_vs_pool_list = (Get-F5.iControl).LocalLBVirtualServer.get_default_pool_name( (Get-VSList) ); } return $g_vs_pool_list; } #------------------------------------------------------------------------- # #------------------------------------------------------------------------- function Get-VSRuleList() { if ( $null -eq $g_vs_rule_list ) { $g_vs_rule_list = (Get-F5.iControl).LocalLBVirtualServer.get_rule( (Get-VSList) ); } return $g_vs_rule_list; } #------------------------------------------------------------------------- # #------------------------------------------------------------------------- function Get-ObjectStatus() { param ( $object_status ); $avail = $object_status.availability_status; $enabled = $object_status.enabled_status; $s_avail = ""; $s_enabled = ""; $s_desc = $object_status.status_description; switch($avail) { "AVAILABILITY_STATUS_GREEN" { $s_avail = "Available"; } "AVAILABILITY_STATUS_YELLOW" { $s_avail = "Unavailable"; } "AVAILABILITY_STATUS_RED" { $s_avail = "Unavailable"; } "AVAILABILITY_STATUS_BLUE" { $s_avail = "Unknown"; } "AVAILABILITY_STATUS_GRAY" { $s_avail = "Unavailable"; } default { $s_avail = "Unknown"; } } switch($enabled) { "ENABLED_STATUS_ENABLED" { $s_enabled = "Enabled"; } "ENABLED_STATUS_DISABLED" { $s_enabled = "Disabled"; } "ENABLED_STATUS_DISABLED_BY_PARENT" { $s_enabled = "Disabled"; } default { } } return "$s_avail ($s_enabled) $s_desc"; } #------------------------------------------------------------------------- # #------------------------------------------------------------------------- function Print-LocalTrafficMap() { $vs_list = Get-VSList; $pool_list = Get-VSPoolList; $vs_statuses = (Get-F5.iControl).LocalLBVirtualServer.get_object_status( $vs_list ); $pool_statuses = (Get-F5.iControl).LocalLBPool.get_object_status( (Sanitize-Array $pool_list) ); $MemberStatAofA = (Get-F5.iControl).LocalLBPoolMember.get_object_status( $pool_list ); $VSRuleAofA = Get-VSRuleList; Write-Host "***** SITE MAP FOR BIG-IP $g_bigip ******" for($i=0; $i -lt $vs_list.Length; $i++) { $vs = $vs_list[$i]; $stat_str = Get-ObjectStatus $vs_statuses[$i]; Write-Host "$vs (VS)"; Write-Host "| $stat_str" if ( $pool_list[$i].Length -gt 0 ) { $pool = $pool_list[$i]; $stat_str = Get-ObjectStatus $pool_statuses[$i]; Write-Host "+-> $pool (P)" Write-Host " | $stat_str" for($j=0; $j -lt $MemberStatAofA[$i].Length; $j++) { $MemberStat = $MemberStatAofA[$i][$j]; $member = $MemberStat.member; $addr = $member.address; $port = $member.port; $stat_str = Get-ObjectStatus $MemberStat.object_status; Write-Host " +-> ${addr}:${port} (PM)" Write-Host " | $stat_str" } } if ( $VSRuleAofA[$i].Length -gt 0 ) { for ($j=0; $j -lt $VSRuleAofA[$i].Length; $j++) { $RuleDef = $VSRuleAofA[$i][$j]; $rule_name = $RuleDef.rule_name; Write-Host "+-> $rule_name (R)" } } } } #------------------------------------------------------------------------- # #------------------------------------------------------------------------- function Do-Initialize() { $snapin = Get-PSSnapin | Where-Object { $_.Name -eq "iControlSnapIn" } if ( $null -eq $snapin ) { 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) ) { Show-Usage; } if ( Do-Initialize ) { Print-LocalTrafficMap } else { Write-Error "ERROR: iControl subsystem not initialized" }241Views0likes2CommentsPowerShell PoolMember Ratio And Priority
Problem this snippet solves: This sample PowerShell script illustrates how to use the methods in the LocalLB::Pool interface to get and set the Ratio and Priority for a Pool Member. Note, this example uses the new pool member methods in the LocalLB Pool interface introduced in BIG-IP v11.0 Code : #---------------------------------------------------------------------------- # The contents of this file are subject to the "END USER LICENSE AGREEMENT # FOR F5 Software Development Kit for iControl"; you may not use this file # except in compliance with the License. The License is included in the # iControl Software Development Kit. # # Software distributed under the License is distributed on an "AS IS" # basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See # the License for the specific language governing rights and limitations # under the License. # # The Original Code is iControl Code and related documentation # distributed by F5. # # The Initial Developer of the Original Code is F5 Networks, Inc. # Seattle, WA, USA. Portions created by F5 are Copyright (C) 1996-2012 # F5 Networks, Inc. All Rights Reserved. iControl (TM) is a registered # trademark of F5 Networks, Inc. # # Alternatively, the contents of this file may be used under the terms # of the GNU General Public License (the "GPL"), in which case the # provisions of GPL are applicable instead of those above. If you wish # to allow use of your version of this file only under the terms of the # GPL and not to allow others to use your version of this file under the # License, indicate your decision by deleting the provisions above and # replace them with the notice and other provisions required by the GPL. # If you do not delete the provisions above, a recipient may use your # version of this file under either the License or the GPL. #---------------------------------------------------------------------------- param ( $BIGIP = $null, $User = $null, $Pass = $null, $Pool = $null, $Member = $null, $Ratio = $null, $Priority = $null ) #------------------------------------------------------------------------- # function Show-Usage #------------------------------------------------------------------------- function Show-Usage() { Write-Host @" Usage: PoolMemberRatioPriority.ps1 BIGIP User Pass Pool Member Ratio Priority Examples .\PoolMemberRatioPriority.ps1 -BIGIP bigip -User user -Pass pass : list pools .\PoolMemberRatioPriority.ps1 -BIGIP bigip -User user -Pass pass -Member ipport : list pool members .\PoolMemberRatioPriority.ps1 -BIGIP bigip -User user -Pass pass -Member ipport -Ratio 5 : set member ratio to 5 .\PoolMemberRatioPriority.ps1 -BIGIP bigip -User user -Pass pass -Member ipport -Priority 3 : set member priority to 3 "@ exit; } #---------------------------------------------------------------------------- function Do-Initialize() #---------------------------------------------------------------------------- { if ( (Get-PSSnapin | Where-Object { $_.Name -eq "iControlSnapIn"}) -eq $null ) { Add-PSSnapIn iControlSnapIn } $success = Initialize-F5.iControl -HostName $BIGIP -Username $User -Password $Pass; return $success; } function Parse-AddressPort() { param($Value); $tokens = $Value.Split(":"); $r = New-Object iControl.CommonAddressPort; $r.address = $tokens[0]; $r.port = $tokens[1]; $r; } function Get-Pools() { (Get-F5.iControl).LocalLBPool.get_list(); } function Get-PoolMembers() { param( $Pool = $null ); $MemberListAofA = (Get-F5.iControl).LocalLBPool.get_member_v2( @($Pool) ); $MemberListA = $MemberListAofA[0]; $MemberListA; } function Get-PoolMemberDetails() { param( $Pool = $null, $Member = $null ); $AddrPort = Parse-AddressPort $Member; $RatioAofA = (Get-F5.iControl).LocalLBPool.get_member_ratio( @($Pool), @( @($AddrPort) ) ); $PriorityAofA = (Get-F5.iControl).LocalLBPool.get_member_priority( @($Pool), @( @($AddrPort) ) ); $ratio = $RatioAofA[0][0]; $priority = $PriorityAofA[0][0]; "Pool '$Pool' member '$Member' ratio '$ratio' priority '$priority'"; } function Set-PoolMemberDetails() { param( $Pool = $null, $Member = $null, $Ratio = $null, $Priority = $null ); $AddrPort = Parse-AddressPort $Member; if ( $null -ne $Ratio ) { (Get-F5.iControl).LocalLBPool.set_member_ratio( @($Pool), @( @($AddrPort) ), @($Ratio) ); } if ( $null -ne $Priority ) { (Get-F5.iControl).LocalLBPool.set_member_priority( @($Pool), @( @($AddrPort) ), @($Priority) ); } } #------------------------------------------------------------------------- # Main Application Logic #------------------------------------------------------------------------- if ( ($BIGIP -eq $null) -or ($User -eq $null) -or ($Pass -eq $null) ) { Show-Usage; } if ( Do-Initialize ) { if ( $Pool -eq $null ) { # List Pools Get-Pools; } elseif ( $Member -eq $null ) { # List Pool Members Get-PoolMembers -Pool $Pool; } elseif ( ($Ratio -eq $null) -and ($Priority -eq $null) ) { # List Pool Member Details Get-PoolMemberDetails -Pool $Pool -Member $Member; } else { # Set Ratio and/or Priority Set-PoolMemberDetails -Pool $Pool -Member $Member -Ratio $Ratio -Priority $Priority; Get-PoolMemberDetails -Pool $Pool -Member $Member; } } else { Write-Error "ERROR: iControl subsystem not initialized" }289Views1like1CommentPowerShell Pool Member Availability
Problem this snippet solves: This PowerShell script will query the status of the pool members for a specified poolname. How to use this snippet: PowerShellPoolMemberAvailability.ps1 -BIGIP < bigip> -User < user> -Pass < pass> [-Pool < poolname> [-List]] Code : #---------------------------------------------------------------------------- # The contents of this file are subject to the "END USER LICENSE AGREEMENT # FOR F5 Software Development Kit for iControl"; you may not use this file # except in compliance with the License. The License is included in the # iControl Software Development Kit. # # Software distributed under the License is distributed on an "AS IS" # basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See # the License for the specific language governing rights and limitations # under the License. # # The Original Code is iControl Code and related documentation # distributed by F5. # # The Initial Developer of the Original Code is F5 Networks, # Inc. Seattle, WA, USA. Portions created by F5 are Copyright (C) 1996-2010 # F5 Networks, Inc. All Rights Reserved. iControl (TM) is a registered # trademark of F5 Networks, Inc. # # Alternatively, the contents of this file may be used under the terms # of the GNU General Public License (the "GPL"), in which case the # provisions of GPL are applicable instead of those above. If you wish # to allow use of your version of this file only under the terms of the # GPL and not to allow others to use your version of this file under the # License, indicate your decision by deleting the provisions above and # replace them with the notice and other provisions required by the GPL. # If you do not delete the provisions above, a recipient may use your # version of this file under either the License or the GPL. #---------------------------------------------------------------------------- param( [string]$BIGIP = $null, [string]$User = $null, [string]$Pass = $null, [string]$Pool = $null, [switch]$List = $false ); Set-PSDebug -strict; #------------------------------------------------------------------------- function Write-Usage() # # Print Usage information for this script #------------------------------------------------------------------------- { Write-Host "Usage: $(Split-Path -Path $MyInvocation.ScriptName -Leaf) -BIGIP -User -Pass [-Pool [-List]]"; exit; } #------------------------------------------------------------------------- function Get-PoolList() #------------------------------------------------------------------------- { $pool_list = (Get-F5.iControl).LocalLBPool.get_list(); Write-Host "Available Pools:"; foreach ($pool in $pool_list) { Write-Host " $pool"; } } #------------------------------------------------------------------------- function Get-PoolMemberAvailability() #------------------------------------------------------------------------- { param([string]$Pool); $avail_count = 0; $total_count = 0; if ( $Pool.Length -ne 0 ) { $MemberObjectStatusAofA = (Get-F5.iControl).LocalLBPoolMember.get_object_status((, $Pool)); # Only one pool, so let's access the members for first entry of returned array. $MemberObjectStatusA = $MemberObjectStatusAofA[0]; foreach ($MemberObjectStatus in $MemberObjectStatusA) { $member = $MemberObjectStatus.member; $addr = $member.address; $port = $member.port; $Availability = $MemberObjectStatus.object_status.availability_status; $Enabled = $MemberObjectStatus.object_status.enabled_status; $Description = $MemberObjectStatus.object_status.status_description; $total_count++; if ( $Availability -eq "AVAILABILITY_STATUS_GREEN" ) { $avail_count++; } if ($List) { Write-Host "$Pool,${addr}:${port},$Availability,$Enabled,$Description"; } } if (!$List) { Write-Host "$avail_count/$total_count" } } } #------------------------------------------------------------------------- function Do-Initialize() #------------------------------------------------------------------------- { if ( (Get-PSSnapin | Where-Object { $_.Name -eq "iControlSnapIn"}) -eq $null ) { Add-PSSnapIn iControlSnapIn } $success = Initialize-F5.iControl -HostName $BIGIP -Username $User -Password $Pass; return $success; } #------------------------------------------------------------------------- # Main Application Logic #------------------------------------------------------------------------- if ( ($BIGIP.Length -eq 0) -or ($User.Length -eq 0) -or ($Pass.Length -eq 0) ) { Write-Usage; } if ( Do-Initialize ) { if ( $Pool.Length -eq 0 ) { Get-PoolList; } else { Get-PoolMemberAvailability -Pool $Pool; } }619Views0likes3CommentsPs Global Ssl Statistics
Problem this snippet solves: This application will explore the system level ssl statistics available in the System.Statistics interface. Continuing on with my series of applications on system level statistics, this application will look into the insides of the SSL subsystem and dump out the available statistics for client and server based SSL processing. Code : # The contents of this file are subject to the "END USER LICENSE AGREEMENT FOR F5 # Software Development Kit for iControl"; you may not use this file except in # compliance with the License. The License is included in the iControl # Software Development Kit. # # Software distributed under the License is distributed on an "AS IS" # basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See # the License for the specific language governing rights and limitations # under the License. # # The Original Code is iControl Code and related documentation # distributed by F5. # # The Initial Developer of the Original Code is F5 Networks, # Inc. Seattle, WA, USA. Portions created by F5 are Copyright (C) 1996-2007 F5 Networks, # Inc. All Rights Reserved. iControl (TM) is a registered trademark of F5 Networks, Inc. # # Alternatively, the contents of this file may be used under the terms # of the GNU General Public License (the "GPL"), in which case the # provisions of GPL are applicable instead of those above. If you wish # to allow use of your version of this file only under the terms of the # GPL and not to allow others to use your version of this file under the # License, indicate your decision by deleting the provisions above and # replace them with the notice and other provisions required by the GPL. # If you do not delete the provisions above, a recipient may use your # version of this file under either the License or the GPL. #---------------------------------------------------------------------------- param ( $g_bigip = $null, $g_uid = $null, $g_pwd = $null ); Set-PSDebug -strict; #------------------------------------------------------------------------- # function Write-Usage #------------------------------------------------------------------------- function Write-Usage() { Write-Host "Usage: GlobalSSLStats.ps1 host uid pwd"; exit; } #------------------------------------------------------------------------- # function Get-TimeFromTimeStamp #------------------------------------------------------------------------- function Get-TimeFromTimeStamp() { param ($TimeStamp); $dt = new-object -typename System.DateTime $dt = $dt.AddYears($TimeStamp.year-1).AddMonths($TimeStamp.month-1).AddDays($TimeStamp.day-1); $dt = $dt.AddHours($TimeStamp.hour).AddMinutes($TimeStamp.minute).AddSeconds($TimeStamp.second); return $dt; } #------------------------------------------------------------------------- # function Convert-To64Bit #------------------------------------------------------------------------- function Convert-To64Bit() { param($high, $low); return ($high*[Math]::Pow(2,32))+$low; } #------------------------------------------------------------------------- # function Get-StatisticLabel #------------------------------------------------------------------------- function Get-StatisticLabel() { param($type); $label = ""; switch($type) { "STATISTIC_SSL_COMMON_CURRENT_CONNECTIONS" { $label = "Connections - currently Opened"; } "STATISTIC_SSL_COMMON_MAXIMUM_CONNECTIONS" { $label = "Connections - maximum simultaneous"; } "STATISTIC_SSL_COMMON_CURRENT_NATIVE_CONNECTIONS" { $label = "Connections - currently opened native"; } "STATISTIC_SSL_COMMON_MAXIMUM_NATIVE_CONNECTIONS" { $label = "Connections - maximum simultaneous native"; } "STATISTIC_SSL_COMMON_TOTAL_NATIVE_CONNECTIONS" { $label = "Connections - total native"; } "STATISTIC_SSL_COMMON_CURRENT_COMPATIBLE_MODE_CONNECTIONS" { $label = "Connections - currently opened compatible mode"; } "STATISTIC_SSL_COMMON_MAXIMUM_COMPATIBLE_MODE_CONNECTIONS" { $label = "Connections - maximum compatible mode"; } "STATISTIC_SSL_COMMON_TOTAL_COMPATIBLE_MODE_CONNECTIONS" { $label = "Connections - total compatible mode"; } "STATISTIC_SSL_COMMON_ENCRYPTED_BYTES_IN" { $label = "Bytes - total encrypted received"; } "STATISTIC_SSL_COMMON_ENCRYPTED_BYTES_OUT" { $label = "Bytes - total encrypted sent"; } "STATISTIC_SSL_COMMON_DECRYPTED_BYTES_IN" { $label = "Bytes - total decrypted received"; } "STATISTIC_SSL_COMMON_DECRYPTED_BYTES_OUT" { $label = "Bytes - Total decrypted sent"; } "STATISTIC_SSL_COMMON_RECORDS_IN" { $label = "Records - total received"; } "STATISTIC_SSL_COMMON_RECORDS_OUT" { $label = "Records - total sent"; } "STATISTIC_SSL_COMMON_FULLY_HW_ACCELERATED_CONNECTIONS" { $label = "Connections - total offloaded"; } "STATISTIC_SSL_COMMON_PARTIALLY_HW_ACCELERATED_CONNECTIONS" { $label = "Connections - total assisted"; } "STATISTIC_SSL_COMMON_NON_HW_ACCELERATED_CONNECTIONS" { $label = "Connections - total software"; } "STATISTIC_SSL_COMMON_PREMATURE_DISCONNECTS" { $label = "Shutdowns - total unclean"; } "STATISTIC_SSL_COMMON_MIDSTREAM_RENEGOTIATIONS" { $label = "Hanshakes - total mid-connection"; } "STATISTIC_SSL_COMMON_SESSION_CACHE_CURRENT_ENTRIES" { $label = "Cache - current session entries"; } "STATISTIC_SSL_COMMON_SESSION_CACHE_HITS" { $label = "Cache - total hits"; } "STATISTIC_SSL_COMMON_SESSION_CACHE_LOOKUPS" { $label = "Cache - total lookups"; } "STATISTIC_SSL_COMMON_SESSION_CACHE_OVERFLOWS" { $label = "Cache - total overflows"; } "STATISTIC_SSL_COMMON_SESSION_CACHE_INVALIDATIONS" { $label = "Cache - total session invalidations"; } "STATISTIC_SSL_COMMON_VALID_PEER_CERTIFICATES" { $label = "Certificates - total valid"; } "STATISTIC_SSL_COMMON_INVALID_PEER_CERTIFICATES" { $label = "Certificates - total invalid"; } "STATISTIC_SSL_COMMON_NO_PEER_CERTIFICATES" { $label = "Certificates - connections without"; } "STATISTIC_SSL_COMMON_HANDSHAKE_FAILURES" { $label = "Handshake - total failures"; } "STATISTIC_SSL_COMMON_NOT_SSL_HANDSHAKE_FAILURES" { $label = "Handshake - total bad client greetings"; } "STATISTIC_SSL_COMMON_BAD_RECORDS" { $label = "Records - total bad"; } "STATISTIC_SSL_COMMON_FATAL_ALERTS" { $label = "Alerts - total fatal"; } "STATISTIC_SSL_PROTOCOL_SSLV2" { $label = "Protocol - total SSLv2"; } "STATISTIC_SSL_PROTOCOL_SSLV3" { $label = "Protocol - total SSLv3"; } "STATISTIC_SSL_PROTOCOL_TLSV1" { $label = "Protocol - total TLSv1"; } "STATISTIC_SSL_CIPHER_ADH_KEY_EXCHANGE" { $label = "Key Exchange - total anonymous Diffie-Hellman"; } "STATISTIC_SSL_CIPHER_DH_RSA_KEY_EXCHANGE" { $label = "Key Exchange - total Diffie-Hellman w/RSA certificate"; } "STATISTIC_SSL_CIPHER_EDH_RSA_KEY_EXCHANGE" { $label = "Key Exchange - ephemeral Diffie-Hellman w/RSA certificate"; } "STATISTIC_SSL_CIPHER_RSA_KEY_EXCHANGE" { $label = "Key Exchange - RSA cerficate"; } "STATISTIC_SSL_CIPHER_NULL_BULK" { $label = "Cipher - No encryption"; } "STATISTIC_SSL_CIPHER_AES_BULK" { $label = "Cipher - Advanced Encryption Standard (AES)"; } "STATISTIC_SSL_CIPHER_DES_BULK" { $label = "Cipher - Digital Encryption Standard (DES)"; } "STATISTIC_SSL_CIPHER_IDEA_BULK" { $label = "Cipher - IDEA (old SSLv2)"; } "STATISTIC_SSL_CIPHER_RC2_BULK" { $label = "Cipher - Rivest Cipher 2"; } "STATISTIC_SSL_CIPHER_RC4_BULK" { $label = "Cipher - Rivest Cipher 4"; } "STATISTIC_SSL_CIPHER_NULL_DIGEST" { $label = "Cipher - No message authentication"; } "STATISTIC_SSL_CIPHER_MD5_DIGEST" { $label = "Cipher - Message Digest 5 (MD5)"; } "STATISTIC_SSL_CIPHER_SHA_DIGEST" { $label = "Cipher - Secure Hash Algorithm (SHA)"; } default { $label = "***UNKNOWN***"; } } return $label; } #------------------------------------------------------------------------- # Get-GlobalSSLStatistics #------------------------------------------------------------------------- function Get-GlobalSSLStatistics() { $SystemStatisticsClient = (Get-F5.iControl).SystemStatistics.get_client_ssl_statistics(); $SystemStatisticsServer = (Get-F5.iControl).SystemStatistics.get_server_ssl_statistics(); $t = Get-TimeFromTimeStamp $SystemStatisticsClient.time_stamp; $hash = @{}; $hash.Add("* Time Stamp", $t); $hash.Add("* Type", "(Client, Server)"); $Statistics = $SystemStatisticsClient.statistics; foreach($Statistic in $Statistics) { $val = Convert-To64Bit $Statistic.value.high $Statistic.value.low; $label = Get-StatisticLabel $Statistic.type; $hash.Add($label, $val); } $Statistics = $SystemStatisticsServer.statistics; foreach($Statistic in $Statistics) { $val = Convert-To64Bit $Statistic.value.high $Statistic.value.low; $label = Get-StatisticLabel $Statistic.type; $v1 = $hash[$label]; $hash[$label] = "($v1, $val)"; } $hash.GetEnumerator() | Sort-Object -Property Name | Format-Table -autosize } #------------------------------------------------------------------------- # Do-Initialize #------------------------------------------------------------------------- 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-GlobalSSLStatistics; } else { Write-Error "ERROR: iControl subsystem not initialized" }262Views0likes2CommentsPs Irule Dashboard
Problem this snippet solves: This Powershell application will use iControl and the Google Chart API to build a dashboard to monitor the usage of your iRules. PowerShell is a very extensible scripting language and the fact that it integrates so nicely with iControl means you can do all sorts of fun things with it. In this tech tip, I'll illustrate how to use just a couple of iControl method calls (3 to be exact) to create an iRule monitoring dashboard for you desktop (with a little help from the Google Chart API). Code : #---------------------------------------------------------------------------- # The contents of this file are subject to the "END USER LICENSE AGREEMENT FOR # F5 Software Development Kit for iControl"; you may not use this file except # in compliance with the License. The License is included in the iControl # Software Development Kit. # # Software distributed under the License is distributed on an "AS IS" # basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See # the License for the specific language governing rights and limitations # under the License. # # The Original Code is iControl Code and related documentation # distributed by F5. # # The Initial Developer of the Original Code is F5 Networks, # Inc. Seattle, WA, USA. Portions created by F5 are Copyright (C) 1996-2010 # F5 Networks, Inc. All Rights Reserved. iControl (TM) is a registered # trademark of F5 Networks, Inc. # # Alternatively, the contents of this file may be used under the terms # of the GNU General Public License (the "GPL"), in which case the # provisions of GPL are applicable instead of those above. If you wish # to allow use of your version of this file only under the terms of the # GPL and not to allow others to use your version of this file under the # License, indicate your decision by deleting the provisions above and # replace them with the notice and other provisions required by the GPL. # If you do not delete the provisions above, a recipient may use your # version of this file under either the License or the GPL. #---------------------------------------------------------------------------- param ( $BIGIP = $null, $User = $null, $Pass = $null, $VirtualServer = $null, $iRule = $null, $Metric = "CPUUSAGE", $Debug = $false, $Interval = 10 ); $script:DEBUG = $Debug; $script:TITLE = "iRule Monitor"; $script:VIRTUALSERVER = $VirtualServer; $script:IRULE = $iRule; $script:THEATER = $false; $script:CHARTSIZE = "200x75"; $script:INTERVAL = $Interval; $script:CHARTPREFIX = 0; $script:CPUSPEED = 1600; # CYCLES|RUNTIME|CPUUSAGE|ALL $script:METRIC = $Metric; $script:BROWSER = $null; #------------------------------------------------------------------------- function Write-Usage() #------------------------------------------------------------------------- { Write-Host "Usage: iRuleMonitor.ps1 host uid pwd"; exit; } #------------------------------------------------------------------------- function Write-DebugMessage() #------------------------------------------------------------------------- { param($msg = $null); if ( $script:DEBUG -and ($null -ne $msg) ) { Write-Host "DBG> $msg"; } } #------------------------------------------------------------------------- function Get-VirtualServerList() #------------------------------------------------------------------------- { $vslist = @(); if ( $script:VIRTUALSERVER -eq $null ) { $vslist = (Get-F5.iControl).LocalLBVirtualServer.get_list(); } else { $vslist = (, $script:VIRTUALSERVER); } return $vslist; } #------------------------------------------------------------------------- function Filter-RuleStatistics() #------------------------------------------------------------------------- { param($VirtualServerRuleA, $RuleStatistics); $RuleStatsForVip = @(); foreach($VirtualServerRule in $VirtualServerRuleA) { foreach($RuleStatisticEntry in $RuleStatistics.statistics) { if ( $VirtualServerRule.rule_name -eq $RuleStatisticEntry.rule_name ) { $RuleStatsForVip += @(, $RuleStatisticEntry); } } } if ( $RuleStatsForVip.Length -eq 0 ) { $RuleStatsForVip = $null; } return $RuleStatsForVip; } #------------------------------------------------------------------------- function Convert-To64Bit() #------------------------------------------------------------------------- { param($high, $low); return ($high*[Math]::Pow(2,32))+$low; } #------------------------------------------------------------------------- function Extract-Statistic() #------------------------------------------------------------------------- { param($StatisticA, $type); $value = -1; foreach($Statistic in $StatisticA) { if ( $Statistic.type -eq $type ) { $value = Convert-To64Bit $Statistic.value.high $Statistic.value.low; break; } } return $value; } #------------------------------------------------------------------------- function Get-ChartPrefix() #------------------------------------------------------------------------- { $prefix = $script:CHARTPREFIX % 10; $script:CHARTPREFIX++; return "${prefix}."; } #------------------------------------------------------------------------- function Get-Chart() #------------------------------------------------------------------------- { param($min, $val, $max, $type, $fmt); $chart = ""; Write-DebugMessage "Querying chart for '$min', '$val', '$max', '$type'..."; if ( ($null -ne $val) -and ($null -ne $fmt) ) { $val = $val.ToString($fmt); } $suffix = ""; switch($type) { "CYCLES" { $suffix = ""; } "RUNTIME" { $suffix = " ms."; } "CPUUSAGE" { $suffix = "%"; } } $prefix = Get-ChartPrefix; $charturl = "http://${prefix}chart.apis.google.com/chart?cht=gom"; $charturl += "&chs=$($script:CHARTSIZE)"; $charturl += "&chco=00FF00,FF0000"; $charturl += "&chds=$min,$max"; $charturl += "&chd=t:$val"; $charturl += "&chxt=x,y"; $charturl += "&chxl=0:|$val$suffix|1:|0||$max"; $charturl += "&chf=c,lg,45,FFE7C6,0,76A4FB,0.75"; Write-DebugMessage "returning chart: $charturl..."; $chart += " "; switch($type) { "CYCLES" { $chart += " CPU Cycles/Request "; } "RUNTIME" { $chart += " Runtime (ms)/Request "; } "CPUUSAGE" { $chart += " Percent CPU Usage/Request "; } "ERRORS" { $chart += " Total Errors "; } } $chart += ""; return $chart; } #------------------------------------------------------------------------- # function Get-Data #------------------------------------------------------------------------- function Get-Data() { $now = [DateTime]::Now; $page_data = " $($script:TITLE) body,td,th { font-family: Tahoma; font-size: 10pt; } .datatable { background-color: #C0C0C0; } .colheader { background-color: cyan; } .rowheader { background-color: yellow; } iRule Monitor $now "; $vslist = [string[]]$(Get-VirtualServerList); $VirtualServerRuleAofA = (Get-F5.iControl).LocalLBVirtualServer.get_rule( $vslist ); $RuleStatistics = (Get-F5.iControl).LocalLBRule.get_all_statistics(); # loop through all the virtual servers for($i=0; $i -lt $VirtualServerRuleAofA.Length; $i++) { $vs = $vslist[$i]; # rules for current vs $VirtualServerRuleA = $VirtualServerRuleAofA[$i]; # rule stats for current vs $RuleStatisticEntryA = Filter-RuleStatistics $VirtualServerRuleA $RuleStatistics; if ( $RuleStatisticEntryA -ne $null ) { # Build out a column list... $columns = @{}; foreach($RuleStatisticEntry in $RuleStatisticEntryA) { if ( ($columns.count -eq 0) -or ($null -eq $columns[$RuleStatisticEntry.event_name]) ) { $columns.Add($RuleStatisticEntry.event_name, 0); } } $scolumns = $columns.GetEnumerator() | Sort-Object Name; # Build out result graphs Write-DebugMessage "VIRTUAL SERVER $vs"; $page_data += " " $page_data += " Virtual Server '$vs' "; $page_data += " iRule " foreach($key in $scolumns) { $page_data += " $($key.Name) "; } $page_data += " "; # loop through all rules for current virtual server foreach($VirtualServerRule in $VirtualServerRuleA) { if ( ($null -eq $script:IRULE) -or ($VirtualServerRule.rule_name -eq $script:IRULE) ) { $page_data += " "; $page_data += " $($VirtualServerRule.rule_name) "; foreach($key in $scolumns) { $aborts = $null; $avg_cycles = $null; $failures = $null; $max_cycles = $null; $min_cycles = $null; $total_executions = $null; foreach($RuleStatisticEntry in $RuleStatisticEntryA) { if ( ($RuleStatisticEntry.rule_name -eq $VirtualServerRule.rule_name) -and ($RuleStatisticEntry.event_name -eq $key.Name) ) { Write-DebugMessage "Searching for '$($RuleStatisticEntry.rule_name), $($RuleStatisticEntry.event_name)..."; # Found a match for the row and column $min_cycles = Extract-Statistic $RuleStatisticEntry.statistics "STATISTIC_RULE_MINIMUM_CYCLES"; $avg_cycles = Extract-Statistic $RuleStatisticEntry.statistics "STATISTIC_RULE_AVERAGE_CYCLES"; $max_cycles = Extract-Statistic $RuleStatisticEntry.statistics "STATISTIC_RULE_MAXIMUM_CYCLES"; $aborts = Extract-Statistic $RuleStatisticEntry.statistics "STATISTIC_RULE_ABORTS"; $failures = Extract-Statistic $RuleStatisticEntry.statistics "STATISTIC_RULE_FAILURES"; $total_executions = Extract-Statistic $RuleStatisticEntry.statistics "STATISTIC_RULE_TOTAL_EXECUTIONS"; break; } } $min = 0; $data_value = $null; $max = 5000; $speedMhz = [Convert]::ToDouble($script:CPUSPEED); $speed = [Convert]::ToUInt64(1000000 * $speedMhz); $cycles_min = $min_cycles; $cycles_avg = $avg_cycles; $cycles_max = $max_cycles; $runtime_min = [Convert]::ToDouble($min_cycles) * (1000.0/$speed); $runtime_avg = [Convert]::ToDouble($avg_cycles) * (1000.0/$speed); $runtime_max = [Convert]::ToDouble($max_cycles) * (1000.0/$speed); $cpu_min = 0; #$min = 100.0 * ([Convert]::ToDouble($min_cycles) / [Convert]::ToDouble($speed)); $cpu_avg = 100.0 * ([Convert]::ToDouble($avg_cycles) / [Convert]::ToDouble($speed)); #$max = 100.0 * ([Convert]::ToDouble($max_cycles) / [Convert]::ToDouble($speed)); $cpu_max = 100; if ( 0 -eq $data_value ) { $data_value = $null; } if ( $null -ne $data_value ) { $data_value = $data_value.ToString("0.0000"); } $cycles_chart = Get-Chart $cycles_min $cycles_avg $cycles_max "CYCLES"; $runtime_chart = Get-Chart $runtime_min $runtime_avg $runtime_max "RUNTIME" "0.00000"; $cpu_chart = Get-Chart $cpu_min $cpu_avg $cpu_max "CPUUSAGE" "0.00000"; $success_chart = Get-Chart 0 ($aborts + $failures) $total_executions "ERRORS"; Write-DebugMessage $charturl; $page_data += " "; switch($script:METRIC) { "CYCLES" { $page_data += "$cycles_chart"; $page_data += $success_chart; } "RUNTIME" { $page_data += "$runtime_chart"; $page_data += $success_chart; } "CPUUSAGE" { $page_data += "$cpu_chart"; $page_data += $success_chart; } "ALL" { $page_data += $cycles_chart; $page_data += $runtime_chart; $page_data += $cpu_chart; $page_data += $success_chart; } default { $page_data += "$cycles_chart"; } } $page_data += " "; } $page_data += " "; } } $page_data += " " } } $page_data += " "; return $page_data; } #------------------------------------------------------------------------- function Refresh-Browser() #------------------------------------------------------------------------- { param($file_data); if ( $null -eq $script:BROWSER ) { Write-DebugMessage "Creating new Browser" $script:BROWSER = New-Object -com InternetExplorer.Application; $script:BROWSER.Navigate2("About:blank"); $script:BROWSER.Visible = $true; $script:BROWSER.TheaterMode = $script:THEATER; } $docBody = $script:BROWSER.Document.DocumentElement.lastChild; $docBody.InnerHTML = $file_data; } #------------------------------------------------------------------------- function Kill-Browser() #------------------------------------------------------------------------- { if ( $null -ne $script:BROWSER ) { $script:BROWSER.TheaterMode = $false; $script:BROWSER.Quit(); $script:BROWSER = $null; } } #------------------------------------------------------------------------- function Run-Dashboard() #------------------------------------------------------------------------- { while($true) { Write-Host "Requesting data..." $file_data = Get-Data; Refresh-Browser $file_data; Start-Sleep $script:INTERVAL; } } #------------------------------------------------------------------------- # Do-Initialize #------------------------------------------------------------------------- function Do-Initialize() { if ( (Get-PSSnapin | Where-Object { $_.Name -eq "iControlSnapIn"}) -eq $null ) { Add-PSSnapIn iControlSnapIn } $success = Initialize-F5.iControl -HostName $BIGIP -Username $User -Password $Pass; return $success; } #------------------------------------------------------------------------- # Exception handling #------------------------------------------------------------------------- Trap [Exception] { Write-Host $("TRAPPED: " + $_.Exception.GetType().FullName); Write-Host $("TRAPPED: " + $_.Exception.Message); Kill-Browser Exit; } #------------------------------------------------------------------------- # Main Application Logic #------------------------------------------------------------------------- if ( ($BIGIP -eq $null) -or ($User -eq $null) -or ($Pass -eq $null) ) { Write-Usage; } if ( Do-Initialize ) { Run-Dashboard } else { Write-Error "ERROR: iControl subsystem not initialized" Kill-Browser }198Views0likes1Comment