This week I received a question about process monitoring. The question was about monitoring CPU and Memory usage of processes on RDS or Citrix XenApp Session Host servers. Process monitoring is one of the standard capabilities so I started with configuring process monitoring through the template which you can find in the Authoring section. But the results were not what I wanted to see. Check this blog to see why!
The results of the standard process monitoring capabilities were not the results we wanted to see :). On Session Host RDS servers or Citrix XenApp servers there could be more instances of the same process. As test we used Google Chrome as a test application. This application has even multiple processes even for one user. With the standard process monitoring capabilities op SCOM this results in the following:
The problem is that the performance collection rule collect data about each instance of the process separately. In our case we would like to see only a sum of all instances of a single process. Based on investigating the issue I decided to create a custom Data source with a PowerShell Probe action to get summary values of the CPU en Memory Usage of all instances of a process. I did the following steps to create this custom Management Pack
1. Defining Classes
I started with creating a custom class for the processes. I selected ‘Microsoft Windows LocalApplication’ as a source. Maybe in the future I would add a monitor to this MP and in that case the health will Roll-up to the computer object.
2. Creating Discoveries
The first problem was the way how I need to discover the processes. There are several options. The first is to use the ‘get-process’ cmdlet and create an instance for each active process. But on Session Hosted servers it could be the case that processes are only running during the day and not the night. When the discovery the runs in the night the process is not discovered and during the day no performance is collected.
To avoid this I used an external source for the discovery. This could be a text file where you list the processes which need to be monitored. Based on this I created a PowerShell script which reads the content of the source file and create instances of the above class.
3. Creating the Rules
When the instances are discovered we can target rules and monitors against them. I created a custom data source and a PowerShell Probe to retrieve the counters. I created a single script which returned both counters in separate property bags. This script is triggered by a data source based on a schedule. My first solution didn’t worked because of a bug in the ‘Microsoft.SystemCenter.DataWarehouse.PublishPerformanceData’ write action. Values of both counters were written to the Operational Database but only values of a single counter where written to the data warehouse. This is a bug in the above write action. The write action only supports a counter per performance rule. To work around this bug I needed to create 2 rules, one for CPU and one for memory. By using cookdown both rules using the single data source for the results.
The result of above management pack is the collection of CPU and Memory Usage of processes where all instances are summarized in a single value. See below an example dashboard:
If you are interested in a full copy of this Management Packs please let me know through the comments. I’m happy to send you a copy of this MP!