tw_query
The tw_query utility enables you to extract data using a query. The information can be output in CSV or XML format using one of the available arguments.
To use the utility, type the following command at the $TIDEWAY/bin/ directory:
where:
- query is the data you want to extract from the Search service.
- options are any of the options described in the following table and the common command line options described in Using-command-line-utilities.
Command Line Option | Description |
---|---|
--csv | The output of the query is saved in .CSV format |
--delimiter=CHAR | Specifies the delimiter character used in .CSV files |
--destroy | Marks all of the nodes returned by the query as deleted. |
--file=FILE | Specifies the name of the .CSV output file |
--filedump | Dump to files specified in first column |
--no-headings | Do not output column headings |
--search=NAME | Specifies the name of the search service |
--time | Reports the time taken to perform the query |
--xml | Specifies that the output of the query will be saved in .XML format |
User examples
The following user examples show basic usage, marking a named host as destroyed, and results written to a CSV file. The commands are entered on a single line, but broken here to help readability.
Basic usage
"SEARCH Host WHERE os_type = 'CentOS Linux' ORDER BY name SHOW name, os_version"
Password for BMC Discovery UI user system:
Host
====
name os_version
---- ----------
ais-netlogdr-01 6.8
bacon.internal.calbnet.com 6.8
clm-ais-002331 6.4
clm-ais-002332 6.4
clm-pun-sr7he8 7.4.1708
clm-pun-sr7hep 7.4.1708
clm-pun-sr7hfp 7.4.1708
clm-pun-sr7hgq 7.4.1708
mcr-netlogpr-01.calbro.com 6.7
mcr-tubedpr-01.calbro.com 7.3.1611
[tideway@appliance01 ~]$
Marking a named host node as destroyed
"SEARCH Host WHERE name = 'bacon.internal.calbnet.com'"
Password for BMC Discovery UI user system:
WARNING: Use of this tool can lead to data instability and unexpected
system behavior. If you are at all unsure about the consequences of this
action, you should contact customer support in advance.
1 node will be marked as destroyed in the data store.
Are you sure? (y/n) n
Nothing destroyed.
[tideway@appliance01 ~]$ tw_query --destroy
"SEARCH Host WHERE name = 'bacon.internal.calbnet.com'"
Password for BMC Discovery UI user system:
WARNING: Use of this tool can lead to data instability and unexpected
system behavior. If you are at all unsure about the consequences of this
action, you should contact customer support in advance.
1 node will be marked as destroyed in the data store.
Are you sure? (y/n) y
Destroying 1 Host node...
Destroyed 1 Host node.
[tideway@appliance01 ~]$
Results output to CSV file
"SEARCH Host WHERE os_type = 'CentOS Linux' ORDER BY name SHOW name, os_version"
Password for BMC Discovery UI user system:
[tideway@appliance01 ~]$ more /usr/tideway/tmp/centoshosts.csv
name,os_version
ais-netlogdr-01,6.8
clm-ais-002331,6.4
clm-ais-002332,6.4
clm-pun-sr7he8,7.4.1708
clm-pun-sr7hep,7.4.1708
clm-pun-sr7hfp,7.4.1708
clm-pun-sr7hgq,7.4.1708
mcr-netlogpr-01.calbro.com,6.7
mcr-tubedpr-01.calbro.com,7.3.1611
[tideway@appliance01 ~]$