2019-10-05 16:02:17 -04:00
|
|
|
function Show-IcingaRegisteredServiceChecks()
|
|
|
|
|
{
|
2022-01-27 14:59:55 -05:00
|
|
|
[array]$ServiceSummary = @(
|
2022-01-28 09:22:12 -05:00
|
|
|
'List of configured background service checks on this system:',
|
2022-01-27 14:59:55 -05:00
|
|
|
'=> https://icinga.com/docs/icinga-for-windows/latest/doc/110-Installation/06-Collect-Metrics-over-Time/',
|
|
|
|
|
''
|
|
|
|
|
);
|
2019-10-05 16:02:17 -04:00
|
|
|
|
2022-01-27 14:59:55 -05:00
|
|
|
[hashtable]$ServiceList = Get-IcingaRegisteredServiceChecks;
|
|
|
|
|
|
|
|
|
|
foreach ($serviceId in $ServiceList.Keys) {
|
|
|
|
|
$serviceDetails = $ServiceList[$serviceId];
|
|
|
|
|
|
|
|
|
|
$ServiceSummary += $serviceDetails.CheckCommand;
|
|
|
|
|
$ServiceSummary += '-----------';
|
|
|
|
|
|
|
|
|
|
[int]$MaxLength = (Get-IcingaMaxTextLength -TextArray $serviceDetails.Keys) - 1;
|
|
|
|
|
[array]$ServiceData = @();
|
|
|
|
|
|
|
|
|
|
foreach ($serviceArguments in $serviceDetails.Keys) {
|
|
|
|
|
$serviceValue = $serviceDetails[$serviceArguments];
|
|
|
|
|
$PrintName = Add-IcingaWhiteSpaceToString -Text $serviceArguments -Length $MaxLength;
|
|
|
|
|
if ($serviceValue -Is [array]) {
|
|
|
|
|
$serviceValue = [string]::Join(', ', $serviceValue);
|
|
|
|
|
} elseif ($serviceValue -Is [PSCustomObject]) {
|
|
|
|
|
$serviceValue = ConvertTo-IcingaCommandArgumentString -Command $serviceDetails.CheckCommand -CommandArguments $serviceValue;
|
|
|
|
|
}
|
|
|
|
|
$ServiceData += [string]::Format('{0} => {1}', $PrintName, $serviceValue);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$ServiceSummary += $ServiceData | Sort-Object;
|
|
|
|
|
$ServiceSummary += '';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($ServiceList.Count -eq 0) {
|
|
|
|
|
$ServiceSummary += 'No background service checks configured';
|
|
|
|
|
$ServiceSummary += '';
|
2019-10-05 16:02:17 -04:00
|
|
|
}
|
2022-01-27 14:59:55 -05:00
|
|
|
|
|
|
|
|
Write-Output $ServiceSummary;
|
2019-10-05 16:02:17 -04:00
|
|
|
}
|