mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-20 23:00:35 -05:00
21 lines
727 B
PowerShell
21 lines
727 B
PowerShell
|
|
function Test-IcingaAgentConfig()
|
||
|
|
{
|
||
|
|
param (
|
||
|
|
[switch]$WriteStackTrace
|
||
|
|
);
|
||
|
|
|
||
|
|
$Binary = Get-IcingaAgentBinary;
|
||
|
|
$ConfigResult = Start-IcingaProcess -Executable $Binary -Arguments 'daemon -C';
|
||
|
|
|
||
|
|
if ($ConfigResult.ExitCode -eq 0) {
|
||
|
|
Write-IcingaTestOutput -Severity 'PASSED' -Message 'Icinga Agent configuration is valid';
|
||
|
|
return $TRUE;
|
||
|
|
} else {
|
||
|
|
Write-IcingaTestOutput -Severity 'FAILED' -Message 'Icinga Agent configuration is containing errors. Run this command for getting a detailed error report: "Test-IcingaAgentConfig -WriteStackTrace | Out-Null"';
|
||
|
|
if ($WriteStackTrace) {
|
||
|
|
Write-Host $ConfigResult.Message;
|
||
|
|
}
|
||
|
|
return $FALSE;
|
||
|
|
}
|
||
|
|
}
|