2019-10-05 16:02:17 -04:00
|
|
|
function Register-IcingaServiceCheck()
|
|
|
|
|
{
|
|
|
|
|
param(
|
|
|
|
|
[string]$CheckCommand,
|
|
|
|
|
[hashtable]$Arguments,
|
|
|
|
|
[int]$Interval = 60,
|
|
|
|
|
[array]$TimeIndexes = @()
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if ([string]::IsNullOrEmpty($CheckCommand)) {
|
|
|
|
|
throw 'Please specify a CheckCommand';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$Hash = Get-StringSha1 ([string]::Format('{0} {1}', $CheckCommand, ($Arguments | Out-String)));
|
|
|
|
|
$Path = [string]::Format('BackgroundDaemon.RegisteredServices.{0}', $Hash);
|
|
|
|
|
|
|
|
|
|
Set-IcingaPowerShellConfig -Path ([string]::Format('{0}.CheckCommand', $Path)) -Value $CheckCommand;
|
|
|
|
|
Set-IcingaPowerShellConfig -Path ([string]::Format('{0}.Arguments', $Path)) -Value $Arguments;
|
|
|
|
|
Set-IcingaPowerShellConfig -Path ([string]::Format('{0}.Interval', $Path)) -Value $Interval;
|
|
|
|
|
Set-IcingaPowerShellConfig -Path ([string]::Format('{0}.TimeIndexes', $Path)) -Value $TimeIndexes;
|
|
|
|
|
|
2022-01-27 14:59:55 -05:00
|
|
|
Write-IcingaConsoleNotice 'Icinga background service check has been added';
|
2019-10-05 16:02:17 -04:00
|
|
|
}
|