Home

Awesome

Warden Process Watcher

Warden

OPEN SOURCE & CROSS-PLATFORM TOOL FOR SIMPLIFIED MONITORING

getwarden.net

BranchBuild status
mastermaster branch build status
developdevelop branch build status

ProcessWatcher can be used for process monitoring also including the remote machines.

Installation:

Available as a NuGet package.

dotnet add package Warden.Watchers.Process

Configuration:

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

Example of configuring the watcher via provided configuration class:

var configuration = ProcessWatcherConfiguration
    .Create("mongod", machineName: "MyRemoteMachine")
    .EnsureThat(process => process.Id == 1000)
    .Build();
var processWatcher = ProcessWatcher.Create("Process watcher", configuration);

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

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

var wardenConfiguration = WardenConfiguration
    .Create()
    .AddProcessWatcher("mongod", cfg =>
    {
        cfg.EnsureThat(process => process.Id == 1000)
    })
    //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:

ProcessWatcher provides a custom ProcessWatcherCheckResult type which contains additional values.

public class ProcessWatcherCheckResult : WatcherCheckResult
{
    public ProcessInfo ProcessInfo { get; }
}

Custom interfaces:

public interface IProcessService
{
    Task<ProcessInfo> GetProcessInfoAsync(string name);
}

public class ProcessInfo
{
    public int Id { get; }
    public string Name { get; }
    public string Machine { get; set; }
    public bool Exists { get; }
    public bool Responding{ get; }
}

IProcessService is responsible for checking process status. It can be configured via the WithProcessServiceProvider() method. By default it is based on the System.Diagnostics.Process.