Version 1.1
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
[CmdletBinding()]
|
||||
param([string]$SSHUser = "stressuser")
|
||||
|
||||
Set-StrictMode -Version Latest
|
||||
$BasePath = $PSScriptRoot
|
||||
$KillFile = Join-Path $BasePath "KILL"
|
||||
$LogPath = Join-Path $BasePath "Logs"
|
||||
$LogFile = Join-Path $LogPath ("kill-{0}.log" -f (Get-Date -Format "yyyyMMdd-HHmmss"))
|
||||
$VMs = @(
|
||||
113..120 | ForEach-Object { "10.52.70.$_" }
|
||||
113..120 | ForEach-Object { "10.52.68.$_" }
|
||||
)
|
||||
|
||||
New-Item -ItemType Directory -Path $LogPath -Force | Out-Null
|
||||
New-Item -ItemType File -Path $KillFile -Force | Out-Null
|
||||
|
||||
function Write-Log([string]$Message) {
|
||||
$line = "{0} {1}" -f (Get-Date -Format "yyyy-MM-dd HH:mm:ss"), $Message
|
||||
Write-Host $line
|
||||
Add-Content -LiteralPath $LogFile -Value $line
|
||||
}
|
||||
|
||||
Write-Log "NOT-AUS aktiviert. Kill-Datei: $KillFile"
|
||||
foreach ($vm in $VMs) {
|
||||
& ssh -o BatchMode=yes -o ConnectTimeout=5 "$SSHUser@$vm" "sudo -n /usr/bin/pkill -x stress-ng || true" 2>&1 | ForEach-Object { Write-Log "[$vm] $_" }
|
||||
if ($LASTEXITCODE -eq 0) { Write-Log "[$vm] Stoppbefehl ausgeführt." }
|
||||
else { Write-Log "WARNUNG: [$vm] nicht erreichbar oder Stopp fehlgeschlagen." }
|
||||
}
|
||||
Write-Log "NOT-AUS abgeschlossen. Vor einem Neustart Ursache prüfen und START-STRESS.ps1 mit -ResetKillSwitch starten."
|
||||
Reference in New Issue
Block a user