Update Watchdog.cs
This commit is contained in:
parent
2dc6c84a85
commit
e998affd38
34
Watchdog.cs
34
Watchdog.cs
@ -22,10 +22,21 @@ public partial class Watchdog : BackgroundService
|
||||
|
||||
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||
{
|
||||
var workingDirectory = Path.GetDirectoryName(Environment.ProcessPath!)!;
|
||||
string workingDirectory = Path.GetDirectoryName(Environment.ProcessPath!)!;
|
||||
string hpSsaCli = Path.Combine(workingDirectory, HpCliUtil);
|
||||
string pcBeeper = Path.Combine(workingDirectory, PcBeeperUtil);
|
||||
|
||||
// Ready beep sequence
|
||||
await Cli.Wrap(pcBeeper)
|
||||
.WithArguments(new[] { "-f", "1500", "-d", "100" })
|
||||
.WithWorkingDirectory(workingDirectory)
|
||||
.ExecuteAsync(stoppingToken);
|
||||
await Task.Delay(TimeSpan.FromMilliseconds(10), stoppingToken);
|
||||
await Cli.Wrap(pcBeeper)
|
||||
.WithArguments(new[] { "-f", "2000", "-d", "100" })
|
||||
.WithWorkingDirectory(workingDirectory)
|
||||
.ExecuteAsync(stoppingToken);
|
||||
|
||||
while (!stoppingToken.IsCancellationRequested)
|
||||
{
|
||||
BufferedCommandResult hpSsaCliResult = await Cli.Wrap(hpSsaCli)
|
||||
@ -41,9 +52,26 @@ public partial class Watchdog : BackgroundService
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (Match match in matches)
|
||||
bool allHealthy = matches.All(m => m.Groups[1].Value.Equals("OK", StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
if (!allHealthy)
|
||||
{
|
||||
Console.WriteLine(match.Groups[1].Value);
|
||||
_logger.LogError("One or more disks reported faulty status");
|
||||
|
||||
await Cli.Wrap(pcBeeper)
|
||||
.WithArguments(new[] { "-f", "3000", "-d", "500" })
|
||||
.WithWorkingDirectory(workingDirectory)
|
||||
.ExecuteAsync(stoppingToken);
|
||||
await Task.Delay(TimeSpan.FromMilliseconds(100), stoppingToken);
|
||||
await Cli.Wrap(pcBeeper)
|
||||
.WithArguments(new[] { "-f", "3000", "-d", "500" })
|
||||
.WithWorkingDirectory(workingDirectory)
|
||||
.ExecuteAsync(stoppingToken);
|
||||
await Task.Delay(TimeSpan.FromMilliseconds(100), stoppingToken);
|
||||
await Cli.Wrap(pcBeeper)
|
||||
.WithArguments(new[] { "-f", "3000", "-d", "500" })
|
||||
.WithWorkingDirectory(workingDirectory)
|
||||
.ExecuteAsync(stoppingToken);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user