Add lazy Muninn telemetry organ

This commit is contained in:
Meta Vens 2026-06-08 20:28:39 +01:00
commit b63f8e4241
21 changed files with 863 additions and 44 deletions

View file

@ -0,0 +1,2 @@
@echo off
powershell.exe -NoProfile -ExecutionPolicy Bypass -File E:\Projects\Odin\scripts\activate-muninn-raven-av-srt.ps1

View file

@ -0,0 +1,45 @@
param(
[string] $RavenHost = "raven",
[string] $MuninnExe = "C:\Meta\Odin\Muninn\muninn.exe",
[string] $StorePath = "C:\Meta\Odin\state\muninn.telemetry.cc",
[string] $LoopbackScript = "C:\Meta\Odin\Muninn\scripts\wasapi-loopback-capture.ps1",
[string] $LogRoot = "C:\Meta\Odin\logs\muninn",
[string] $Ffmpeg = "C:\Users\Madman's Lullaby\AppData\Local\Microsoft\WinGet\Links\ffmpeg.exe",
[string] $TargetHost = "10.77.0.2",
[int] $Port = 5200,
[string] $ObsTargetHost = "10.77.0.2",
[int] $ObsPort = 5204,
[string] $AudioDevice = "Realtek"
)
$ErrorActionPreference = "Stop"
$remoteScript = @"
`$ErrorActionPreference = "Stop"
if (-not (Test-Path -LiteralPath "$MuninnExe")) {
throw "Muninn executable not found at $MuninnExe"
}
if (-not (Test-Path -LiteralPath "$LoopbackScript")) {
throw "Muninn loopback script not found at $LoopbackScript"
}
New-Item -ItemType Directory -Force -Path "$LogRoot" | Out-Null
New-Item -ItemType Directory -Force -Path (Split-Path -Parent "$StorePath") | Out-Null
Get-CimInstance Win32_Process |
Where-Object { (`$_.Name -ieq "muninn.exe" -and `$_.CommandLine -like "*activate*") -or (`$_.Name -ieq "ffmpeg.exe" -and `$_.CommandLine -like "*srt://$TargetHost*") -or (`$_.Name -ieq "powershell.exe" -and `$_.CommandLine -like "*wasapi-loopback-capture.ps1*") } |
ForEach-Object { taskkill.exe /PID `$_.ProcessId /T /F | Out-Null }
`$muninnDir = Split-Path -Parent "$MuninnExe"
`$launcher = Join-Path `$muninnDir "activate-raven-av-srt.cmd"
`$lines = @(
"@echo off",
"cd /d ""`$muninnDir""",
"""$MuninnExe"" activate --store ""$StorePath"" --host raven --stream muninn.raven.av.srt --target-host ""$TargetHost"" --port $Port --obs-target-host ""$ObsTargetHost"" --obs-port $ObsPort --audio-device ""$AudioDevice"" --ffmpeg ""$Ffmpeg"" --loopback-script ""$LoopbackScript"" --log-root ""$LogRoot"" 1>>""$LogRoot\muninn-activate.out.log"" 2>>""$LogRoot\muninn-activate.err.log"""
)
Set-Content -LiteralPath `$launcher -Value `$lines -Encoding ASCII
cmd /c "schtasks /Delete /TN GameCult-Muninn-Activate /F 2>NUL"
cmd /c schtasks /Create /TN GameCult-Muninn-Activate /SC ONCE /ST 23:59 /TR `$launcher /IT /RL HIGHEST /F
cmd /c schtasks /Run /TN GameCult-Muninn-Activate
"@
$encoded = [Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes($remoteScript))
& ssh.exe -o BatchMode=yes -o ConnectTimeout=10 $RavenHost "powershell.exe -NoProfile -EncodedCommand $encoded"
exit $LASTEXITCODE

View file

@ -0,0 +1,2 @@
@echo off
powershell.exe -NoProfile -ExecutionPolicy Bypass -File E:\Projects\Odin\scripts\health-muninn.ps1

25
scripts/health-muninn.ps1 Normal file
View file

@ -0,0 +1,25 @@
param(
[string] $RavenHost = "raven",
[string] $MuninnExe = "C:\Meta\Odin\Muninn\muninn.exe",
[string] $StorePath = "C:\Meta\Odin\state\muninn.telemetry.cc"
)
$ErrorActionPreference = "Stop"
$remoteScript = @"
`$ErrorActionPreference = "Stop"
if (-not (Test-Path -LiteralPath "$MuninnExe")) {
throw "Muninn executable not found at $MuninnExe"
}
`$process = Get-CimInstance Win32_Process |
Where-Object { `$_.Name -ieq "muninn.exe" -and `$_.CommandLine -like "*serve*" } |
Select-Object -First 1
if (`$null -eq `$process) {
throw "Muninn serve process is not running"
}
& "$MuninnExe" --health --store "$StorePath"
"@
$encoded = [Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes($remoteScript))
& ssh.exe -o BatchMode=yes -o ConnectTimeout=5 $RavenHost "powershell.exe -NoProfile -EncodedCommand $encoded"
exit $LASTEXITCODE

View file

@ -1,2 +1,2 @@
@echo off
powershell.exe -NoProfile -ExecutionPolicy Bypass -File E:\Projects\Odin\scripts\health-raven-capture-mux.ps1
powershell.exe -NoProfile -ExecutionPolicy Bypass -File E:\Projects\Odin\scripts\health-muninn.ps1

View file

@ -1,9 +1,7 @@
param(
[string] $RavenHost = "10.77.0.4",
[string] $HealthUrl = "http://127.0.0.1:8801/health"
[string] $RavenHost = "raven"
)
$ErrorActionPreference = "Stop"
& ssh.exe -o BatchMode=yes -o ConnectTimeout=5 $RavenHost "curl.exe -fsS $HealthUrl >NUL"
$script = Join-Path $PSScriptRoot "health-muninn.ps1"
& powershell.exe -NoProfile -ExecutionPolicy Bypass -File $script -RavenHost $RavenHost
exit $LASTEXITCODE

View file

@ -0,0 +1,2 @@
@echo off
powershell.exe -NoProfile -ExecutionPolicy Bypass -File E:\Projects\Odin\scripts\restart-muninn.ps1

View file

@ -0,0 +1,37 @@
param(
[string] $RavenHost = "raven",
[string] $MuninnExe = "C:\Meta\Odin\Muninn\muninn.exe",
[string] $StorePath = "C:\Meta\Odin\state\muninn.telemetry.cc",
[string] $LogRoot = "C:\Meta\Odin\logs\muninn"
)
$ErrorActionPreference = "Stop"
$remoteScript = @"
`$ErrorActionPreference = "Stop"
if (-not (Test-Path -LiteralPath "$MuninnExe")) {
throw "Muninn executable not found at $MuninnExe"
}
Get-CimInstance Win32_Process |
Where-Object { `$_.Name -ieq "muninn.exe" -and `$_.CommandLine -like "*serve*" } |
ForEach-Object {
& taskkill.exe /PID `$_.ProcessId /T /F | Out-Null
}
New-Item -ItemType Directory -Force -Path "$LogRoot" | Out-Null
New-Item -ItemType Directory -Force -Path (Split-Path -Parent "$StorePath") | Out-Null
`$muninnDir = Split-Path -Parent "$MuninnExe"
`$launcher = Join-Path `$muninnDir "start-muninn-serve.cmd"
`$lines = @(
"@echo off",
"cd /d ""`$muninnDir""",
"""$MuninnExe"" serve --store ""$StorePath"" --log-root ""$LogRoot"" --host raven --interval-seconds 15 1>>""$LogRoot\muninn-serve.out.log"" 2>>""$LogRoot\muninn-serve.err.log"""
)
Set-Content -LiteralPath `$launcher -Value `$lines -Encoding ASCII
cmd /c "schtasks /Delete /TN GameCult-Muninn /F 2>NUL"
cmd /c schtasks /Create /TN GameCult-Muninn /SC ONCE /ST 23:59 /TR `$launcher /IT /RL HIGHEST /F
cmd /c schtasks /Run /TN GameCult-Muninn
"@
$encoded = [Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes($remoteScript))
& ssh.exe -o BatchMode=yes -o ConnectTimeout=10 $RavenHost "powershell.exe -NoProfile -EncodedCommand $encoded"
exit $LASTEXITCODE

View file

@ -1,2 +1,2 @@
@echo off
powershell.exe -NoProfile -ExecutionPolicy Bypass -File E:\Projects\Odin\scripts\restart-raven-capture-mux.ps1
powershell.exe -NoProfile -ExecutionPolicy Bypass -File E:\Projects\Odin\scripts\restart-muninn.ps1

View file

@ -1,28 +1,7 @@
param(
[string] $RavenHost = "10.77.0.4",
[string] $MimirRepo = "E:\Projects\Mimir",
[string] $TargetHost = "10.77.0.2",
[int] $Port = 5200,
[string] $ObsTargetHost = "10.77.0.2",
[int] $ObsPort = 5204
[string] $RavenHost = "raven"
)
$ErrorActionPreference = "Stop"
$remoteScript = @"
`$ErrorActionPreference = "Stop"
`$startScript = Join-Path "$MimirRepo" "scripts\start-raven-daemon.ps1"
if (-not (Test-Path -LiteralPath `$startScript)) {
throw "Raven Mimir start script not found at `$startScript"
}
Get-CimInstance Win32_Process |
Where-Object { `$_.Name -ieq "dotnet.exe" -and `$_.CommandLine -like "*Mimir.RavenDaemon*" } |
ForEach-Object {
& taskkill.exe /PID `$_.ProcessId /T /F | Out-Null
}
& powershell.exe -NoProfile -ExecutionPolicy Bypass -File `$startScript -TargetHost "$TargetHost" -Port $Port -ObsTargetHost "$ObsTargetHost" -ObsPort $ObsPort
"@
$encoded = [Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes($remoteScript))
& ssh.exe -o BatchMode=yes -o ConnectTimeout=10 $RavenHost "powershell.exe -NoProfile -EncodedCommand $encoded"
$script = Join-Path $PSScriptRoot "restart-muninn.ps1"
& powershell.exe -NoProfile -ExecutionPolicy Bypass -File $script -RavenHost $RavenHost
exit $LASTEXITCODE

View file

@ -56,11 +56,11 @@ $watchdogs = @(
IntervalSeconds = 300
},
[pscustomobject]@{
Id = "raven-capture-mux"
Name = "Raven capture mux"
Id = "muninn"
Name = "Muninn telemetry Verse assembler"
Verse = "raven.local"
Health = "$repoRoot\scripts\health-raven-capture-mux.cmd"
Restart = "$repoRoot\scripts\restart-raven-capture-mux.cmd"
Health = "$repoRoot\scripts\health-muninn.cmd"
Restart = "$repoRoot\scripts\restart-muninn.cmd"
},
[pscustomobject]@{
Id = "nightwing-gjallar"