Home

Awesome

Warden Performance Watcher

Warden

OPEN SOURCE & CROSS-PLATFORM TOOL FOR SIMPLIFIED MONITORING

getwarden.net

BranchBuild status
mastermaster branch build status
developdevelop branch build status

PerformanceWatcher can be used for CPU and RAM monitoring. Accepts optional parameter machineName to work with the remote host.

Installation:

Available as a NuGet package.

dotnet add package Warden.Watchers.Performance -v 2.0.0-beta-1

Configuration:

PerformanceWatcher can be configured by using the PerformanceWatcherConfiguration class or via the lambda expression passed to a specialized constructor.

Example of configuring the watcher via provided configuration class:

var configuration = PerformanceWatcherConfiguration
    .Create(delay: TimeSpan.FromMilliseconds(200))
    .EnsureThat(usage => usage.Cpu < 30 && usage.Ram < 3000)
    .Build();
var performanceWatcher = PerformanceWatcher.Create("Performance watcher", configuration);

var wardenConfiguration = WardenConfiguration
    .Create()
    .AddWatcher(performanceWatcher)
    //Configure other watchers, hooks etc.

Example of adding the watcher directly to the Warden via one of the extension methods:

var wardenConfiguration = WardenConfiguration
    .Create()
    .AddPerformanceWatcher(cfg =>
    {
        cfg.EnsureThat(usage => usage.Cpu < 30 && usage.Ram < 3000);
    }, delay: TimeSpan.FromMilliseconds(200))
    //Configure other watchers, hooks etc.

Please note that you may either use the lambda expression for configuring the watcher or pass the configuration instance directly. You may also configure the hooks by using another lambda expression available in the extension methods.

Check result type:

PerformanceWatcher provides a custom PerformanceWatcherCheckResult type which contains additional values.

public class PerformanceWatcherCheckResult : WatcherCheckResult
{
    public TimeSpan Delay { get; }
    public ResourceUsage ResourceUsage { get; }
}

Custom interfaces:

public interface IPerformance
{
    Task<ResourceUsage> GetResourceUsageAsync();
}

public class ResourceUsage
{
    public double Cpu { get; }
    public double Ram { get; }
}

IPerformance is responsible for calculating the resource usage. It can be configured via the WithPerformanceProvider() method. By default it is based on the Performance Counter.