2021-07-16 05:31:41 -04:00
|
|
|
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;
|
|
|
|
|
|
2023-07-24 11:37:41 -04:00
|
|
|
if ($Global:Icinga.Protected.RunAsDaemon -eq $TRUE -Or $Global:Icinga.Protected.JEAContext -eq $TRUE) {
|
|
|
|
|
throw $OutputMessage;
|
|
|
|
|
|
|
|
|
|
# Just in case we don't end - shouldn't happen anyway
|
|
|
|
|
return;
|
2021-07-16 05:31:41 -04:00
|
|
|
}
|
2023-07-24 11:37:41 -04:00
|
|
|
|
|
|
|
|
Write-IcingaConsolePlain $OutputMessage;
|
|
|
|
|
exit $IcingaEnums.IcingaExitCode.Critical;
|
2021-07-16 05:31:41 -04:00
|
|
|
}
|