-
Type:
Incident report
-
Resolution: Won't fix
-
Priority:
Trivial
-
None
-
Affects Version/s: 3.4.11
-
Component/s: API (A)
-
None
Hi,
I am trying to create a maintenance with my powershell script as shown below,
# Create Maintenance With Servername
function global:Zabbix-CreateMaintenance \{
$ErrorActionPreference = 'Continue'
$body = @\{
"method" = "maintenance.create"
"jsonrpc" = $zabSessionParams.jsonrpc
"id" = ++$zabSessionParams.id
"auth" = $zabSessionParams.session
"params" = @\{
name = "WELCOME"
maintenance_type = 0
description = "OD-ServerMaintenance"
active_since = 1358844540
active_till = 1390466940
groupids = @\{
groupid = "6"
}
hostids = @\{
hostid = "10257"
}
timeperiods = @\{
dayofweek = 1
period = 3600
start_date = 2147483647
start_time = 64800
timeperiod_type = 3
}
}
}
$respond = Invoke-RestMethod $zabSessionParams.url -ContentType "application/json" -Body ($body | ConvertTo-Json) -Method Put
If ($respond.error) \{
Write-Error "Unable to Create Maintenance for OD-ServerMaintenance"
Write-Error $respond.error
Exit -1
}
Else \{
Write-Host "$respond.result"
}
}
I tried with required combinations of parameters used for creating the maintenance and I endup in error message with invalid parameters as shown below,
*Error Message:*
Zabbix-CreateMaintenance : Unable to Create Maintenance for OD3
At C:\Octopus\Work\20180725152127-759-12\Script.ps1:39 char:5
+ Zabbix-CreateMaintenance
+ ~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Zabbix-CreateMaintenance
Zabbix-CreateMaintenance : @\{code=-32602; message=Invalid params.; data=Atleast one maintenance period must be created.; debug=System.Object[]}
At C:\Octopus\Work\20180725152127-759-12\Script.ps1:39 char:5
+ Zabbix-CreateMaintenance
+ ~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Zabbix-CreateMaintenance
Please correct me if I am wrong with the syntax, as per the documentation I tried the same with zabbix documentation version of 3.4.11