You can create your own template and output it using the infx status service.
The template reference describes the template definitions, The parser library reference lists all the values available for output.
In this example I will create a template to output the list of databases for an instance. The information available about databases is here: db list.
<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>bob001@bobii:/home/informix>infx status util=databasesdatabase space owner created flags log buff ansimonitor_jgh1 dat01 informix 11/26/2010 0xFFFFD001 1 0 0sqltest dat01 informix 12/09/2010 0xFFFFD001 1 0 0sysadmin root informix 12/01/2010 0xFFFFD021 1 0 0define an aliasIf you want to execute this command often, you can define an alias for it in config.ini.[[alias alias="dbs" cmd="status util="databases"]]Now, you execute the "dbs" service and get the list of databases.
bob001@bobii:/home/informix>infx dbsdatabase space owner created flags log buff ansimonitor_jgh1 dat01 informix 11/26/2010 0xFFFFD001 1 0 0sqltest dat01 informix 12/09/2010 0xFFFFD001 1 0 0sysadmin root informix 12/01/2010 0xFFFFD021 1 0 0order parameterThe template table format allows you to re-order the table.
This is a two step process:
Make the highlighted change to our databases template, where the table is defined.
<table order=<TMPL_VAR NAME=ARG_ORDER>>Arguments passed to the command are available 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. Change the alias definition so that the dbs command can accept the order parameter, otherwise the CLI will raise an error.
[[ alias alias="dbs" cmd="status" util="databases" opt="order" ]]You can now pass the name of a column in the order parameter, and change the order the list outputs in.
bob001@bobii:/home/informix>infx dbs order=databasedatabase space owner created flags log buff ansisysadmin root informix 12/01/2010 0xFFFFD021 1 0 0sqltest dat01 informix 12/09/2010 0xFFFFD001 1 0 0monitor_jgh1 dat01 informix 11/26/2010 0xFFFFD001 1 0 0filter parametersThe template table format also allows you to filter rows. This is a similar two step process as ordering above.
First, change the template to specify the filters to be applied:
...<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>...
Add the space option to the alias definition:
[[ alias alias="dbs" cmd="status" util="databases" opt="order space" ]]You can now filter the output based on the space name:
bob001@bobii:/home/informix>infx dbs space=dat01database space owner created flags log buff ansimonitor_jgh1 dat01 informix 11/26/2010 0xFFFFD001 1 0 0sqltest dat01 informix 12/09/2010 0xFFFFD001 1 0 0
Utilities can only output information about an instance. If you want to take actions based on the information, you create custom scripts for that. |
