1
This commit is contained in:
6
src/Interface/Jobs/IDiskMonitorRegistry.cs
Normal file
6
src/Interface/Jobs/IDiskMonitorRegistry.cs
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
namespace Interface.Jobs;
|
||||||
|
|
||||||
|
public interface IDiskMonitorRegistry
|
||||||
|
{
|
||||||
|
void Job();
|
||||||
|
}
|
||||||
31
src/Service/Jobs/DiskMonitorRegistry.cs
Normal file
31
src/Service/Jobs/DiskMonitorRegistry.cs
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,6 +12,7 @@ public class JobTriggerController : BaseController
|
|||||||
private readonly IStartupRegistry _startupRegistry;
|
private readonly IStartupRegistry _startupRegistry;
|
||||||
private readonly IShutdownRegistry _shutdownRegistry;
|
private readonly IShutdownRegistry _shutdownRegistry;
|
||||||
private readonly IChineseNfoRegistry _chineseNfoRegistry;
|
private readonly IChineseNfoRegistry _chineseNfoRegistry;
|
||||||
|
private readonly IDiskMonitorRegistry _diskMonitorRegistry;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ctor
|
/// ctor
|
||||||
@@ -23,7 +24,8 @@ public class JobTriggerController : BaseController
|
|||||||
IRSyncTaskRegistry rSyncTaskRegistry,
|
IRSyncTaskRegistry rSyncTaskRegistry,
|
||||||
IStartupRegistry startupRegistry,
|
IStartupRegistry startupRegistry,
|
||||||
IShutdownRegistry shutdownRegistry,
|
IShutdownRegistry shutdownRegistry,
|
||||||
IChineseNfoRegistry chineseNfoRegistry)
|
IChineseNfoRegistry chineseNfoRegistry,
|
||||||
|
IDiskMonitorRegistry diskMonitorRegistry)
|
||||||
{
|
{
|
||||||
_logTotalNotifyJobRegistry = logTotalNotifyJobRegistry;
|
_logTotalNotifyJobRegistry = logTotalNotifyJobRegistry;
|
||||||
_diskActionMonitorRegistry = diskActionMonitorRegistry;
|
_diskActionMonitorRegistry = diskActionMonitorRegistry;
|
||||||
@@ -32,6 +34,7 @@ public class JobTriggerController : BaseController
|
|||||||
_startupRegistry = startupRegistry;
|
_startupRegistry = startupRegistry;
|
||||||
_shutdownRegistry = shutdownRegistry;
|
_shutdownRegistry = shutdownRegistry;
|
||||||
_chineseNfoRegistry = chineseNfoRegistry;
|
_chineseNfoRegistry = chineseNfoRegistry;
|
||||||
|
_diskMonitorRegistry = diskMonitorRegistry;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
@@ -98,4 +101,12 @@ public class JobTriggerController : BaseController
|
|||||||
|
|
||||||
return "OK";
|
return "OK";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public string DiskMonitor()
|
||||||
|
{
|
||||||
|
_diskMonitorRegistry.Job();
|
||||||
|
|
||||||
|
return "OK";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user