diff --git a/src/Ombi.HealthChecks/Checks/OmbiPingHealthCheck.cs b/src/Ombi.HealthChecks/Checks/OmbiPingHealthCheck.cs deleted file mode 100644 index 726d02078..000000000 --- a/src/Ombi.HealthChecks/Checks/OmbiPingHealthCheck.cs +++ /dev/null @@ -1,47 +0,0 @@ -using HealthChecks.Network; -using Microsoft.Extensions.Diagnostics.HealthChecks; -using System; -using System.Collections.Generic; -using System.Net.NetworkInformation; -using System.Text; -using System.Threading; -using System.Threading.Tasks; - -namespace Ombi.HealthChecks.Checks -{ - public class OmbiPingHealthCheck - : IHealthCheck - { - private readonly OmbiPingHealthCheckOptions _options; - public OmbiPingHealthCheck(OmbiPingHealthCheckOptions options) - { - _options = options ?? throw new ArgumentNullException(nameof(options)); - } - public async Task CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default) - { - var configuredHosts = _options.ConfiguredHosts.Values; - - try - { - foreach (var (host, timeout, status) in configuredHosts) - { - using (var ping = new Ping()) - { - var pingReply = await ping.SendPingAsync(host, timeout); - - if (pingReply.Status != IPStatus.Success) - { - return new HealthCheckResult(status, description: $"Ping check for host {host} is failed with status reply:{pingReply.Status}"); - } - } - } - - return HealthCheckResult.Healthy(); - } - catch (Exception ex) - { - return new HealthCheckResult(context.Registration.FailureStatus, exception: ex); - } - } - } -} diff --git a/src/Ombi.HealthChecks/Checks/OmbiPingHealthCheckOptions.cs b/src/Ombi.HealthChecks/Checks/OmbiPingHealthCheckOptions.cs deleted file mode 100644 index f89c71a52..000000000 --- a/src/Ombi.HealthChecks/Checks/OmbiPingHealthCheckOptions.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Microsoft.Extensions.Diagnostics.HealthChecks; -using System.Collections.Generic; - -namespace Ombi.HealthChecks.Checks -{ - public class OmbiPingHealthCheckOptions - { - internal Dictionary ConfiguredHosts { get; } = new Dictionary(); - - public OmbiPingHealthCheckOptions AddHost(string host, int timeout, HealthStatus status) - { - ConfiguredHosts.Add(host, (host, timeout, status)); - return this; - } - } -} diff --git a/src/Ombi.HealthChecks/Checks/PlexHealthCheck.cs b/src/Ombi.HealthChecks/Checks/PlexHealthCheck.cs index 182c1b2f8..bc90c4756 100644 --- a/src/Ombi.HealthChecks/Checks/PlexHealthCheck.cs +++ b/src/Ombi.HealthChecks/Checks/PlexHealthCheck.cs @@ -27,7 +27,7 @@ namespace Ombi.HealthChecks.Checks var settings = await settingsProvider.GetSettingsAsync(); if (settings == null) { - return HealthCheckResult.Healthy("Plex is not confiured."); + return HealthCheckResult.Healthy("Plex is not configured."); } var taskResult = new List>(); diff --git a/src/Ombi.HealthChecks/HealthCheckExtensions.cs b/src/Ombi.HealthChecks/HealthCheckExtensions.cs index 2f80378ff..21b9d5dde 100644 --- a/src/Ombi.HealthChecks/HealthCheckExtensions.cs +++ b/src/Ombi.HealthChecks/HealthCheckExtensions.cs @@ -18,39 +18,8 @@ namespace Ombi.HealthChecks builder.AddCheck("Radarr", tags: new string[] { "DVR" }); builder.AddCheck("CouchPotato", tags: new string[] { "DVR" }); builder.AddCheck("SickRage", tags: new string[] { "DVR" }); - builder.AddOmbiPingHealthCheck(options => - { - options.AddHost("www.google.co.uk", 5000, HealthStatus.Unhealthy); - options.AddHost("www.google.com", 3000, HealthStatus.Degraded); - }, "External Ping", tags: new string[] { "System" }); return builder; } - - /// - /// Add a health check for network ping. - /// - /// The . - /// The action to configure the ping parameters. - /// The health check name. Optional. If null the type name 'ping' will be used for the name. - /// - /// The that should be reported when the health check fails. Optional. If null then - /// the default status of will be reported. - /// - /// A list of tags that can be used to filter sets of health checks. Optional. - /// An optional System.TimeSpan representing the timeout of the check. - /// The . - public static IHealthChecksBuilder AddOmbiPingHealthCheck(this IHealthChecksBuilder builder, Action setup, string name = default, HealthStatus? failureStatus = default, IEnumerable tags = default, TimeSpan? timeout = default) - { - var options = new OmbiPingHealthCheckOptions(); - setup?.Invoke(options); - - return builder.Add(new HealthCheckRegistration( - name, - sp => new OmbiPingHealthCheck(options), - failureStatus, - tags, - timeout)); - } } }