CodeLogic.SystemStats 4.5.2-preview.68

This is a prerelease version of CodeLogic.SystemStats.
There is a newer version of this package available.
See the version list below for details.
dotnet add package CodeLogic.SystemStats --version 4.5.2-preview.68
                    
NuGet\Install-Package CodeLogic.SystemStats -Version 4.5.2-preview.68
                    
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="CodeLogic.SystemStats" Version="4.5.2-preview.68" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CodeLogic.SystemStats" Version="4.5.2-preview.68" />
                    
Directory.Packages.props
<PackageReference Include="CodeLogic.SystemStats" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CodeLogic.SystemStats --version 4.5.2-preview.68
                    
#r "nuget: CodeLogic.SystemStats, 4.5.2-preview.68"
                    
#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.
#:package CodeLogic.SystemStats@4.5.2-preview.68
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=CodeLogic.SystemStats&version=4.5.2-preview.68&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=CodeLogic.SystemStats&version=4.5.2-preview.68&prerelease
                    
Install as a Cake Tool

CodeLogic.SystemStats

NuGet

Cross-platform system statistics (CPU, memory, processes) for CodeLogic applications on Windows and Linux.

Install

dotnet add package CodeLogic.SystemStats

Quick Start

All data-returning methods return a Result<T>: check IsSuccess, then read Value (or Error on failure).

var statsLib = new SystemStatsLibrary();
// After library initialization via CodeLogic framework:

var cpu = await statsLib.GetCpuStatsAsync();
if (cpu.IsSuccess)
    Console.WriteLine($"CPU: {cpu.Value!.OverallUsagePercent:F1}%");

var cpuInfo  = await statsLib.GetCpuInfoAsync();        // static: model, cores, vendor
var memInfo  = await statsLib.GetMemoryInfoAsync();     // static: total RAM
var memory   = await statsLib.GetMemoryStatsAsync();    // live usage
var uptime   = await statsLib.GetSystemUptimeAsync();
var snapshot = await statsLib.GetSystemSnapshotAsync(); // combined + fires event
var all      = await statsLib.GetAllProcessesAsync();
var topCpu   = await statsLib.GetTopProcessesByCpuAsync(5);
var topMem   = await statsLib.GetTopProcessesByMemoryAsync(5);
var one      = await statsLib.GetProcessStatsAsync(processId: 1234);

Features

  • CPU monitoring — static CpuInfo (model, cores, vendor, architecture) and live CpuStats (overall + per-core) with configurable sampling
  • Memory stats — static MemoryInfo and live MemoryStats (total/used/available/cached/buffers), with MiB/GiB helper properties
  • Uptime — system uptime since last boot
  • Process monitoring — enumerate all processes, query by PID, or rank by CPU/memory usage
  • System snapshots — combined CPU + memory + uptime + top processes in a single call
  • Threshold events — publishes HighCpuUsageEvent / HighMemoryUsageEvent when thresholds are exceeded, and SystemSnapshotTakenEvent after each snapshot
  • Result caching — cached reads (configurable duration); clear via statsLib.Stats.ClearCache()
  • Cross-platform providers — Windows (PerformanceCounters + P/Invoke GlobalMemoryStatusEx) and Linux (/proc)

Configuration

Config file: config.systemstats.json

{
  "EnableCaching": true,
  "CacheDurationSeconds": 5,
  "CpuSamplingIntervalMs": 100,
  "CpuSamplesForAverage": 3,
  "EnableTemperatureMonitoring": true,
  "EnableProcessMonitoring": true,
  "MaxTopProcesses": 10,
  "HighCpuThresholdPercent": 90.0,
  "HighMemoryThresholdPercent": 90.0
}

Events

Published on the CodeLogic event bus (when one is available):

  • SystemSnapshotTakenEvent — after each successful GetSystemSnapshotAsync().
  • HighCpuUsageEvent — when overall CPU usage ≥ HighCpuThresholdPercent.
  • HighMemoryUsageEvent — when memory usage ≥ HighMemoryThresholdPercent.

Threshold checks run on GetCpuStatsAsync, GetMemoryStatsAsync, and GetSystemSnapshotAsync.

Documentation

Full API docs: https://github.com/Media2A/CodeLogic.Libs

Requirements

  • .NET 10.0+
  • CodeLogic 3.x or 4.x
  • Windows: System.Diagnostics.PerformanceCounter, System.Management
  • Linux: /proc filesystem access

License

MIT — see LICENSE

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

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.6.72 51 6/20/2026
4.6.69-preview 41 6/20/2026
4.5.2 108 5/24/2026
4.5.2-preview.68 61 6/20/2026
4.5.1 104 5/24/2026
4.5.1-preview.56 60 5/24/2026
4.4.2-preview.53 59 5/24/2026
4.4.1 104 5/24/2026
4.0.5 98 5/15/2026
4.0.4 111 5/9/2026
4.0.3 115 5/9/2026
3.3.1 108 4/18/2026
3.3.0 114 4/18/2026
3.2.11 122 4/18/2026
3.2.10 108 4/18/2026
3.2.9 105 4/18/2026
3.2.8 108 4/18/2026
3.2.7 106 4/18/2026
3.2.6 108 4/18/2026
3.2.5 108 4/18/2026
Loading failed

# CL.SystemStats — Changelog

All notable changes to **CodeLogic.SystemStats** are documented here. Versions follow
[Semantic Versioning](https://semver.org/).

## [4.5.1] — 2026-06-20

### Documentation

- Rewrote the system-monitoring guide and refreshed the README to match the
 current API: `Result<T>`-returning methods, static info accessors
 (`GetCpuInfoAsync` / `GetMemoryInfoAsync`), `GetSystemUptimeAsync`,
 `GetAllProcessesAsync`, and the `CpuInfo` / `CpuStats` / `MemoryInfo` /
 `MemoryStats` / `ProcessStats` / `SystemSnapshot` record shapes (including
 MiB/GiB helper properties).
- Documented the published events (`SystemSnapshotTakenEvent`,
 `HighCpuUsageEvent`, `HighMemoryUsageEvent`) and which calls trigger threshold
 checks.
- Documented result caching behavior, the cached vs. uncached calls, and
 `ClearCache()` via the `Stats` property.
- Corrected the configuration reference to the real `config.systemstats.json`
 fields and value ranges.

## [4.5.0] — 2026-05-24

### Changed

- **Unified versioning.** All CodeLogic.Libs now share a single version line
 controlled by `version.txt` in the repo root. This is a version alignment
 release — no functional changes to this library.
## [4.0.4] — 2026-04-16

### Changed

- README + manifest refresh for the v4 baseline. No functional changes vs 4.0.3.
- `LibraryManifest.Version` now reads from assembly metadata.

## [4.0.2] — 2026-04-09

### Changed

- Annotated SystemStats configuration with `[ConfigField]` for the admin UI surface.
- Aligned with the v4 baseline across all libraries.

### Fixed

- Removed the Windows-only condition on transitive dependencies so the
 library actually loads on Linux containers.

## [4.0.0] — 2026-04-09

Major rewrite. Republished as v4.0.0 to reset the version line under the
unified v4 baseline. Cross-platform CPU / memory / disk / network sampling
backed by Windows performance counters and Linux `/proc`.

### Notes

- Earlier history is retained in the
 [git log](https://github.com/Media2A/CodeLogic.Libs/commits/main/CL.SystemStats).