Skip to content
adatum
  • Home
  •  About adatum
  •  Learn Azure Bicep
  •  SCOM Web API
System Center Opertations manager logo Operations Manager

SCOMpercentageCPUTimeCounter cause CPU Spike

  • 13/03/201707/01/2025
  • by Martin Ehrnst

To be honest this have existed for years, and written about back in 2014. Now, in 2017, SCOM 2016 UR2 is released the problem remains. Perhaps with greater consequence due to virtualization.

If you’re unfamiliar with the problem SCOMpercentageCPUTimeCounter.vbs (.ps1 in SCOM 2016) is a script included in the “System Center Core Monitoring” management pack, and is used as the data source for a rule and a monitor to determinate agent health by gathering ‘HealthService’ CPU usage. The rule and monitor are set to run at a fixed interval of 321 seconds (I assume the person who wrote the MP just tapped 3-2-1 on their numpad 🙂 ) and sync time set to 00:00

 

[supsystic-tables id=1]

If you want to look at the actual code you will find  the data source on SystemCenterCore.com

 

Running this script every 5 minutes isn’t exactly a problem when you have physical servers or a small amount of virtual machines on your Hypervisor. But if you run 100 or 300VM’s on one host and each single VM start this script simultainiasly it will create it creates unnecessary load on your host. If this host is overcommitted as well CPU wait time could cause a ‘freeze’ on your tenant machines as well.

To illustrate the problem, I have attached a graph, that clearly show spikes during script execution.

vcenter host cpu spike SCOM

 

On a monitored computer you will see a cscript.exe process executing the following command line “c:\windows\system32\cscript.exe” /nologo “SCOMPerventageCPUTimeCounter.vbs

Cscript.exe running SCOM Cpu percentange script

 

Unfortunately out of the box there isn’t much to do. Sync time and interval is the only overridable parameters, and these will only help reduce the load on the agent machine itself. So if you experience CPU utilization peaks due to this script, I see only two options

  • Disable the rule and monitor
    • Then you will have to rely on the CPU utilization monitor from the operating system management pack
  • Create a new rule and monitor, using SpreadInitializationOverInterval parameter
    • Reduces load as executions occurs randomly within the set interval
    • Requires authoring skills, but possible. Some information here.

 

To not let this go into oblivion, I have left feedback on Operations Manager user voice. Hopefully, Microsoft will make some changes in the future. If you have suggestions or other experience please let me know and i will update accordingly.

Share this:

  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to share on X (Opens in new window) X
  • Click to share on Reddit (Opens in new window) Reddit
vSphere logo Automation

First look at the vSphere 6.5 REST API

  • 04/03/201707/01/2025
  • by Martin Ehrnst

 

 

The other day I stumbled across  a blog series by William Lee who delves deep in to how you use the latest vmware vSphere REST API using PowerCLI. Using the language I know best, Powershell I thought I should give this API I try. I have some experience with API use from before as I often use this to do information exchange between systems, but this is my first experince with vCenter.

This post will cover the very basics on how we authenticate and get a list of all VM’s connected to our vCenter server.

You can explore and test all endpoints by this URL https://vcenter/rest/apiexplorer

To get started I declare two variables for the urls / endpoints we going to use. One for vm’s and one for the session endpoint

$VCBaseUri = "https://host/rest/vcenter/vm"
$SessionUri = "https://host/rest/com/vmware/cis/session"

Based on the credential input from the user we will create a base64 encoded string and create a header for the session endpoint.

#Getting cred and creating auth key
$Cred = Get-Credential
$auth = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($Cred.UserName+':'+$Cred.GetNetworkCredential().Password))
$head = @{
  'Authorization' = "Basic $auth"
}

The $head variable now contains a table with your encoded username and password. We will use this authorization header to create a new session. At first i assumed we could authenticate using basic authentication only but after a little investigation I figured we needed to create a session. vmware has documented the endpoint here

Using our authorization header we connect to the session endpoint and recieves a token that we use in our session header. From now on. All authentication is with this session token.

the key for our token is ‘vmware-api-session-id’

#Creating a Session

$token = (Invoke-RestMethod -Method Post -Headers $head -Uri $SessionUri).Value
$session = @{'vmware-api-session-id' = $token}

Finally you can call the VM endpoint and retrieve all your vms by running the following.

#Calling VM endpoint authenticated with the session

$vms = (Invoke-RestMethod -Uri $VCBaseUri -Headers $session -ContentType 'Application/json').Value

To get a single vm by name, you can filter by appending the uri.

/vm?filter.names=web-w2k12"

Hopefully you will have this output showing all vm’s as objects

vcenter api powershell vm output

 

My complete script now looks like this.

$VCBaseUri = "https://host/rest/vcenter/vm?filter.names=argaste-web-w2k12"
$SessionUri = "https://host/rest/com/vmware/cis/session"

#Getting cred and creating auth key
$Cred = Get-Credential
$auth = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($Cred.UserName+':'+$Cred.GetNetworkCredential().Password))
$head = @{
  'Authorization' = "Basic $auth"
}

#Creating a Session

$token = (Invoke-RestMethod -Method Post -Headers $head -Uri $SessionUri).Value
$session = @{'vmware-api-session-id' = $token}

#Calling VM endpoint authenticated with the session

$vms = (Invoke-RestMethod -Uri $VCBaseUri -Headers $session -ContentType 'Application/json').Value

 

Share this:

  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to share on X (Opens in new window) X
  • Click to share on Reddit (Opens in new window) Reddit
Azure CDN Logo Azure

Azure CDN on WordPress

  • 02/03/201707/01/2025
  • by Martin Ehrnst

Content Delivery Network (CDN) let you distribute static content from your website or other web application from locations closest to the end-user. For a standard web site this include things like images, CSS files, Java script and so on.

 

Looking at the image below, you can see that visitors on this site is scattered around. enabling CDN will therefore improve performance by delivering the content from different locations rather than the site host which is in Europe.
Following this post you should be able to have CDN up and running in about 15 minutes 🙂

 

visitors location

 

 

 

 

PreReq’s

  • W3 Total Cache WordPress Plugin
  • Azure Subscription

 

Enable Azure CDN

The first thing you need to do is to create a new Azure CDN profile in the Azure portal. Search for CDN and create a new profile.

I chose to go with the standard Verizon version which at this point it cost $0.08 per GB up to 10TB usage. If you have other needs please check the features and pricing for Azure CDN here.

Next, create a new endpoint and configure the origin. If you run your site in Azure you can find it in the drop down. The endpoint will be the URL which all cached content is available. You can run multiple endpoints under one profile, i just ended up using a 1-1 resource group, profile and endpoint.

Azure CDN endpoint blade

According to Azure documentation, it can take up to 90 minutes before new endpoints are cached, so expect to see 404 errors after you have created it. Take a note of the endpoint hostname which is the address we are configuring in WordPress.

 

Configure WordPress CDN

Heading over to your wordpress admin page you will have to enable CDN under W3 Total Cache general settings. Tick enable and chose generic mirror as your CDN type. Azure CDN will mirror your data and using “pull” functionality.

Enable CDN using wordpress

 

 

After this is enabled click CDN under performance on your left menu. If you do not remember your endpoint name, go back and copy it from the Azure portal.

 

Scroll down to the configuration area and put in your endpoint name without HTTP(s). Check connectivity by clicking “test mirror”

 

This is all configuration needed to do basic CDN using Azure on your WordPress web site, but a lot of customization can be done both in Azure and in WP. After caching is enabled and time has done it things. You should be able to confirm that mirroring is working. Here is a screenshot of Chrome developer tools where you see the image URL is my CDN endpoint in Azure.

 

Share this:

  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to share on X (Opens in new window) X
  • Click to share on Reddit (Opens in new window) Reddit

Posts pagination

1 … 26 27 28 29 30 … 37

Popular blog posts

  • Azure Application registrations, Enterprise Apps, and managed identities
  • Access to Blob storage using Managed Identity in Logic Apps - by Nadeem Ahamed
  • Creating Azure AD Application using Powershell
  • Track changes to Azure resources
  • First look at the vSphere 6.5 REST API

Categories

Automation Azure Azure Active Directory Azure Bicep Azure DevOps Azure Functions Azure Lighthouse Azure Logic Apps Azure Monitor Azure Policy Community Conferences CSP Monitoring DevOps GitHub Guest blogs Infrastructure As Code Kubernetes Microsoft CSP MPAuthoring OMS Operations Manager Podcast Powershell Uncategorised Windows Admin Center Windows Server

Follow Martin Ehrnst

  • X
  • LinkedIn

RSS feed RSS - Posts

RSS feed RSS - Comments

Microsoft Azure MVP

Martin Ehrnst Microsoft Azure MVP
Adatum.no use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it. Cookie Policy
Theme by Colorlib Powered by WordPress