mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-21 15:19:58 -05:00
32 lines
935 B
PowerShell
32 lines
935 B
PowerShell
function Exit-IcingaThrowCritical()
|
|
{
|
|
param (
|
|
[string]$Message = '',
|
|
[string]$FilterString = $null,
|
|
[string]$SearchString = $null,
|
|
[switch]$Force = $FALSE
|
|
);
|
|
|
|
if ($Force -eq $FALSE) {
|
|
if ([string]::IsNullOrEmpty($FilterString) -Or [string]::IsNullOrEmpty($SearchString)) {
|
|
return;
|
|
}
|
|
|
|
if ($FilterString -NotLike "*$SearchString*") {
|
|
return;
|
|
}
|
|
}
|
|
|
|
[string]$OutputMessage = [string]::Format(
|
|
'[CRITICAL] {0}',
|
|
$Message
|
|
);
|
|
|
|
Set-IcingaInternalPluginExitCode -ExitCode $IcingaEnums.IcingaExitCode.Critical;
|
|
Set-IcingaInternalPluginException -PluginException $OutputMessage;
|
|
|
|
if ($Global:Icinga.Protected.RunAsDaemon -eq $FALSE -And $Global:Icinga.Protected.JEAContext -eq $FALSE) {
|
|
Write-IcingaConsolePlain $OutputMessage;
|
|
exit $IcingaEnums.IcingaExitCode.Critical;
|
|
}
|
|
}
|