Home > Uncategorized > Build SCOM *like* Reports for SharePoint using PowerShell (F5 – BIG IP)

Build SCOM *like* Reports for SharePoint using PowerShell (F5 – BIG IP)

In my SharePoint 2010 environment we are leveraging two F5 BIG-IP servers as our network load balancer servers that sit between our TMG server, and SharePoint Web Front end servers. I needed to generate some SCOM *Like* dashboards that pulled statistics from the F5 to display to the end user, specifically the helpdesk to give them direct insight to on-the-minute/demand statistical updates for our servers. Since there is “separation of duties” where I work the helpdesk has no insight into our F5 BIG-IP Servers or configurations. This is where I turn to PowerShell to help pull statistics from the F5 and display them to the users.

To get started you first need to register the F5 iControl cmdlet assemblies to the server where you will be execting the PowerShell scripts.

To download the icontrol cmdlets visit here: https://devcentral.f5.com/d/microsoft-powershell-with-icontrol

Once the icontrol cmdlets are downloaded move the files over to the server where you will be executing the PS Script and unpackage the zip file.

Inside the zip file “f5-icontrol-powershell-snapin-12_1_0” folder you will find the setupSnap.ps1 file. Open up a PowerShell console with Admin rights and browse to the location where the setupSnap.ps1 is.

Execute the setupSnapin.ps1 – .\setupSnapin.ps1
Once the PowerShell script executes and finishes the icontrol .dll assesmblies are applied.

Now you are free to execute F5 BIG-IP iControl cmdlets in PowerShell on that server.

Below is the PowerShell script I executed to help me achieve my goal. I won’t take full credit for this script, the credit goes to Patrik on devcenter for the code snippet. – https://devcentral.f5.com/questions/obtain-node-name-by-node-description-using-powershell#comment43426 I took his example and built around it to achieve my goal.

—————————————————–

#Initialize Snapin
if ( (Get-PSSnapin | Where-Object { $_.Name -eq "iControlSnapIn"}) -eq $null ){
    Add-PSSnapIn iControlSnapIn
}

#Setup credentials
$User = "user"
$Password = "password"
$BigIP = "xx.xx.xx.xx"
$Partition = "PARTITION NAME"

#Add a type/class to store the node data in
Add-Type @'
public class Member
{
    public string Pool;
    public string Address;
    public string Port;
    public string Name;
    public string Availablity;
    public string Enabled;
    public string Status;
    public string Connections;
}
'@

#Create an empty array to store the node objects in
$Nodes = @()
$NodeDict = @{}

#Connect to the BigIP and get an iControl Handle
$Success = Initialize-F5.iControl -HostName $BigIP -Username $User -Password $Password
$F5 = Get-F5.iControl

#Get the partition list
$f5partitions = $F5.ManagementPartition
$f5partitions.set_active_partition($Partition)

#Get Pool Lists, Status, Nodes

$PoolList = $F5.LocalLBPool.get_list()
$PoolMembers = $F5.LocalLBPool.get_member_V2($PoolList)
$PoolMemberStatus = $F5.LocalLBPool.get_member_object_status($PoolList, $PoolMembers)
$NodeList = $F5.LocalLBNodeAddressV2.get_list()
$NodeIPList = $F5.LocalLBNodeAddressV2.get_address($NodeList)

#Save the nodes in a dictionary for convenient access

for ($i=0; $i -lt ($NodeList.Count); $i++)
{
    $NodeDict.Add($NodeList[$i], $NodeIPList[$i])
}
for ($i=0; $i -lt ($PoolList.Count); $i++)
{
    for ($x=0; $x -lt ($PoolMembers[$i].Count); $x++)
    {
         $objTempMember = New-Object Member

         #Populate the object
         $objTempMember.Pool = $PoolList[$i]
         $objTempMember.Name = $PoolMembers[$i][$x].address
         $objTempMember.Address = $NodeDict[$objTempMember.Name]
         $objTempMember.Port = $PoolMember[$i][$x].port
         $objTempMember.Availability = $PoolMemberStatus[$i][$x].availability_status
         $objTempMember.Enabled = $PoolMemberStatus[$i][$x].enabled_status
         
         #Get Current Connections
         $MemberStatisticsA = $F5.LocalLBNodeAddress.get_statistics($objTempMember.Address);
         $MemberStatisticEntry = $MemberStatisticsA.Statistics;
         $Statistics = $MemberStatisticEntry[0].statistics;

         foreach ($Statistic in $Statistics)
         {
                 $type = $Statistic.type;
                 $value = $Statistic.value;

                 if ($type -eq "STATISTIC_SERVER_SIDE_CURRENT_CONNECTIONS" -and $objTempMember.Port -eq "443")
                 {
                       $cur_connections = $value.low
                       $objTempMember.Connections = $cur_connections
                 }

         }
         $Nodes += $objTempMember
         
         $Outputreport = "<HTML><HEAD><META HTTP-EQIV=""refresh"" content=""60""><TITLE>SharePoint F5 Node Status</TITLE></HEAD>         
         <BODY background-color:peachpuff>
         <Font color=""#99000"" face=""Microsoft Tai le"">
         <center><H2> SharePoint F5 Node Status </H2></font></center>
         <Table border="1" cellpadding="0" cellspacing="0">
         <TR bgcolor="gray" align="center">
         <TD><B>Name</B></TD>
         <TD><B>Address</B></TD>
         <TD><B>Port</B></TD>
         <TD><B>Enabled</B></TD>
         <TD><B>Status</B></TD>
         <TD><B>Connections</B></TD></TR>"

         foreach ($Entry in $Nodes)
         {
                $Outputreport += "<TR><TD>$($Entry.Name)</TD><TD align="center">$($Entry.Address)</TD><TD align="center">$($Entry.Port)</TD><TD align="center">$($Entry.Enabled)</TD><TD align="center">$($Entry.Status)</TD><TD align="center">$($Entry.Connections)</TD></TR>"
         }
         $Outputreport += "</Table></BODY></HTML>"

    }
}
$Outputreport | out-file

Once the script was created I created a Task Scheduler to execute the script every 5 mintues. ON the report build I had a refresh of 60 seconds to update the dashboard so the end users did not have to do any interaction with the report.

Advertisements
Categories: Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: