-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrace_stop.ps1
More file actions
47 lines (39 loc) · 1.36 KB
/
trace_stop.ps1
File metadata and controls
47 lines (39 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# siehe: https://ib-aid.com/articles/wie-analysiert-man-firebird-traces-mit-ibsurgeon-performance-analysis
# Config laden
$ScriptDir = $PSScriptRoot
$ConfigPath = Join-Path $ScriptDir "config.json"
Write-Host("Config Pfad: $ConfigPath")
if (-not (Test-Path $ConfigPath)) {
Write-Error "KRITISCH: config.json fehlt!"
exit 1
}
try {
$Config = Get-Content -Path $ConfigPath -Raw | ConvertFrom-Json
}
catch {
Write-Error "KRITISCH: config.json ist kein gültiges JSON."
exit 2
}
$MyUser = $Config.Firebird.Username
$MyPass = $Config.Firebird.Password
$MyPfad = $Config.Firebird.FirebirdPath
# Neueste Logdatei ermitteln
$LogFile = Get-ChildItem -Path "E:\*.log" | Sort-Object LastWriteTime -Descending | Select-Object -First 1
if (-not $LogFile) {
Write-Host "Keine Logdatei gefunden" -ForegroundColor Red
exit 3
}
Write-Host "Datei: $($LogFile.FullName)"
# Erste Zeile lesen und Trace-ID extrahieren
$FirstLine = Get-Content -Path $LogFile.FullName -TotalCount 1
if ($FirstLine -match "Trace session ID (\d+) started") {
$MyTraceId = $Matches[1]
Write-Host "Trace-ID: $MyTraceId"
Write-Host "Stoppe Trace..."
& "$MyPfad\fbtracemgr" -SE service_mgr -USER $MyUser -PASS $MyPass -STOP -ID $MyTraceId
}
else {
Write-Host "Konnte Trace-ID nicht aus erster Zeile extrahieren:" -ForegroundColor Red
Write-Host $FirstLine
exit 4
}