template

The template format used is very basic.

You can specify variable names, use basic if statements, and loops.

A simple HTML like table format is used to format fixed width output and lists for the terminal.

variables

You specify the variable name for the item you want to output.

In your output, this will be translated with the instance status:

if statements

You can use basic logic with if statements.

The template if statement only checks if a value if set, or true (not 0).

You can’t have an if statement based on the contents of a variable.

Example, output when the last backup occurred or an error message.

If the instance has not been backed up, the parser library will not set the ARC_L0 variable. This will trigger the else condition above, otherwise we output when the last backup occurred.

See instance for more information about the ARC_L0 and other instance variables.

loops

Some variables represent lists of values, such as user sessions, and internally are stored like arrays. To output these lists you have to use a loop structure and define what to do for each element in the list.

Example, list all of the user sessions:

Note that is used to represent a new line in the output, otherwise all line breaks are ignored.

If there are no users nothing will be output. See users list and session list for more information about each user session.

table format

A simple HTML like format is used to provide fixed width output, essential to making the command line output readable.

Lets format the user output above, and add some more columns to it.

You only need to specify the alignment on the column in the first row, the rest of the rows will follow suit.

filter results

The parser library will always return the full lists of things like users and storage spaces. If you don’t want to output them all, you can specify a column filter that will be applied at run time.

You can specify:

  • gt= only output rows whose numeric value is greater than supplied
  • lt= only output rows whose numeric value is less than supplied
  • eq= only output rows whose numeric value is equal to supplied
  • ne= only output rows whose numeric value is not equal to supplied
  • match= only output rows whose string value matches supplied
  • notmatch= only output rows whose string value does not match supplied

examples

Only output this row if this column value is greater than 0.

Only output this row if this column value is less than 90.

Only output this row if this column value is equal 100.

Only output this row if this column value matches “test”, only the first two rows will output

parameters

You can easily access command line arguments, because they are available in the template as variables. The variable names are prefaced with ARG_ to keep them separate from any other variable names.

Now you can pass a number of reads on the command line and filter based on that value.

Now we only output sessions with nreads >0. These parameters are optional, if you don’t specify a nreads parameter on the command line, all rows will output. You can add multiple command line arguments as filters, and they will only be active when you specify them on the command line.

Lets make a parameter for the database name, user name and number of writes in our template.

Now we could filter the user sessions we output on any combination of user, database and number of writes.

ordering

You can change the ordering used to output the rows, by specifying which column of the table to order by.

This template will output in the order of the second column. Alphabetic ordering is used, unless all values in the column are numbers, then numeric ordering will be used. To reverse this order, specify a negative number.

Order this output in reverse order based on the third column.

When you specify ordering on a table, infx assumes that the first row in the table is a header row, and that all remaining rows are table rows to be sorted. You can change this in the table definition by specifying a number of lines of header or footer.

Order this table by the first column, the first two rows are headers and the last row is the footer. Sorting is only applied to the remaining rows.

To order a table with no header row, set header=0.

limits

If you still have too many rows in your table, you can specify a maximum number of rows and limit the output of a table. To do this you specify the maximum number of rows you want output. This maximum does not include any header or footer rows in the table.

Order the table by column two, and limit the output to at most the first five data rows, one header row will output by default.