Werk #16149: New OrderBy header in livestatus

Komponente Livestatus
Titel New OrderBy header in livestatus
Datum 29.01.2024
Checkmk Edition Checkmk Raw (CRE)
Checkmk-Version 2.3.0b1 2.4.0b1
Level Kleine Änderung
Klasse Neues Feature
Kompatibilität Kompatibel - benötigt kein manuelles Eingreifen

We provide a new header for livestatus that returns the rows in sorted order.

For example, to sort host names in descending order

$ lq 'GET hosts\nColumns: name\nOrderBy: name desc'
zhost
yhost
xhost
...

in ascending order

$ lq 'GET hosts\nColumns: name\nOrderBy: name asc'
ahost
bhost
...

or, alternatively without asc,

$ lq 'GET hosts\nColumns: name\nOrderBy: name'
ahost
bhost
...

The OrderBy header can be combined with the Limit header to limit the number of results as expected.

$ lq 'GET hosts\nColumns: name\nOrderBy: name\nLimit: 1'
ahost

Furthermore, it is possible to sort on dictionary keys with the following syntax

$ lq << EOF
GET services
Columns: host_name description performance_data
OrderBy: performance_data.user_time
EOF
...

Zur Liste aller Werks