31 lines
777 B
C#
31 lines
777 B
C#
|
|
using System.Diagnostics;
|
|||
|
|
using FluentScheduler;
|
|||
|
|
using Interface.Jobs;
|
|||
|
|
|
|||
|
|
namespace Service.Jobs;
|
|||
|
|
|
|||
|
|
public class DiskMonitorRegistry : Registry, IDiskMonitorRegistry
|
|||
|
|
{
|
|||
|
|
public void Job()
|
|||
|
|
{
|
|||
|
|
// 执行 cmd 命令 获取执行结果
|
|||
|
|
var command = "df -h";
|
|||
|
|
var process = new Process
|
|||
|
|
{
|
|||
|
|
StartInfo = new ()
|
|||
|
|
{
|
|||
|
|
FileName = "/bin/bash",
|
|||
|
|
Arguments = $"-c \"{command}\"",
|
|||
|
|
RedirectStandardOutput = true,
|
|||
|
|
UseShellExecute = false,
|
|||
|
|
CreateNoWindow = true
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
process.Start();
|
|||
|
|
var result = process.StandardOutput.ReadToEnd();
|
|||
|
|
process.WaitForExit();
|
|||
|
|
|
|||
|
|
Console.WriteLine(result);
|
|||
|
|
}
|
|||
|
|
}
|