DotNetMetrics.Tool 1.0.9

dotnet tool install --global DotNetMetrics.Tool --version 1.0.9
                    
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest
                    
if you are setting up this repo
dotnet tool install --local DotNetMetrics.Tool --version 1.0.9
                    
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=DotNetMetrics.Tool&version=1.0.9
                    
nuke :add-package DotNetMetrics.Tool --version 1.0.9
                    

DotNet Metrics Tool

NuGet Version NuGet Downloads Build License

Real-time monitoring tool for .NET Core process metrics. Monitor any .NET process by PID and get JSON output with CPU usage, memory consumption, and performance metrics.

Features

  • 🔍 Real-time monitoring - Updates every second
  • 📊 Comprehensive metrics - CPU usage, memory consumption, working set, private memory
  • 📝 JSON output - Structured data perfect for logging and analysis
  • 💾 File output - Save metrics to file for continuous monitoring
  • 🚀 Cross-platform - Works on Windows, Linux, and macOS
  • Lightweight - Minimal overhead on system resources
  • 🛠️ Easy installation - Install as a global .NET tool

Installation

Install as a global .NET tool:

dotnet tool install --global DotNetMetrics.Tool

Usage

Basic monitoring (console output)

dotnet-metrics <PID>

Save to file (silent mode)

dotnet-metrics <PID> --out metrics.json
dotnet-metrics <PID> -o /path/to/metrics.json

Find process PID

Windows (PowerShell):

Get-Process | Where-Object {$_.ProcessName -like '*your-app*'}

Linux/macOS:

ps aux | grep your-app

Alternative (Command Prompt)

tasklist | findstr "process_name"

Task Manager

  1. Open Task Manager (Ctrl+Shift+Esc)
  2. Go to "Details" tab
  3. Find your process and check the "PID" column

Example Output

{
  "timestamp": "2025-08-25T10:30:45.123Z",
  "processId": 1234,
  "processName": "MyApp",
  "cpuUsagePercent": 15.67,
  "memoryUsageMB": 256.78,
  "workingSetMB": 312.45,
  "privateMemoryMB": 189.23
}

Metrics Explained

  • timestamp - ISO 8601 timestamp of the measurement
  • processId - Process ID being monitored
  • processName - Name of the process
  • cpuUsagePercent - CPU usage as percentage (0-100)
  • memoryUsageMB - Paged memory usage in megabytes
  • workingSetMB - Physical memory usage in megabytes
  • privateMemoryMB - Private memory usage in megabytes

Use Cases

  • Performance monitoring - Track application resource usage
  • CI/CD pipelines - Monitor test execution performance
  • Production monitoring - Continuous performance tracking
  • Debugging - Identify memory leaks and CPU spikes
  • Load testing - Monitor application behavior under load

Parameters

Parameter Short Description
<PID> - Process ID to monitor (required)
--out -o Output file path (optional)

Usage Examples

Option 1: Direct via .NET CLI

cd DotNetMetrics.Console
dotnet run <PID>

Option 2: Using helper scripts

Windows Command Prompt
monitor_process.bat <PID>
PowerShell
.\monitor_process.ps1 -ProcessId <PID>

Example Commands

dotnet run 1234
# or
monitor_process.bat 1234
# or
.\monitor_process.ps1 -ProcessId 1234

Where 1234 is the PID of the .NET Core process you want to monitor.

Stopping Monitoring

Press Ctrl+C to stop monitoring.

Self-contained Builds

Pre-built self-contained executables are available for all major platforms:

Platform Executable Size
Windows x64 builds/win-x64/DotNetMetrics.Console.exe ~12 MB
Windows x86 builds/win-x86/DotNetMetrics.Console.exe ~11 MB
Windows ARM64 builds/win-arm64/DotNetMetrics.Console.exe ~12 MB
Linux x64 builds/linux-x64/DotNetMetrics.Console ~13 MB
Linux ARM64 builds/linux-arm64/DotNetMetrics.Console ~13 MB
macOS x64 builds/osx-x64/DotNetMetrics.Console ~13 MB
macOS ARM64 builds/osx-arm64/DotNetMetrics.Console ~13 MB

Building Self-Contained Executables

Build for Current Platform (Windows)
.\build-windows.ps1
Build for All Platforms
.\build-all-platforms.ps1
List Built Executables
.\list-builds.ps1

See BUILD.md for detailed build instructions.

Requirements

  • .NET 8.0 or higher
  • Appropriate permissions to read process information

Building from Source

git clone https://github.com/jakubkozera/dotnet-metrics.git
cd dotnet-metrics
dotnet pack DotNetMetrics.Console --configuration Release
dotnet tool install --global --add-source ./nupkg DotNetMetrics.Tool

Troubleshooting

"Process with PID X not found"

  • Check if the process actually exists
  • Verify the PID is correct

"Cannot access process"

  • Run the application as administrator
  • Check if the process is still running

High CPU usage in first measurement

  • The first CPU measurement may be imprecise
  • The application performs baseline measurement before starting actual monitoring

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Author

Jakub Kozera


⭐ If this tool helps you, please consider giving it a star!

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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.

This package has no dependencies.

Version Downloads Last Updated
1.0.9 2,760 8/25/2025