You must Sign In to post a response.
  • Category: .NET

    Query to fetch PC utilization

    Trying to integrate .net application with SCOM . Need queries through which I can display information like CPU Utilization , Memory Usage , Number of Processes running on the client machine . SCOM has its own database but unable to create a query that can fetch the said information.
  • #765073
    PerformanceCounter class will help you to get CPU utilization, you might check below snippet
    private static void RunTest(string appName)
    bool done = false;
    PerformanceCounter total_cpu = new PerformanceCounter("Process", "% Processor Time", "_Total");
    PerformanceCounter process_cpu = new PerformanceCounter("Process", "% Processor Time", appName);
    while (!done)
    float t = total_cpu.NextValue();
    float p = process_cpu.NextValue();
    Console.WriteLine(String.Format("_Total = {0} App = {1} {2}%\n", t, p, p / t * 100));
    you need to pass program name to get its CPU utilization

    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]

  • #765111
    For CPU usage information, you can use System.Diagnostics.PerformanceCounter namespace.
    Please go through this URL:
    Whole project:
    Shashikant Gurav

  • Sign In to post your comments