1
All checks were successful
Docker Build & Deploy / Build Docker Image (push) Successful in 12s
Docker Build & Deploy / Deploy to Production (push) Successful in 4s

This commit is contained in:
孙诚
2025-03-07 12:10:53 +08:00
parent 41a69f44d3
commit bc92b6eaf5

View File

@@ -1,4 +1,5 @@
using System.Diagnostics; using System.Diagnostics;
using System.Text;
using FluentScheduler; using FluentScheduler;
using Interface.Jobs; using Interface.Jobs;
@@ -12,7 +13,7 @@ public class DiskMonitorRegistry : Registry, IDiskMonitorRegistry
var command = "df -h"; var command = "df -h";
var process = new Process var process = new Process
{ {
StartInfo = new () StartInfo = new()
{ {
FileName = "/bin/bash", FileName = "/bin/bash",
Arguments = $"-c \"{command}\"", Arguments = $"-c \"{command}\"",
@@ -21,11 +22,28 @@ public class DiskMonitorRegistry : Registry, IDiskMonitorRegistry
CreateNoWindow = true CreateNoWindow = true
} }
}; };
process.Start(); process.Start();
var result = process.StandardOutput.ReadToEnd(); var result = process.StandardOutput.ReadToEnd();
process.WaitForExit(); process.WaitForExit();
Console.WriteLine(result); Console.WriteLine(FormatResult(result));
}
private string FormatResult(string result)
{
var lines = result.Split("\n");
var sb = new StringBuilder();
foreach (var line in lines)
{
var cols = line.Split(" ", StringSplitOptions.RemoveEmptyEntries);
if (line.Contains("/host/wd/"))
{
sb.AppendLine($"{cols[5]}, {cols[1]}, {cols[4]}");
}
}
return sb.ToString();
} }
} }