McpNetwork.SystemMetrics 7.0.0

dotnet add package McpNetwork.SystemMetrics --version 7.0.0                
NuGet\Install-Package McpNetwork.SystemMetrics -Version 7.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="McpNetwork.SystemMetrics" Version="7.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add McpNetwork.SystemMetrics --version 7.0.0                
#r "nuget: McpNetwork.SystemMetrics, 7.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install McpNetwork.SystemMetrics as a Cake Addin
#addin nuget:?package=McpNetwork.SystemMetrics&version=7.0.0

// Install McpNetwork.SystemMetrics as a Cake Tool
#tool nuget:?package=McpNetwork.SystemMetrics&version=7.0.0                

McpNetwork.SystemMetrics

This NuGet collects metrics on Windows or Unix (Linux, MacOs) systems. It collects :

  • Total CPU usage
  • Process CPU and memory usage
  • System total, used and free memory

Example :

class Program
{

    static readonly ManualResetEvent manualResetEvent = new ManualResetEvent(false);

    static void Main(string[] args)
    {

        Task.Factory.StartNew(() => { GetMetrics(); });

        UseProcessor();
    }

    static void GetMetrics()
    {
        const int nbMaxReads = 3;
        using (var systemMetrics = new SystemMetrics())
        {
            Console.WriteLine(String.Format("Process name: {0}", systemMetrics.ProcessName));
            Console.WriteLine(String.Format("Process id: {0}", systemMetrics.ProcessId));
            Console.WriteLine(String.Format("Binary name: {0}", systemMetrics.BinaryName));
            Console.WriteLine(String.Format("Nb processor(s): {0}", systemMetrics.ProcessorCount));
            Console.WriteLine(String.Format("system is Unix: {0}", systemMetrics.IsUnix));
            for (var index = 1; index <= nbMaxReads; index++)
            {
                Console.WriteLine();
                Console.WriteLine(String.Format(" > Reading #{0} of {1}", index, nbMaxReads));
                var result = systemMetrics.GetMetrics();
                Console.WriteLine(String.Format("   > GetMetrics execution time (ms): {0}", result.GetMetricsExecutionTime));
                Console.WriteLine(String.Format("   - System Memory (Mb): {0}", result.SystemMemory));
                Console.WriteLine(String.Format("   - Total Memory Free (Mb): {0}", result.TotalMemoryFree));
                Console.WriteLine(String.Format("   - Total Memory Used (Mb): {0}", result.TotalMemoryUsed));

                Console.WriteLine(String.Format("   - Total CPU usage (%): {0}", result.TotalCpuUsage));

                Console.WriteLine(String.Format("   - Process CPU usage (%): {0}", result.ProcessCpuUsage));
                Console.WriteLine(String.Format("   - Process Memory usage (Mb): {0}", result.ProcessMemoryUsage));
                Thread.Sleep(1000);
            }
        }

        manualResetEvent.Set();
    }

    static void UseProcessor()
    {
        var exit = false;
        while (!exit)
        {
            exit = manualResetEvent.WaitOne(0);
            for (var index = 1; index < 100; index++)
            {
                Fibonacci(index);
            }
        }
    }

    static int Fibonacci(int n)
    {
        int w;
        if (n <= 0) return 0;
        if (n == 1) return 1;
        int u = 0;
        int v = 1;
        for (int i = 2; i <= n; i++)
        {
            w = u + v;
            u = v;
            v = w;
        };
        return v;
    }

}
Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net7.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on McpNetwork.SystemMetrics:

Package Downloads
McpNetwork.MicroServiceCore

Micro service core implementation including razor pages, usage statistics, API gateway

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
7.0.0 460 11/14/2022
6.0.0 1,119 11/19/2021
5.0.1 414 3/15/2021