wiki:zbx_api/zabcon/ideas

This page lists slightly vague ideas about improvements that are not ready go in tickets yet.

Zabcon command syntax and output

Zabcon commands should hide complexity and structure of API from use where applicable.

get user

This writeup will concentrate on get user syntax as that is the only partially implemented command so far. General concepts should apply the same to all commands.

Zabbix API provides either list of user IDs, or full user information. List of user IDs is useless information, so Zabcon should always perform extendoutput calls and format output appropriately. Suggested default output format is "ID Username".

Example output:

+> get user
ID Username
1  Admin
2  Guest
3  Client1

Output is properly formatted in columns - for example, if at least one user ID is 3 characters long, second column is accordingly aligned.

Sorting output

By default, output should be sorted by the first column. User should be able to specify sorting by one or multiple columns:

+> get user show=all sort=api_access+desc,id+asc

This would sort by api access descending first, then id ascending.

Syntax is just dreamt up for now, should be improved (especially ascending/descending specifying).

Invalid input handling

Invalid column specifications should make the command fail. Example session:

+> get user show=nosuchcolumn
ERROR: no such column 'nosuchcolumn'

Offering to continue command

Currently partial commands result in error message:

 -> get
Unknown command or syntax error

Instead, if command can be continued with a finite list of possibilities, available options should be printed. possible solution:

> get
1. user
2. host
Type in number > 1
ID Username
1  Admin
2  Guest

Such a sequence should be stored in the history as single command : "get user"

TAB completion

Similar to command continuing, but different use case. Pressing tab key should complete commands when possible.

> g[tab]
> get [tab]
user
host
item
> get u[tab]
> get user

Supporting singular and plural

Nouns are supported in both singular and plural forms, so both get user and get users are the same.

Warning about large output

Would be nice if requesting a huge output Zabcon would warn before outputting that for the user - for example, get item might return all items in Zabbix, which would be a very long list. Zabcon could warn if output would exceed 300 lines or so.

This protection would be in interactive mode only.

Currently partially solved by pause functionality. Pause should have two additional abilities:

  • quit, which would stop output;
  • full print, which would print all output not pausing anymore.

Possible problem with square brakcets

Currently, square brackets are used to allow array input. Will have to test this when hostgroups are supported as parameters somewhere - they can have square brackets in their name.

Implemented

Specifying columns

It is possible to specify output columns. For example:

 +> get user show=userid,alias limit=2
User result set
+--------+-------+
| userid | alias |
+--------+-------+
| 1      | Admin |
| 2      | guest |
+--------+-------+
2 rows total

Alias all

There is special alias all. When this is used as a column specification, all columns are printed. Default column ordering is used. Example command:

+> get user show=all