Home

Awesome

Warden Server Watcher

Warden

OPEN SOURCE & CROSS-PLATFORM TOOL FOR SIMPLIFIED MONITORING

getwarden.net

BranchBuild status
mastermaster branch build status
developdevelop branch build status

ServerWatcher can be used for monitoring server availability including opened ports (if specified).

Installation:

Available as a NuGet package.

dotnet add package Warden.Watchers.Server

Configuration:

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

Example of configuring the watcher via provided configuration class:

var configuration = ServerWatcherConfiguration
    .Create("www.google.com", 80)
    .Build();
var serverWatcher = ServerWatcher.Create("Port watcher", configuration);

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

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

var wardenConfiguration = WardenConfiguration
    .Create()
    .AddServerWatcher("www.google.com", 80)
    //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:

ServerWatcher provides a custom ServerWatcherCheckResult type which contains additional values.

public class ServerWatcherCheckResult: WatcherCheckResult
{
    public string Hostname { get; }
    public int Port { get; }
}

Custom interfaces:

public interface IDnsResolver
{
    IPAddress GetIpAddress(string hostnameOrIp);
}

public interface IPinger
{
    Task<IPStatus> PingAsync(IPAddress addressIp, TimeSpan? timeout = null);
}

public interface ITcpClient
{
    bool IsConnected { get; }
    Task ConnectAsync(IPAddress ipAddress, int port, TimeSpan? timeout = null);
}

public class ConnectionInfo
{
    public string Hostname { get; }
    public IPAddress IpAddress { get; }
    public int Port { get; }
    public bool PortOpened { get; }
    public IPStatus PingStatus { get; }
    public string PingStatusMessage { get; }
}

IDnsResolver is responsible for resolving the DNS. It can be configured via the WithDnsResolverProvider() method. IPinger is responsible for pinging the specified hostname. It can be configured via the WithPingerProvided() method. ITcpClient is responsible for handling the TCP connection for a given port number. It can be configured via the WithTcpClientProvider() method. By default these services are based on the System.Net.Sockets.