Ad Widget

Collapse

Zabbix API problem by maintenance.creat

Collapse
This topic has been answered.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Spearmint0695
    Junior Member
    • Apr 2024
    • 2

    #1

    Zabbix API problem by maintenance.creat

    Hello all together

    I am writing a python script to set maintenance mode for hostgroups. I can set maintenance windows starting from now, but when I try to make a maintenance windows on a day next week, it doesn't work. Maybe there is a problem in my json request.

    payload = {}
    payload['jsonrpc'] = '2.0'
    payload['method'] = 'maintenance.create'
    payload['params'] = {}
    payload['params']['name'] = "Maintenance period for: " + hostgroup + ""
    payload['params']['active_since'] = start_dt (is a timestamp with the date and the time)
    payload['params']['active_till'] = new_epoch ( also timestamp with the ending time)
    payload['params']['groups'] = []
    groups = {}
    groups['groupid'] = hostgroupid
    payload['params']['groups'].append(groups)
    payload['params']['description'] = "This maintenance period is created by a script."
    payload['params']['timeperiods'] = []
    timeperiods = {}
    timeperiods['period'] = period
    timeperiods['timeperiod_type'] = 0
    timeperiods['start_date'] = start_date_ts (its a timestamp 1714514400.0)
    timeperiods['start_time'] = start_time_s (it's 33300s also 09:15)
    payload['params']['timeperiods'].append(timeperiods)
    payload['auth'] = token
    payload['id'] = 1

    Can someone help me with this?

    Thanks in advance

    T
  • Answer selected by Spearmint0695 at 26-04-2024, 08:56.
    Spearmint0695
    Junior Member
    • Apr 2024
    • 2

    I have resolved this problem with help from zabbix support. The timeperiods['start_time'] = start_time_s (it's 33300s also 09:15) is not needed in this case because of timeperiods['start_date'] = start_date_ts (its a timestamp 1714514400.0). And second thing the timestamp has to be an int value and not a float value.

    Comment

    • Spearmint0695
      Junior Member
      • Apr 2024
      • 2

      #2
      I have resolved this problem with help from zabbix support. The timeperiods['start_time'] = start_time_s (it's 33300s also 09:15) is not needed in this case because of timeperiods['start_date'] = start_date_ts (its a timestamp 1714514400.0). And second thing the timestamp has to be an int value and not a float value.

      Comment

      Working...