2019-09-29 12:25:40 -04:00
function Test-IcingaAgent ( )
{
2021-08-06 12:12:27 -04:00
$IcingaAgentData = Get-IcingaAgentInstallation ;
$AgentServicePresent = Get-Service 'icinga2' -ErrorAction SilentlyContinue ;
if ( $IcingaAgentData . Installed -And $null -ne $AgentServicePresent ) {
2020-05-22 10:34:18 -04:00
Write-IcingaTestOutput -Severity 'Passed' -Message 'Icinga Agent service is installed' ;
2021-08-06 12:12:27 -04:00
} elseif ( $IcingaAgentData . Installed -And $null -eq $AgentServicePresent ) {
Write-IcingaTestOutput -Severity 'Failed' -Message 'Icinga Agent service is not installed' ;
} elseif ( $IcingaAgentData . Installed -eq $FALSE -And $null -ne $AgentServicePresent ) {
Write-IcingaTestOutput -Severity 'Failed' -Message 'Icinga Agent service is still present, while Icinga Agent itself is not installed.' ;
} elseif ( $IcingaAgentData . Installed -eq $FALSE -And $null -eq $AgentServicePresent ) {
Write-IcingaTestOutput -Severity 'Passed' -Message 'Icinga Agent is not installed and service is not present.' ;
}
Test-IcingaAgentServicePermission | Out-Null ;
Test-IcingaAcl " $Env:ProgramData \icinga2\etc " -WriteOutput | Out-Null ;
Test-IcingaAcl " $Env:ProgramData \icinga2\var " -WriteOutput | Out-Null ;
Test-IcingaAcl ( Get-IcingaCacheDir ) -WriteOutput | Out-Null ;
Test-IcingaAcl ( Get-IcingaPowerShellConfigDir ) -WriteOutput | Out-Null ;
2022-01-14 16:18:59 -05:00
Test-IcingaAcl -Directory ( Join-Path -Path ( Get-IcingaFrameworkRootPath ) -ChildPath 'certificate' ) -WriteOutput | Out-Null ;
2022-06-03 08:06:24 -04:00
Test-IcingaStateFile -WriteOutput | Out-Null ;
2021-08-06 12:12:27 -04:00
if ( $IcingaAgentData . Installed ) {
2019-09-29 12:25:40 -04:00
Test-IcingaAgentConfig | Out-Null ;
if ( Test-IcingaAgentFeatureEnabled -Feature 'debuglog' ) {
2020-05-22 10:34:18 -04:00
Write-IcingaTestOutput -Severity 'Warning' -Message 'The debug log of the Icinga Agent is enabled. Please keep in mind to disable it once testing is done, as a huge amount of data is generated'
2019-09-29 12:25:40 -04:00
} else {
2020-05-22 10:34:18 -04:00
Write-IcingaTestOutput -Severity 'Passed' -Message 'Icinga Agent debug log is disabled'
2019-09-29 12:25:40 -04:00
}
}
}