You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Radarr/src/NzbDrone.Core/HealthCheck/Checks/DownloadClientCheck.cs

47 lines
1.4 KiB

using System;
using System.Linq;
using NLog;
using NzbDrone.Core.Download;
namespace NzbDrone.Core.HealthCheck.Checks
{
public class DownloadClientCheck : HealthCheckBase
{
private readonly IProvideDownloadClient _downloadClientProvider;
private readonly Logger _logger;
public DownloadClientCheck(IProvideDownloadClient downloadClientProvider, Logger logger)
{
_downloadClientProvider = downloadClientProvider;
_logger = logger;
}
public override HealthCheck Check()
{
var downloadClients = _downloadClientProvider.GetDownloadClients().ToList();
if (!downloadClients.Any())
{
return new HealthCheck(GetType(), HealthCheckResult.Warning, "No download client is available");
}
foreach (var downloadClient in downloadClients)
{
try
{
downloadClient.GetItems();
}
catch (Exception ex)
{
var message = String.Format("Unable to communicate with {0}.", downloadClient.Definition.Name);
_logger.ErrorException(message, ex);
return new HealthCheck(GetType(), HealthCheckResult.Error, message + " " + ex.Message);
}
}
return new HealthCheck(GetType());
}
}
}