mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-21 15:19:58 -05:00
25 lines
984 B
PowerShell
25 lines
984 B
PowerShell
function Test-IcingaStateFile()
|
|
{
|
|
param (
|
|
[switch]$WriteOutput = $FALSE
|
|
);
|
|
|
|
$IcingaAgentData = Get-IcingaAgentInstallation;
|
|
[string]$StateFilePath = Join-Path -Path $ENV:ProgramData -ChildPath 'icinga2\var\lib\icinga2\icinga2.state';
|
|
|
|
if ((Test-Path $StateFilePath) -eq $FALSE) {
|
|
Write-IcingaTestOutput -Severity 'Passed' -Message 'The Icinga Agent state file does not exist' -DropMessage:(-Not $WriteOutput);
|
|
return $TRUE;
|
|
}
|
|
|
|
$Success = Read-IcingaStateFile;
|
|
|
|
if ($Success) {
|
|
Write-IcingaTestOutput -Severity 'Passed' -Message 'The Icinga Agent state file is healthy' -DropMessage:(-Not $WriteOutput);
|
|
return $TRUE;
|
|
} else {
|
|
Write-IcingaTestOutput -Severity 'Failed' -Message 'The Icinga Agent state file is corrupt. Use the "Repair-IcingaStateFile" command to repair the file or "Read-IcingaStateFile -WriteOutput" for further details' -DropMessage:(-Not $WriteOutput);
|
|
}
|
|
|
|
return $FALSE;
|
|
}
|