mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-21 15:19:58 -05:00
38 lines
1.2 KiB
PowerShell
38 lines
1.2 KiB
PowerShell
function Set-IcingaRegisteredServiceCheckConfig()
|
|
{
|
|
param(
|
|
[string]$ServiceId,
|
|
[hashtable]$Arguments = $null,
|
|
$Interval = $null,
|
|
[array]$TimeIndexes = $null
|
|
);
|
|
|
|
$Services = Get-IcingaRegisteredServiceChecks;
|
|
|
|
if ($Services.ContainsKey($ServiceId) -eq $FALSE) {
|
|
Write-Host 'Service Id was not found';
|
|
return;
|
|
}
|
|
|
|
[bool]$Modified = $FALSE;
|
|
$Path = [string]::Format('BackgroundDaemon.RegisteredServices.{0}', $ServiceId);
|
|
|
|
if ($null -ne $Arguments) {
|
|
Set-IcingaPowerShellConfig -Path ([string]::Format('{0}.Arguments', $Path)) -Value $Arguments;
|
|
$Modified = $TRUE;
|
|
}
|
|
if ($null -ne $Interval) {
|
|
Set-IcingaPowerShellConfig -Path ([string]::Format('{0}.Interval', $Path)) -Value $Interval;
|
|
$Modified = $TRUE;
|
|
}
|
|
if ($null -ne $TimeIndexes) {
|
|
Set-IcingaPowerShellConfig -Path ([string]::Format('{0}.TimeIndexes', $Path)) -Value $TimeIndexes;
|
|
$Modified = $TRUE;
|
|
}
|
|
|
|
if ($Modified) {
|
|
Write-Host 'Service configuration was successfully updated';
|
|
} else {
|
|
Write-Host 'No arguments were specified to update the service configuraiton';
|
|
}
|
|
}
|