2019-09-29 12:25:40 -04:00
function Test-IcingaAgentConfig ( )
{
param (
[ switch ] $WriteStackTrace
) ;
$Binary = Get-IcingaAgentBinary ;
$ConfigResult = Start-IcingaProcess -Executable $Binary -Arguments 'daemon -C' ;
if ( $ConfigResult . ExitCode -eq 0 ) {
2020-05-22 10:34:18 -04:00
Write-IcingaTestOutput -Severity 'Passed' -Message 'Icinga Agent configuration is valid' ;
2019-09-29 12:25:40 -04:00
return $TRUE ;
} else {
2020-05-22 10:34:18 -04:00
Write-IcingaTestOutput -Severity 'Failed' -Message 'Icinga Agent configuration contains errors. Run this command for getting a detailed error report: "Test-IcingaAgentConfig -WriteStackTrace | Out-Null"' ;
2019-09-29 12:25:40 -04:00
if ( $WriteStackTrace ) {
2020-05-13 10:53:15 -04:00
Write-IcingaConsolePlain $ConfigResult . Message ;
2019-09-29 12:25:40 -04:00
}
return $FALSE ;
}
}