how to ...

custom utilities

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>

Output the template using the status service

bob001@bobii:/home/informix>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

define an alias

If 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 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

order parameter

The template table format allows you to re-order the table.

This is a two step process:
  1. modify the databases template to allow table ordering
  2. change the alias definition to allow the order parameter to be passed.
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=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

The 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=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

See the template reference for a complete list of filters that can be applied.

Utilities can only output information about an instance. If you want to take actions based on the information, you create custom scripts for that.