mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-20 23:00:35 -05:00
40 lines
1.3 KiB
PowerShell
40 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;
|
||
|
|
}
|