zabbix-tools / go-zabbix

Go bindings for the Zabbix API
GNU General Public License v2.0
108 stars 70 forks source link

How to sort the triggers return from seesion.GetTriggers? #16

Closed ykyuen closed 6 years ago

ykyuen commented 6 years ago

i have the following code snippet which i could get the triggers from zabbix

triggers, err := session.GetTriggers(zabbix.TriggerGetParams{
  TriggerIDs: []string{
    "14606",
    "14618",
    "14625",
    "14632",
    "14639",
    "14646",
  },
  // GetParameters: zabbix.GetParameters{
  //   SortField: []string{
  //     "TriggerID",
  //   },
  //   SortOrder: zabbix.SortOrderDescending,
  // },
})

it works fine and by default the returned triggers are sorted by TriggerID in asc order. I tried uncommenting the GetParameters block in order to change the sorting but then it will return no results.

What did i miss? Thanks =D

ykyuen commented 6 years ago

O, i figured it out~ it didn't work becoz i the sort field name is incorrect.

according to the zabbix api doc

Possible values are: triggerid, description, status, priority, lastchange and hostname.

=D