Minor improvements in health checks

(cherry picked from commit a22f598b0c129110f2a3b663e9b40c84f3a1f02b)

Closes #8615
pull/8717/head
Bogdan 1 year ago
parent 0cbfb4ca65
commit 783878be1e

@ -48,15 +48,13 @@ namespace NzbDrone.Core.HealthCheck.Checks
try try
{ {
var status = client.GetStatus(); var status = client.GetStatus();
var folders = status.OutputRootFolders; var folders = status.OutputRootFolders.Where(folder => rootFolders.Any(r => r.Path.PathEquals(folder.FullPath)));
foreach (var folder in folders) foreach (var folder in folders)
{
if (rootFolders.Any(r => r.Path.PathEquals(folder.FullPath)))
{ {
return new HealthCheck(GetType(), HealthCheckResult.Warning, string.Format(_localizationService.GetLocalizedString("DownloadClientCheckDownloadingToRoot"), client.Definition.Name, folder.FullPath), "#downloads-in-root-folder"); return new HealthCheck(GetType(), HealthCheckResult.Warning, string.Format(_localizationService.GetLocalizedString("DownloadClientCheckDownloadingToRoot"), client.Definition.Name, folder.FullPath), "#downloads-in-root-folder");
} }
} }
}
catch (DownloadClientException ex) catch (DownloadClientException ex)
{ {
_logger.Debug(ex, "Unable to communicate with {0}", client.Definition.Name); _logger.Debug(ex, "Unable to communicate with {0}", client.Definition.Name);

@ -23,12 +23,14 @@ namespace NzbDrone.Core.HealthCheck.Checks
public override HealthCheck Check() public override HealthCheck Check()
{ {
var jackettAllProviders = _providerFactory.All().Where( var jackettAllProviders = _providerFactory.All()
.Where(
i => i.ConfigContract.Equals("TorznabSettings") && i => i.ConfigContract.Equals("TorznabSettings") &&
((i.Settings as TorznabSettings).BaseUrl.Contains("/torznab/all/api", StringComparison.InvariantCultureIgnoreCase) || (((TorznabSettings)i.Settings).BaseUrl.Contains("/torznab/all/api", StringComparison.InvariantCultureIgnoreCase) ||
(i.Settings as TorznabSettings).BaseUrl.Contains("/api/v2.0/indexers/all/results/torznab", StringComparison.InvariantCultureIgnoreCase) || ((TorznabSettings)i.Settings).BaseUrl.Contains("/api/v2.0/indexers/all/results/torznab", StringComparison.InvariantCultureIgnoreCase) ||
(i.Settings as TorznabSettings).ApiPath.Contains("/torznab/all/api", StringComparison.InvariantCultureIgnoreCase) || ((TorznabSettings)i.Settings).ApiPath.Contains("/torznab/all/api", StringComparison.InvariantCultureIgnoreCase) ||
(i.Settings as TorznabSettings).ApiPath.Contains("/api/v2.0/indexers/all/results/torznab", StringComparison.InvariantCultureIgnoreCase))); ((TorznabSettings)i.Settings).ApiPath.Contains("/api/v2.0/indexers/all/results/torznab", StringComparison.InvariantCultureIgnoreCase)))
.ToArray();
if (jackettAllProviders.Empty()) if (jackettAllProviders.Empty())
{ {

@ -32,8 +32,7 @@ namespace NzbDrone.Core.HealthCheck.Checks
s => s.ProviderId, s => s.ProviderId,
(i, s) => new { Provider = i, Status = s }) (i, s) => new { Provider = i, Status = s })
.Where(p => p.Status.InitialFailure.HasValue && .Where(p => p.Status.InitialFailure.HasValue &&
p.Status.InitialFailure.Value.Before( p.Status.InitialFailure.Value.Before(DateTime.UtcNow.AddHours(-6)))
DateTime.UtcNow.AddHours(-6)))
.ToList(); .ToList();
if (backOffProviders.Empty()) if (backOffProviders.Empty())

@ -30,8 +30,7 @@ namespace NzbDrone.Core.HealthCheck.Checks
s => s.ProviderId, s => s.ProviderId,
(i, s) => new { Provider = i, Status = s }) (i, s) => new { Provider = i, Status = s })
.Where(p => p.Status.InitialFailure.HasValue && .Where(p => p.Status.InitialFailure.HasValue &&
p.Status.InitialFailure.Value.After( p.Status.InitialFailure.Value.After(DateTime.UtcNow.AddHours(-6)))
DateTime.UtcNow.AddHours(-6)))
.ToList(); .ToList();
if (backOffProviders.Empty()) if (backOffProviders.Empty())

@ -22,7 +22,7 @@ namespace NzbDrone.Core.HealthCheck.Checks
// Not best for optimization but due to possible symlinks and junctions, we get mounts based on series path so internals can handle mount resolution. // Not best for optimization but due to possible symlinks and junctions, we get mounts based on series path so internals can handle mount resolution.
var mounts = _movieService.AllMoviePaths() var mounts = _movieService.AllMoviePaths()
.Select(p => _diskProvider.GetMount(p.Value)) .Select(p => _diskProvider.GetMount(p.Value))
.Where(m => m != null && m.MountOptions != null && m.MountOptions.IsReadOnly) .Where(m => m is { MountOptions.IsReadOnly: true })
.DistinctBy(m => m.RootDirectory) .DistinctBy(m => m.RootDirectory)
.ToList(); .ToList();

@ -18,10 +18,12 @@ namespace NzbDrone.Core.HealthCheck.Checks
public override HealthCheck Check() public override HealthCheck Check()
{ {
var ptpIndexers = _indexerFactory.All().Where(i => i.Settings.GetType() == typeof(PassThePopcornSettings)); var ptpIndexers = _indexerFactory.All()
.Where(i => i.Settings.GetType() == typeof(PassThePopcornSettings));
var ptpIndexerOldSettings = ptpIndexers var ptpIndexerOldSettings = ptpIndexers
.Where(i => (i.Settings as PassThePopcornSettings).APIUser.IsNullOrWhiteSpace()).Select(i => i.Name); .Where(i => ((PassThePopcornSettings)i.Settings).APIUser.IsNullOrWhiteSpace()).Select(i => i.Name)
.ToList();
if (ptpIndexerOldSettings.Any()) if (ptpIndexerOldSettings.Any())
{ {

@ -31,9 +31,13 @@ namespace NzbDrone.Core.HealthCheck.Checks
public override HealthCheck Check() public override HealthCheck Check()
{ {
if (_configService.ProxyEnabled) if (!_configService.ProxyEnabled)
{ {
return new HealthCheck(GetType());
}
var addresses = Dns.GetHostAddresses(_configService.ProxyHostname); var addresses = Dns.GetHostAddresses(_configService.ProxyHostname);
if (!addresses.Any()) if (!addresses.Any())
{ {
return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format(_localizationService.GetLocalizedString("ProxyCheckResolveIpMessage"), _configService.ProxyHostname), "#proxy-failed-resolve-ip"); return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format(_localizationService.GetLocalizedString("ProxyCheckResolveIpMessage"), _configService.ProxyHostname), "#proxy-failed-resolve-ip");
@ -59,7 +63,6 @@ namespace NzbDrone.Core.HealthCheck.Checks
_logger.Error(ex, "Proxy Health Check failed"); _logger.Error(ex, "Proxy Health Check failed");
return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format(_localizationService.GetLocalizedString("ProxyCheckFailedToTestMessage"), request.Url), "#proxy-failed-test"); return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format(_localizationService.GetLocalizedString("ProxyCheckFailedToTestMessage"), request.Url), "#proxy-failed-test");
} }
}
return new HealthCheck(GetType()); return new HealthCheck(GetType());
} }

@ -62,6 +62,7 @@ namespace NzbDrone.Core.HealthCheck.Checks
{ {
var status = client.GetStatus(); var status = client.GetStatus();
var folders = status.OutputRootFolders; var folders = status.OutputRootFolders;
foreach (var folder in folders) foreach (var folder in folders)
{ {
if (!folder.IsValid) if (!folder.IsValid)
@ -70,15 +71,14 @@ namespace NzbDrone.Core.HealthCheck.Checks
{ {
return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format(_localizationService.GetLocalizedString("RemotePathMappingCheckWrongOSPath"), client.Definition.Name, folder.FullPath, _osInfo.Name), "#bad-remote-path-mapping"); return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format(_localizationService.GetLocalizedString("RemotePathMappingCheckWrongOSPath"), client.Definition.Name, folder.FullPath, _osInfo.Name), "#bad-remote-path-mapping");
} }
else if (_osInfo.IsDocker)
if (_osInfo.IsDocker)
{ {
return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format(_localizationService.GetLocalizedString("RemotePathMappingCheckBadDockerPath"), client.Definition.Name, folder.FullPath, _osInfo.Name), "#docker-bad-remote-path-mapping"); return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format(_localizationService.GetLocalizedString("RemotePathMappingCheckBadDockerPath"), client.Definition.Name, folder.FullPath, _osInfo.Name), "#docker-bad-remote-path-mapping");
} }
else
{
return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format(_localizationService.GetLocalizedString("RemotePathMappingCheckLocalWrongOSPath"), client.Definition.Name, folder.FullPath, _osInfo.Name), "#bad-download-client-settings"); return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format(_localizationService.GetLocalizedString("RemotePathMappingCheckLocalWrongOSPath"), client.Definition.Name, folder.FullPath, _osInfo.Name), "#bad-download-client-settings");
} }
}
if (!_diskProvider.FolderExists(folder.FullPath)) if (!_diskProvider.FolderExists(folder.FullPath))
{ {
@ -86,17 +86,16 @@ namespace NzbDrone.Core.HealthCheck.Checks
{ {
return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format(_localizationService.GetLocalizedString("RemotePathMappingCheckDockerFolderMissing"), client.Definition.Name, folder.FullPath), "#docker-bad-remote-path-mapping"); return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format(_localizationService.GetLocalizedString("RemotePathMappingCheckDockerFolderMissing"), client.Definition.Name, folder.FullPath), "#docker-bad-remote-path-mapping");
} }
else if (!status.IsLocalhost)
if (!status.IsLocalhost)
{ {
return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format(_localizationService.GetLocalizedString("RemotePathMappingCheckLocalFolderMissing"), client.Definition.Name, folder.FullPath), "#bad-remote-path-mapping"); return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format(_localizationService.GetLocalizedString("RemotePathMappingCheckLocalFolderMissing"), client.Definition.Name, folder.FullPath), "#bad-remote-path-mapping");
} }
else
{
return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format(_localizationService.GetLocalizedString("RemotePathMappingCheckGenericPermissions"), client.Definition.Name, folder.FullPath), "#permissions-error"); return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format(_localizationService.GetLocalizedString("RemotePathMappingCheckGenericPermissions"), client.Definition.Name, folder.FullPath), "#permissions-error");
} }
} }
} }
}
catch (DownloadClientException ex) catch (DownloadClientException ex)
{ {
_logger.Debug(ex, "Unable to communicate with {0}", client.Definition.Name); _logger.Debug(ex, "Unable to communicate with {0}", client.Definition.Name);
@ -122,25 +121,22 @@ namespace NzbDrone.Core.HealthCheck.Checks
return new HealthCheck(GetType()); return new HealthCheck(GetType());
} }
if (typeof(MovieImportFailedEvent).IsAssignableFrom(message.GetType())) if (message is MovieImportFailedEvent failureMessage)
{ {
var failureMessage = (MovieImportFailedEvent)message;
// if we can see the file exists but the import failed then likely a permissions issue // if we can see the file exists but the import failed then likely a permissions issue
if (failureMessage.MovieInfo != null) if (failureMessage.MovieInfo != null)
{ {
var moviePath = failureMessage.MovieInfo.Path; var moviePath = failureMessage.MovieInfo.Path;
if (_diskProvider.FileExists(moviePath)) if (_diskProvider.FileExists(moviePath))
{ {
return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format(_localizationService.GetLocalizedString("RemotePathMappingCheckDownloadPermissions"), moviePath), "#permissions-error"); return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format(_localizationService.GetLocalizedString("RemotePathMappingCheckDownloadPermissions"), moviePath), "#permissions-error");
} }
else
{
// If the file doesn't exist but MovieInfo is not null then the message is coming from // If the file doesn't exist but MovieInfo is not null then the message is coming from
// ImportApprovedMovies and the file must have been removed part way through processing // ImportApprovedMovies and the file must have been removed part way through processing
return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format(_localizationService.GetLocalizedString("RemotePathMappingCheckFileRemoved"), moviePath), "#remote-path-file-removed"); return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format(_localizationService.GetLocalizedString("RemotePathMappingCheckFileRemoved"), moviePath), "#remote-path-file-removed");
} }
}
// If the previous case did not match then the failure occured in DownloadedMovieImportService, // If the previous case did not match then the failure occured in DownloadedMovieImportService,
// while trying to locate the files reported by the download client // while trying to locate the files reported by the download client
@ -170,15 +166,14 @@ namespace NzbDrone.Core.HealthCheck.Checks
{ {
return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format(_localizationService.GetLocalizedString("RemotePathMappingCheckFilesWrongOSPath"), client.Definition.Name, dlpath, _osInfo.Name), "#bad-remote-path-mapping"); return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format(_localizationService.GetLocalizedString("RemotePathMappingCheckFilesWrongOSPath"), client.Definition.Name, dlpath, _osInfo.Name), "#bad-remote-path-mapping");
} }
else if (_osInfo.IsDocker)
if (_osInfo.IsDocker)
{ {
return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format(_localizationService.GetLocalizedString("RemotePathMappingCheckFilesBadDockerPath"), client.Definition.Name, dlpath, _osInfo.Name), "#docker-bad-remote-path-mapping"); return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format(_localizationService.GetLocalizedString("RemotePathMappingCheckFilesBadDockerPath"), client.Definition.Name, dlpath, _osInfo.Name), "#docker-bad-remote-path-mapping");
} }
else
{
return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format(_localizationService.GetLocalizedString("RemotePathMappingCheckFilesLocalWrongOSPath"), client.Definition.Name, dlpath, _osInfo.Name), "#bad-download-client-settings"); return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format(_localizationService.GetLocalizedString("RemotePathMappingCheckFilesLocalWrongOSPath"), client.Definition.Name, dlpath, _osInfo.Name), "#bad-download-client-settings");
} }
}
if (_diskProvider.FolderExists(dlpath)) if (_diskProvider.FolderExists(dlpath))
{ {
@ -190,16 +185,15 @@ namespace NzbDrone.Core.HealthCheck.Checks
{ {
return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format(_localizationService.GetLocalizedString("RemotePathMappingCheckFolderPermissions"), client.Definition.Name, dlpath), "#docker-bad-remote-path-mapping"); return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format(_localizationService.GetLocalizedString("RemotePathMappingCheckFolderPermissions"), client.Definition.Name, dlpath), "#docker-bad-remote-path-mapping");
} }
else if (!status.IsLocalhost)
if (!status.IsLocalhost)
{ {
return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format(_localizationService.GetLocalizedString("RemotePathMappingCheckRemoteDownloadClient"), client.Definition.Name, dlpath), "#bad-remote-path-mapping"); return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format(_localizationService.GetLocalizedString("RemotePathMappingCheckRemoteDownloadClient"), client.Definition.Name, dlpath), "#bad-remote-path-mapping");
} }
else
{
// path mappings shouldn't be needed locally so probably a permissions issue // path mappings shouldn't be needed locally so probably a permissions issue
return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format(_localizationService.GetLocalizedString("RemotePathMappingCheckFilesGenericPermissions"), client.Definition.Name, dlpath), "#permissions-error"); return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format(_localizationService.GetLocalizedString("RemotePathMappingCheckFilesGenericPermissions"), client.Definition.Name, dlpath), "#permissions-error");
} }
}
catch (DownloadClientException ex) catch (DownloadClientException ex)
{ {
_logger.Debug(ex, "Unable to communicate with {0}", client.Definition.Name); _logger.Debug(ex, "Unable to communicate with {0}", client.Definition.Name);
@ -215,10 +209,8 @@ namespace NzbDrone.Core.HealthCheck.Checks
return new HealthCheck(GetType()); return new HealthCheck(GetType());
} }
else
{
return Check(); return Check();
} }
} }
}
} }

@ -22,7 +22,9 @@ namespace NzbDrone.Core.HealthCheck.Checks
public override HealthCheck Check() public override HealthCheck Check()
{ {
var discordSlackNotifications = _notificationFactory.GetAvailableProviders().Where(n => n.ConfigContract.Equals("SlackSettings") && (n.Definition.Settings as SlackSettings).WebHookUrl.Contains("discord")); var discordSlackNotifications = _notificationFactory.GetAvailableProviders()
.Where(n => n.ConfigContract.Equals("SlackSettings") && ((SlackSettings)n.Definition.Settings).WebHookUrl.Contains("discord"))
.ToList();
if (discordSlackNotifications.Empty()) if (discordSlackNotifications.Empty())
{ {
@ -31,8 +33,7 @@ namespace NzbDrone.Core.HealthCheck.Checks
return new HealthCheck(GetType(), return new HealthCheck(GetType(),
HealthCheckResult.Warning, HealthCheckResult.Warning,
string.Format(_localizationService.GetLocalizedString("DiscordUrlInSlackNotification"), string.Format(_localizationService.GetLocalizedString("DiscordUrlInSlackNotification"), string.Join(", ", discordSlackNotifications.Select(n => n.Name))),
string.Join(", ", discordSlackNotifications.Select(n => n.Name))),
"#discord-as-slack-notification"); "#discord-as-slack-notification");
} }
} }

Loading…
Cancel
Save