mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-20 23:00:35 -05:00
24 lines
945 B
PowerShell
24 lines
945 B
PowerShell
|
|
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;
|
||
|
|
|
||
|
|
Write-Host 'Icinga Service Check has been configured';
|
||
|
|
}
|