question

Zid-3479 avatar image
0 Votes"
Zid-3479 asked MdRubiatHaque-0645 commented

SCOM 2016 dashboard view to display resource utilization of all servers

Hi Guys,

I have been trying for weeks to create a SCOM custom dashboard view to display current CPU%, RAM%, Network%, C drive %, D drive % in one single view. SCOM has the limitation to display only the "Top 20" resource utilization but in my case I have more than 60+ server and all of them needs to be displayed. I was suggested that this could be possible using a PowerShell dashboard and I have done too many research to find a script which could help me based on my requirement but unfortunately could not find any blogs or post which is relevant to my need. Could someone please help me out with my request?

msc-operations-manager
· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@Zid-3479, Research but not find the sample to create a dashboard with PowerShell script to get resource utilization. For PowerShell script, I find some similar links for the reference:
https://www.reddit.com/r/PowerShell/comments/ayo3yo/looking_for_a_simple_script_to_get_cpu_usage_top/
https://www.powershellbros.com/get-memory-utilization-report-using-powershell/
Note: Non-Microsoft link just for the reference.

For your request, I notice this needs strong PowerShell script skills. To get more professional help, we suggest to open a case to help on this. Here is a link with the Phone number for the reference:
https://support.microsoft.com/en-us/topic/global-customer-service-phone-numbers-c0389ade-5640-e588-8b0e-28de8afeb3f2

Thanks for the understanding and have a nice day!

0 Votes 0 ·

Thanks @Crystal-MSFT for your response. I understand this needs some strong PowerShell scripting and I was hoping that someone would have come across this scenario as a request to implement in their work. I am still clueless on how to proceed this further.

0 Votes 0 ·

@everyone, If any one has such experience, I appreciate your help to share here. Thanks for your help in advance.

@Zid-3479, let's wait to see if anyone has the similar experience can share here to help us. If still no response, we can open case to get more help.

0 Votes 0 ·
AlexZhu-MSFT avatar image
0 Votes"
AlexZhu-MSFT answered Zid-3479 edited

Hi,

Thank you for asking this. For a quick lab test, I've created a dashboard view with two grid columns and add the PowerShell Grid Widget for one of them. And the powershell is something like this.

 $class = Get-SCOMClass -Name Microsoft.Windows.Computer
 $computers = Get-SCOMClassInstance -Class $class
 $i=1
 foreach ($computer in $computers)
 {
     $cpu_usage = (Get-WmiObject -ComputerName $computer -Class win32_processor -ErrorAction silentlycontinue | Measure-Object -Property LoadPercentage -Average | Select-Object Average).Average.ToString()+"%"
     $dataObject=$ScriptContext.CreateFromObject($computer,"Id=Id,HealthState=HealthState,DisplayName=DisplayName",$null)
     $dataObject["Index"]=$i
     $dataObject["CPU_Usage"]=$cpu_usage
     $ScriptContext.ReturnCollection.Add($dataObject)
     $i++
 }

Note: Get-WmiObject need remote administration permission on target computer. We can set -ErrorAction Stop to see if any errors. If 0x800706BA error appears, check this article:
https://www.vspbreda.nl/nl/server-os/server-2008/error-get-wmiobject-the-rpc-server-is-unavailable-exception-from-hresult-0x800706ba/
Note: the above link is not from MS, just for your reference.

After that, the output is like this:

111986-scom-pwershell-dashboard-01.png

For more information about dashboard scrip widget, we may refer to:
https://social.technet.microsoft.com/wiki/contents/articles/24595.operations-manager-dashboard-script-widgets.aspx

Alex
If the response is helpful, please click "Accept Answer" and upvote it.



· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi Alex,
Thank you for the solution. Works perfect. I have further added wmi objects but I have an issue which I am unable to identify in the script.
$class = Get-SCOMClass -Name Microsoft.Windows.Computer
$computers = Get-SCOMClassInstance -Class $class
$i=1
foreach ($computer in $computers)
{
$cpu_usage = (Get-WmiObject -ComputerName $computer -Class win32_processor | Measure-Object -Property LoadPercentage -Average | Select-Object Average).Average.ToString()
$mem_usage = Get-WmiObject win32_operatingsystem -ComputerName $c | Foreach {"{0:N2}" -f ((($.TotalVisibleMemorySize - $.FreePhysicalMemory)*100)/ $.TotalVisibleMemorySize)}
$disk_usage_c = Get-WmiObject Win32_Volume -ComputerName $c -Filter "DriveLetter = 'C:'" | Foreach {"{0:N2}" -f (($.FreeSpace / $.Capacity)*100)}
$disk_usage_d = Get-WmiObject Win32_Volume -ComputerName $c -Filter "DriveLetter = 'D:'" | Foreach {"{0:N2}" -f (($.FreeSpace / $_.Capacity)*100)} $dataObject=$ScriptContext.CreateFromObject($computer,"Id=Id,HealthState=HealthState,DisplayName=DisplayName",$null)
$dataObject["Index"]=$i
$dataObject["CPU%"]=$cpu_usage
$dataObject["Memory%"]=$mem_usage
$dataObject["C:Drive"]=$disk_usage_c
$dataObject["D:Drive"]=$disk_usage_d
$ScriptContext.ReturnCollection.Add($dataObject)
$i++
}
The script loads all the resource data when only one server is listed but when multiple servers are listed then the Mem% & DiskFree% details does not fetch data.

0 Votes 0 ·

Output with a single server:
113027-powershelldashboard1.png

Output with multiple servers:
113105-powershelldashboard2.png

Could you please help me if I am missing anything on the script to get it working. @AlexZhu-MSFT


0 Votes 0 ·
badgerbadger avatar image
0 Votes"
badgerbadger answered

Hi,

as Crystal said, you can do this with Powershell or SQL.

If you're looking for SCOM dashboards not only for this but for a lot more other features you can check out squaredup.com they specialize in SCOM dashboards :)

Cheers

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

CyrAz avatar image
1 Vote"
CyrAz answered CyrAz edited

Indeed, there are so many ways to do this...
As long as the data is collected by SCOM and therefore stored in the Datawarehouse, you can display it with whatever tool you like.
Native perf report, powershell, raw SQL query, PowerBI, Grafana or as suggested by @sameermhaisekar : SquaredUp (probably the best option).

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Zid-3479 avatar image
0 Votes"
Zid-3479 answered

Hi Guys,

Thanks for all your response. I got held up with something else and wasn't able to respond to your suggestions.
I tried to query the logical disk details using powershell script for sample on operations manager shell and was able to get the data but when using the same script on the SCOM dashboard it does not fetch any details. it keeps loading with no response.

@AlexZhu-MSFT : Hi Alex.. I found few post of yours which I could relate with my request and thought you might be able to help me on this ?

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

AlexZhu-MSFT avatar image
1 Vote"
AlexZhu-MSFT answered Zid-3479 commented

Hi Zid-3479,

It seems the script contains minor spelling error that prevents the result. I've changed the script slightly and you may have a try in your environment.

 $class = Get-SCOMClass -Name Microsoft.Windows.Computer
 $computers = Get-SCOMClassInstance -Class $class
 $i=1
 foreach ($computer in $computers)
 {
     $cpu_usage = (Get-WmiObject -ComputerName $computer -Class win32_processor | Measure-Object -Property LoadPercentage -Average | Select-Object Average).Average.ToString()
     $mem_usage = Get-WmiObject win32_operatingsystem -ComputerName $computer | Foreach {"{0:N2}" -f ((($_.TotalVisibleMemorySize - $_.FreePhysicalMemory)*100)/ $_.TotalVisibleMemorySize)}
     $disk_usage_c = Get-WmiObject Win32_Volume -ComputerName $computer -Filter "DriveLetter = 'C:'" | Foreach {"{0:N2}" -f (($_.FreeSpace / $_.Capacity)*100)}
     $disk_usage_d = Get-WmiObject Win32_Volume -ComputerName $computer -Filter "DriveLetter = 'D:'" | Foreach {"{0:N2}" -f (($_.FreeSpace / $_.Capacity)*100)}
     $dataObject=$ScriptContext.CreateFromObject($computer,"Id=Id,HealthState=HealthState,DisplayName=DisplayName",$null)
     $dataObject["Index"]=$i
     $dataObject["CPU%"]=$cpu_usage
     $dataObject["Memory%"]=$mem_usage
     $dataObject["C:Drive"]=$disk_usage_c
     $dataObject["D:Drive"]=$disk_usage_d
     $ScriptContext.ReturnCollection.Add($dataObject)
     $i++
 }

screenshot for your reference:

113144-scom-pwershell-dashboard-02.png

Alex
If the response is helpful, please click "Accept Answer" and upvote it.




· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @AlexZhu-MSFT ,

I have two scenarios where I get timeout error when trying to view the PowerShell dashboard.

  • The dashboard does not load on the console for a Management group where it has more than 150+ servers to be listed but at the same time it loads for another Management group where there are less than 5 server to display. And the SCOM console here is accessed from the Management server.

  • The dashboard keeps loading and does not fetch any results when I try to access from a non management server (Eg. SCOM Console installed on my local machine)

Error code below for the above two scenarios:

Microsoft.EnterpriseManagement.Presentation.DataAccess.DataProviderException: An error occurred executing the command: [Microsoft.SystemCenter.Visualization.Component.Library.DataProviders!PowershellProvider/ExecutePowershellDataSourceScript] in provider: [Microsoft.SystemCenter.Visualization.Component.Library.DataProviders.PowershellProvider, Microsoft.SystemCenter.Visualization.Component.Library.DataProviders, Version=7.0.5000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35].The operation has timed out. ---> System.TimeoutException: The operation has timed out.
at Microsoft.EnterpriseManagement.Monitoring.DataProviders.RetryCommandExecutionStrategy.Invoke(IDataProviderCommandMethodInvoker invoker)
at Microsoft.EnterpriseManagement.Presentation.DataAccess.DataProviderCommandMethod.Invoke(CoreDataGateway gateWay, DataCommand command)


0 Votes 0 ·

Hi @AlexZhu-MSFT .. Do you have any idea on the cause for the time-out in running the script on dashboard? I believe there are no options in SCOM to increase the time-out limit as far the research which I have done through. Please let me know if you have a solution for this. Thanks in advance.

0 Votes 0 ·
AlexZhu-MSFT avatar image
1 Vote"
AlexZhu-MSFT answered MdRubiatHaque-0645 commented

Hi,

Sorry for missing your reply. For the time-out issue, it seems we can add some debugging to find out which server(s) spend more times and take actions accordingly. For example, some servers may be shutdown.

For the remote console issue, it seems there is no perfect way to solve this and we may fire up a ticket in the uservoice to see if product team can work on this. Currently, we may consider that we RDP to the management server.

General Operations Manager Feedback
https://systemcenterom.uservoice.com/forums/293064-general-operations-manager-feedback

Also, I noticed that this thread is about two months ago. Commonly, new posts are more likely to get noticed. If possible, you may create a new thread to see if anyone who ever experienced the similar situation can help.

For debugging, we can run the following script on the management server directly

 $time_begin_0 = get-date
 $class = Get-SCOMClass -Name Microsoft.Windows.Computer
 $computers = Get-SCOMClassInstance -Class $class
 $i=1
 foreach ($computer in $computers)
 {
     $time_begin = get-date
     $cpu_usage = (Get-WmiObject -ComputerName $computer -Class win32_processor | Measure-Object -Property LoadPercentage -Average | Select-Object Average).Average.ToString()
     $mem_usage = Get-WmiObject win32_operatingsystem -ComputerName $computer | Foreach {"{0:N2}" -f ((($_.TotalVisibleMemorySize - $_.FreePhysicalMemory)*100)/ $_.TotalVisibleMemorySize)}
     $disk_usage_c = Get-WmiObject Win32_Volume -ComputerName $computer -Filter "DriveLetter = 'C:'" | Foreach {"{0:N2}" -f (($_.FreeSpace / $_.Capacity)*100)}
     $disk_usage_d = Get-WmiObject Win32_Volume -ComputerName $computer -Filter "DriveLetter = 'D:'" | Foreach {"{0:N2}" -f (($_.FreeSpace / $_.Capacity)*100)}
     $i++
     $time_end = get-date
     ($time_end - $time_begin).totalmilliseconds.tostring() + " - " + $computer.name
 }
 $time_end_0 = get-date
 ($time_end_0 - $time_begin_0).totalmilliseconds.tostring() + " - total time elapsed" 

And here's the sample output in the lab.

114929-scom-pwershell-dashboard-03.png

Alex
If the response is helpful, please click "Accept Answer" and upvote it.



· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks @AlexZhu-MSFT for the extended help. Much appreciated.

0 Votes 0 ·

Hi Zid-3479,

You're welcome. I'm glad that some information helps and it's nice experience to work with you.

Alex
If the response is helpful, please click "Accept Answer" and upvote it.

0 Votes 0 ·

Hello, when I ran the below command and after completion the steps no information I can viewed in my Dashboard and it seems like loading. How to solve this issue? I have SCOM 2019

0 Votes 0 ·