Uploaded image for project: 'ZABBIX BUGS AND ISSUES'
  1. ZABBIX BUGS AND ISSUES
  2. ZBX-14645

Unable to create maintenance

XMLWordPrintable

    • Icon: Incident report Incident report
    • Resolution: Won't fix
    • Icon: Trivial Trivial
    • None
    • 3.4.11
    • 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

            Unassigned Unassigned
            harish88 harish
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: