Share via


OMS Dashboard Extension for the Upgrade Helper MP for SCOM 2012 R2 to 2016

The Upgrade Helper For SCOM 2012 R2 to 2016 Dashboard extends the new Upgrade Helper Management Pack to Operations Management Suite (OMS). It provides a summary view of the overall upgrade state of a System Center Operations Manager Management Group moving from 2012 R2 to 2016, and is accessible through the OMS Portal.

image                image

The Upgrade Helper Management Pack, the .omsview JSON file for the OMS Upgrade Helper Dashboard and the collection script can now be downloaded from the TechNet Gallery.

The OMS Upgrade Helper Dashboard consists of a summary tile on the main page of the OMS Portal that shows the number and percentage of core components already upgraded or not upgraded to OpsMgr 2016 within a management group of interest, and the following views are available when drill-in from the summary tile:

  1. Information View  Provides a summary description for the OMS Upgrade Helper Dashboard, links to obtain further information and to download the Upgrade Helper Management Pack, the . omsview JSON file for and the collection script.
  2. Upgrade State of Core Components View – Provides a summary of the overall upgrade state of the core components of the management group of interest by showing the percentage and number of core components already upgraded or not upgraded to OpsMgr 2016 on the Donut section, and listing the names of all the core components, their upgrade state and their roles on the List section of the View.
  3. Upgrade State of Agents View Provides a summary of the overall upgrade state of the agents of the management group of interest by showing the percentage and number of agents already upgraded or not upgraded to OpsMgr 2016 on the Donut section, and only listing the names and versions of each agents that have yet to be upgraded on the List section of the View.
  4. SCOM Agent Patch List View – Provides a count of the total number of agents found in the management group of interest on the Single Number section, and a list of agent patches identified with the number of occurrences found for each patch list in the management group of interest on the List section of the View.

 image

Here are the steps on how to:

  • Implement the OMS Upgrade Helper Dashboard to an OMS Workspace, and
  • Collect and send the required upgrade state data of a management group to the OMS Workspace to be displayed on the Upgrade Helper Dashboard.

To implement the OMS Upgrade Helper Dashboard to an OMS Workspace, download the .omsview JSON file from the TechNet Gallery and upload the file to the OMS Workspace using the Import option in the View Designer.

image 

To collect and send the required upgrade state data of a management group to an OMS Workspace, use the sample data collection script that can be downloaded together with the .omsview JSON file from the TechNet Gallery. The sample collection script is written in PowerShell and leverages the OMS HTTP Collector API  to introduce a Custom Log Type for the upgrade state data –  OM16UpgradeState, and to send the collected data to the OMS Workspace in a JSON payload.

Here is the sample PowerShell script used in the data collection script (UpgradeStatusCollectionScript.SendtoOMS.v1.ps1):
IMPORTANT NOTE:
This collection script must either be (1.) run on the Operations Manager Shell or in a PowerShell session with the OperationsManager module imported, (2.) connected to the Operations Manager management group of interest (3.) with the Upgrade Helper Management Pack imported, and (4.) have access to the internet via HTTP.

 # Replace with your Workspace ID
$CustomerId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" 
  
# Replace with your Primary Key
$SharedKey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

#Specify the name of the record type that we'll be creating.
$LogType = "OM16UpgradeState"

#Specify a time in the format YYYY-MM-DDThh:mm:ssZ to specify a created time for the records.
$TimeStampField = ""

$coreComponentArray=@()
$agentCollectionArray=@()

# Function to create the authorization signature.
Function Build-Signature ($customerId, $sharedKey, $date, $contentLength, $method, $contentType, $resource)
{
    $xHeaders = "x-ms-date:" + $date
    $stringToHash = $method + "`n" + $contentLength + "`n" + $contentType + "`n" + $xHeaders + "`n" + $resource

    $bytesToHash = [Text.Encoding]::UTF8.GetBytes($stringToHash)
    $keyBytes = [Convert]::FromBase64String($sharedKey)

    $sha256 = New-Object System.Security.Cryptography.HMACSHA256
    $sha256.Key = $keyBytes
    $calculatedHash = $sha256.ComputeHash($bytesToHash)
    $encodedHash = [Convert]::ToBase64String($calculatedHash)
    $authorization = 'SharedKey {0}:{1}' -f $customerId,$encodedHash
    return $authorization
}

# Function to create and post the request
Function Post-OMSData($customerId, $sharedKey, $body, $logType) 
{
    $method = "POST"
    $contentType = "application/json"
    $resource = "/api/logs"
    $rfc1123date = [DateTime]::UtcNow.ToString("r")
    $contentLength = $body.Length
     $signature = Build-Signature `
        -customerId $customerId `
        -sharedKey $sharedKey `
        -date $rfc1123date `
        -contentLength $contentLength `
        -fileName $fileName `
        -method $method `
        -contentType $contentType `
        -resource $resource
    $uri = "https://" + $customerId + ".ods.opinsights.azure.com" + $resource + "?api-version=2016-04-01"

    $headers = @{
        "Authorization" = $signature;
        "Log-Type" = $logType;
        "x-ms-date" = $rfc1123date;
        "time-generated-field" = $TimeStampField;
    }

    $response = Invoke-WebRequest -Uri $uri -Method $method -ContentType $contentType -Headers $headers -Body $body -UseBasicParsing
    return $response.StatusCode
} 


#////Main Section////

$coreComponentClass = get-scomclass -name OperationsManager2016.Upgrade.CoreComponent
$coreComponents = Get-SCOMClassInstance -class $coreComponentClass
foreach ($coreComponent in $coreComponents) {

$Hostname = $coreComponent.Name
$ComponentVersion = $coreComponent.'[OperationsManager2016.Upgrade.CoreComponent].ComponentVersion'.value
$Role = $coreComponent.'[OperationsManager2016.Upgrade.CoreComponent].Role'.value
If($coreComponent.HealthState -ne "Success")
{$UpgradeState = "Not Upgraded"}
else
{$UpgradeState = "Success"}
$IsAvailable = $coreComponent.IsAvailable
$OMManagementGroupName = $coreComponent.ManagementGroup
$FullName = $coreComponent.FullName
$LastModified = ($coreComponent.LastModified).ToString("yyyy-MM-ddThh:mm:ssZ");
$OMObjectId= $coreComponent.Id
$OMManagementGroupId= $coreComponent.ManagementGroupId
$AgentPatchList= ""
$AgentManagement =""
$coreComponentArray += @{"Hostname"=$Hostname.ToString();"ComponentVersion"=$ComponentVersion.ToString();"Role"=$Role.ToString();"UpgradeState"=$UpgradeState.ToString();"IsAvailable"=$IsAvailable.ToString();"OMManagementGroupName"=$OMManagementGroupName.ToString();"FullName"=$FullName.ToString();"LastModified"=$LastModified;"OMObjectId"=$OMObjectId;"OMManagementGroupId"=$OMManagementGroupId;"AgentPatchList"=$AgentPatchList.ToString();"AgentManagement"=$AgentManagement.ToString()}
}


$agentClass = get-scomclass -Name Microsoft.SystemCenter.Agent
$Agents = Get-SCOMClassInstance -class $agentClass
foreach ($Agent in $Agents) {

$Hostname = $Agent.Path
$ComponentVersion = $Agent.'[Microsoft.SystemCenter.HealthService].Version'.value
$Role = "Agent"
If($ComponentVersion -gt 7.2)
{$UpgradeState = "Success"}
else
{$UpgradeState = "Not Upgraded"}
$IsAvailable = $Agent.IsAvailable
$OMManagementGroupName = $Agent.ManagementGroup
$FullName = $Agent.FullName
$LastModified = ($Agent.LastModified).ToString("yyyy-MM-ddThh:mm:ssZ");
$OMObjectId= $Agent.Id
$OMManagementGroupId= $Agent.ManagementGroupId
$AgentPatchList= $Agent.'[Microsoft.SystemCenter.HealthService].PatchList'.value
$AgentInstallation = $Agent.'[Microsoft.SystemCenter.HealthService].IsManuallyInstalled'.value
If($AgentInstallation -eq $True)
{$AgentManagement ="Manual"}
else
{$AgentManagement ="Remote"}
$agentCollectionArray += @{"Hostname"=$Hostname.ToString();"ComponentVersion"=$ComponentVersion.ToString();"Role"=$Role.ToString();"UpgradeState"=$UpgradeState.ToString();"IsAvailable"=$IsAvailable.ToString();"OMManagementGroupName"=$OMManagementGroupName.ToString();"FullName"=$FullName.ToString();"LastModified"=$LastModified;"OMObjectId"=$OMObjectId;"OMManagementGroupId"=$OMManagementGroupId;"AgentPatchList"=$AgentPatchList.ToString();"AgentManagement"=$AgentManagement.ToString()}
}

$coreComponentArrayJSON = $coreComponentArray | ConvertTo-JSON
# Submit the data to the API endpoint - for core components
Post-OMSData -customerId $customerId -sharedKey $sharedKey -body ([System.Text.Encoding]::UTF8.GetBytes($coreComponentArrayJSON)) -logType $logType

If($agentCollectionArray.count -lt 480)
{
$agentCollectionArrayJSON = $agentCollectionArray | ConvertTo-JSON

# Submit the data to the API endpoint - for agents
Post-OMSData -customerId $customerId -sharedKey $sharedKey -body ([System.Text.Encoding]::UTF8.GetBytes($agentCollectionArrayJSON)) -logType $logType
}
else
{
    $indextracking=0
    ForEach($collectedAgentItem in $agentCollectionArray)
    {
        # Submit the data to the API endpoint - for agents
        $collectedAgentItemFixed = ConvertTo-Json -InputObject @($collectedAgentItem) 
        Post-OMSData -customerId $customerId -sharedKey $sharedKey -body ([System.Text.Encoding]::UTF8.GetBytes($collectedAgentItemFixed)) -logType $logType

        $indextracking++

   }
}

If successful, the upgrade state data collected by the HTTP Collector API should appear in the OMS Upgrade Helper Dashboard in the targeted OMS Workspace within a few minutes.

To list all records of the OM16UpgradeState type that were successfully sent to the targeted workspace, run the Type=OM16UpgradeState_CL search query. The records returned from the search result should appear as follows with the field data types identified accordingly as indicated by their suffix:
image 

The search queries used to power each of the Views within the Upgrade Helper Dashboard will filter these records to summarize and display them accordingly as show in the following example:

image 

The tooltip feature displays the full name when hovering the pointer above the line item in the List view.
image 

Here are the queries for each visualization and navigation component of each View in the Upgrade Helper Dashboard above:

 ##Upgrade State of Core Components
#Donut Query
Type=OM16UpgradeState_CL Role_s!=Agent| measure count() by UpgradeState_s
#List Query
Type=OM16UpgradeState_CL Role_s!=Agent | Measure Countdistinct(Hostname_s) by Hostname_s, UpgradeState_s, Role_s
#Navigation Query
Type=OM16UpgradeState_CL Role_s!=Agent

##Upgrade State of Agents
#Donut Query
Type=OM16UpgradeState_CL Role_s=Agent | measure count() by UpgradeState_s
#List Query
Type=OM16UpgradeState_CL Role_s=Agent UpgradeState_s="Not Upgraded" | Measure Countdistinct(Hostname_s) by Hostname_s, ComponentVersion_s
#Navigation Query
"Type=OM16UpgradeState_CL Role_s=Agent UpgradeState_s="Not Upgraded"

##SCOM Agent Patch List
#Number Tile Query
Type=OM16UpgradeState_CL Role_s=Agent
#List Query
Type=OM16UpgradeState_CL Role_s=Agent | Measure Count() by  AgentPatchList_s
#Navigation Query
Type=OM16UpgradeState_CL Role_s=Agent

Additional Resources:

Log Analytics HTTP Data Collector API by Brian Wren
https://azure.microsoft.com/en-us/documentation/articles/log-analytics-data-collector-api/

HTTP Data Collector API: Send us data from space… or anywhere! by Evan Hissey
https://blogs.technet.microsoft.com/msoms/2016/08/30/http-data-collector-api-send-us-data-from-space-or-anywhere/

OMS View Designer: Visualize your data your way by Evan Hissey
https://blogs.technet.microsoft.com/msoms/2016/06/30/oms-view-designer-visualize-your-data-your-way/

 

Disclaimer:
All information on this blog is provided on an as-is basis with no warranties and for informational purposes only. Use at your own risk. The opinions and views expressed in this blog are those of the author and do not necessarily state or reflect those of my employer.