create a utility
You can create your own utilities by building a template and using the infx status command to output it.
template
Templates should be created under the /infx/local/template directory.
You can create sub-directories there as needed, the whole tree is searched.
You can also create a template by using one of the existing templates as a starting point.
For example, to make changes to the infx status output, copy the template from /infx/template to /infx/local/template and make changes.
The infx status command will use your local template from now on.
database list
By way of example, we will create a utility to list the databases.
First, create the template.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
<table> <tr> <td>database</td> <td>space</td> <td>owner</td> <td>created</td> <td>flags</td> <td>log</td> <td>buff</td> <td>ansi</td> </tr> <TMPL_LOOP NAME=DB_LIST> <tr> <td><TMPL_VAR NAME=NAME></td> <td><TMPL_VAR NAME=DBSPACE></td> <td><TMPL_VAR NAME=OWNER></td> <td><TMPL_VAR NAME=CREATED></td> <td><TMPL_VAR NAME=HFLAGS></td> <td><TMPL_VAR NAME=IS_LOGGING></td> <td><TMPL_VAR NAME=IS_BUFF_LOG></td> <td><TMPL_VAR NAME=IS_ANSI></td> </tr> </TMPL_LOOP> </table> |
output it
Output the template using the status command:
1 2 3 4 5 |
$ infx status util=databases database space owner created flags log buff ansi monitor_jgh1 dat01 informix 11/26/2010 0xFFFFD001 1 0 0 sqltest dat01 informix 12/09/2010 0xFFFFD001 1 0 0 sysadmin root informix 12/01/2010 0xFFFFD021 1 0 0 |
alias it
If you want to execute this command often, define an alias for it by editiing config.ini.
Now, you execute the infx dbs command to get the list of databases.
1 2 3 4 5 |
$ infx dbs database space owner created flags log buff ansi monitor_jgh1 dat01 informix 11/26/2010 0xFFFFD001 1 0 0 sqltest dat01 informix 12/09/2010 0xFFFFD001 1 0 0 sysadmin root informix 12/01/2010 0xFFFFD021 1 0 0 |
ordering
Add tags to the table template to allow ordering by different columns
This is a two step process:
- modify the databases template to allow table ordering
- change the alias definition to allow the order parameter to be passed.
template
Make the change to our databases template, where the table is defined.
Arguments passed to the command are in the template as variables, with ARG_ prepended to the name. So ARG_ORDER will be set to the value of the order= parameter from the command line. If no parameter is passed, no re-ordering will occur.
alias
Change the alias definition so that the dbs command can accept the order parameter.
If you omit this step, the CLI will not accept the order paramter.
You can now pass the name of a column in the order parameter, and change the order the list outputs in.
example
1 2 3 4 5 |
$ infx dbs order=database database space owner created flags log buff ansi sysadmin root informix 12/01/2010 0xFFFFD021 1 0 0 sqltest dat01 informix 12/09/2010 0xFFFFD001 1 0 0 monitor_jgh1 dat01 informix 11/26/2010 0xFFFFD001 1 0 0 |
filter parameters
You can modify the template to allow for filtering rows in the output. It is a similar process to above.
template
First, change the template to specify the filters.
In this case the space parameter will filters the space column.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
... <TMPL_LOOP NAME=DB_LIST> <tr> <td><TMPL_VAR NAME=NAME></td> <td match=<TMPL_VAR NAME=ARG_SPACE>><TMPL_VAR NAME=DBSPACE></td> <td><TMPL_VAR NAME=OWNER></td> <td><TMPL_VAR NAME=CREATED></td> <td><TMPL_VAR NAME=HFLAGS></td> <td><TMPL_VAR NAME=IS_LOGGING></td> <td><TMPL_VAR NAME=IS_BUFF_LOG></td> <td><TMPL_VAR NAME=IS_ANSI></td> </tr> </TMPL_LOOP> |
alias
Add the space parameter to the allowed options in the alias definition:
example
Filter the output based on storage space name:
1 2 3 4 |
$ infx dbs space=dat01 database space owner created flags log buff ansi monitor_jgh1 dat01 informix 11/26/2010 0xFFFFD001 1 0 0 sqltest dat01 informix 12/09/2010 0xFFFFD001 1 0 0 |
more information
Utilities can only output information about an instance. If you want to do more you need to create a script for that.
The template reference describes the template definitions.
The parser library reference lists the variables available in the templates.