mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-21 07:10:15 -05:00
Added Cmdlet to update registered Service Check config
This commit is contained in:
parent
d3d31bfcd4
commit
ffd3cf5644
1 changed files with 38 additions and 0 deletions
38
lib/daemon/Set-IcingaRegisteredServiceCheckConfig.psm1
Normal file
38
lib/daemon/Set-IcingaRegisteredServiceCheckConfig.psm1
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
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';
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue