mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-20 23:00:35 -05:00
Disabling UseConsistentIndentation because it is not properly working for multi-line commands with arguments and array/hashtable objects
30 lines
1.9 KiB
PowerShell
30 lines
1.9 KiB
PowerShell
function Test-IcingaAgent()
|
|
{
|
|
$IcingaAgentData = Get-IcingaAgentInstallation;
|
|
$AgentServicePresent = Get-Service 'icinga2' -ErrorAction SilentlyContinue;
|
|
if ($IcingaAgentData.Installed -And $null -ne $AgentServicePresent) {
|
|
Write-IcingaTestOutput -Severity 'Passed' -Message 'Icinga Agent service is installed';
|
|
} 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;
|
|
Test-IcingaAcl -Directory (Join-Path -Path (Get-IcingaFrameworkRootPath) -ChildPath 'certificate') -WriteOutput | Out-Null;
|
|
|
|
if ($IcingaAgentData.Installed) {
|
|
Test-IcingaAgentConfig | Out-Null;
|
|
if (Test-IcingaAgentFeatureEnabled -Feature 'debuglog') {
|
|
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'
|
|
} else {
|
|
Write-IcingaTestOutput -Severity 'Passed' -Message 'Icinga Agent debug log is disabled'
|
|
}
|
|
}
|
|
}
|