person-key-to-immich-import birthday json (Day-Helper-2024-05-18)
csharp_prefer_braces = true
This commit is contained in:
@ -1,8 +1,7 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace File_Folder_Helper.ADO2025.PI5;
|
||||
|
||||
internal static partial class Helper20250404 {
|
||||
@ -128,10 +127,11 @@ internal static partial class Helper20250404 {
|
||||
ParseMetrics(logger, fileName, url);
|
||||
string sourceDirectory = Path.GetFullPath(args[0]);
|
||||
string[] files = Directory.GetFiles(sourceDirectory, searchPattern, SearchOption.AllDirectories);
|
||||
if (files.Length == 0)
|
||||
if (files.Length == 0) {
|
||||
logger.LogWarning("<{files}>(s)", files.Length);
|
||||
else
|
||||
} else {
|
||||
KumaToGatus(files);
|
||||
}
|
||||
}
|
||||
|
||||
private static void ParseMetrics(ILogger<Worker> logger, string fileName, string url) {
|
||||
@ -174,12 +174,14 @@ internal static partial class Helper20250404 {
|
||||
string checkFile;
|
||||
foreach (string file in files) {
|
||||
checkFile = file.ToLower().Replace('_', '-');
|
||||
if (checkFile != file)
|
||||
if (checkFile != file) {
|
||||
File.Move(file, checkFile);
|
||||
}
|
||||
json = File.ReadAllText(checkFile);
|
||||
kuma = JsonSerializer.Deserialize(json, KumaCommonSourceGenerationContext.Default.Kuma);
|
||||
if (kuma is null)
|
||||
if (kuma is null) {
|
||||
continue;
|
||||
}
|
||||
WriteGatus(checkFile, kuma);
|
||||
}
|
||||
}
|
||||
@ -193,8 +195,9 @@ internal static partial class Helper20250404 {
|
||||
];
|
||||
string[] segments;
|
||||
foreach (MonitorList monitorList in kuma.MonitorList) {
|
||||
if (monitorList.Type is not "http" and not "postgres")
|
||||
if (monitorList.Type is not "http" and not "postgres") {
|
||||
continue;
|
||||
}
|
||||
results.Add($" - name: {monitorList.Name}");
|
||||
results.Add($" group: {monitorList.PathName.Split(' ')[0]}");
|
||||
results.Add($" enabled: {monitorList.Active.ToString().ToLower()}");
|
||||
@ -208,19 +211,22 @@ internal static partial class Helper20250404 {
|
||||
}
|
||||
results.Add(" conditions:");
|
||||
results.Add(" - \"[STATUS] < 300\"");
|
||||
if (monitorList.Url.Contains("https"))
|
||||
if (monitorList.Url.Contains("https")) {
|
||||
results.Add(" - \"[CERTIFICATE_EXPIRATION] > 48h\"");
|
||||
}
|
||||
results.Add($" - \"[RESPONSE_TIME] < {monitorList.Timeout}\"");
|
||||
} else if (monitorList.Type == "postgres") {
|
||||
segments = monitorList.DatabaseConnectionString.Split('@');
|
||||
if (segments.Length != 2)
|
||||
if (segments.Length != 2) {
|
||||
continue;
|
||||
}
|
||||
results.Add($" # connectionString: \"{monitorList.DatabaseConnectionString}\"");
|
||||
results.Add($" url: \"tcp://{segments[1].Split('/')[0]}\"");
|
||||
results.Add(" conditions:");
|
||||
results.Add(" - \"[CONNECTED] == true\"");
|
||||
} else
|
||||
} else {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
results.Add(" alerts:");
|
||||
results.Add(" - type: email");
|
||||
results.Add(" description: \"healthcheck failed\"");
|
||||
|
Reference in New Issue
Block a user