icinga-powershell-framework/lib/daemon/Set-IcingaForWindowsThreadAlive.psm1
2022-03-18 22:54:43 +01:00

39 lines
1.3 KiB
PowerShell

function Set-IcingaForWindowsThreadAlive()
{
param (
[string]$ThreadName = '',
[string]$ThreadCmd = '',
$ThreadPool = $null,
[hashtable]$ThreadArgs = @{ },
[switch]$Active = $FALSE,
[hashtable]$TerminateAction = @{ }
);
if ([string]::IsNullOrEmpty($ThreadName)) {
return;
}
if ($Global:Icinga.Public.ThreadAliveHousekeeping.ContainsKey($ThreadName) -eq $FALSE) {
if ($null -eq $ThreadPool) {
return;
}
$Global:Icinga.Public.ThreadAliveHousekeeping.Add(
$ThreadName,
@{
'LastSeen' = [DateTime]::Now;
'Command' = $ThreadCmd;
'Arguments' = $ThreadArgs;
'ThreadPool' = $ThreadPool;
'Active' = [bool]$Active;
'TerminateAction' = $TerminateAction;
}
);
return;
}
$Global:Icinga.Public.ThreadAliveHousekeeping[$ThreadName].LastSeen = [DateTime]::Now;
$Global:Icinga.Public.ThreadAliveHousekeeping[$ThreadName].Active = [bool]$Active;
$Global:Icinga.Public.ThreadAliveHousekeeping[$ThreadName].TerminateAction = $TerminateAction;
}