The FlowTraq Command Line Interface (CLI) provides an easy way for custom scripts and third party applications to query FlowTraq Server for flow information.

The CLI tools are installed with FlowTraq Server in the /path/to/flowtraq/clitools directory.

[Tip]Tip

The CLI tools, like the client, connect to FlowTraq Server via 9640/tcp. You don't have to run the CLI tools from the host on which you installed FlowTraq Server.

To retrieve raw session records, use the ftsq command.

For example, the following invocation of ftsq returns all records in the last hour to HTTP servers with a client address that is outside the 123.45.67.89 class-C block, in CSV format with a header line:


The ftsq commands accepts a wide range of parameters. Some are optional and some are required.

You should always specify a FlowTraq Server to log in to (or accept the default, localhost), supply a username and password, and select a timeframe over which to perform your query (or accept the default, which is the last 15 minutes).

Optionally, you may supply a filter string to further narrow your query, and you may specify a preference for how you would like the command's output formatted.

Most of the parameters are self-explanatory, but timeframe specification and the filter string syntax are described in depth in Section 3.2.3, “Time Navigation” and Section 3.2.4, “Filter String Syntax”. First, however, please review the complete list of parameters:





[Important]Important

Note that the -snd and -rcv parameters are not applicable to the ftsq command, since rankings are not generated when returning raw session records. Use these parameters in conjunction with ftstat, as described below.


[Important]Important

Note that the -w parameter is not applicable to the ftsq command, since there is no accompanying time series for raw session records. Use this parameter in conjunction with ftstat, as described below.

[Important]Important

Note that the -g, -gx, and -gy parameters are not applicable to the ftsq command, since there is no accompanying stack graph for raw session records. Use these parameters in conjunction with ftstat, as described below.

All data retrieval commands accept an optional filter string. The filter string is used to select which sessions to include in the retrieval.

Filter strings consist of statements, such as SRVIP==123.45.67.89 ("server IP address is 123.45.67.89") and CLNPKTS>=100 ("number of client-transmitted packets is at least 100"), which may be combined using logical operators.

You can combine statements using the following logical operators:

For example: SRVIP==123.45.67.89 && CLNIP==89.67.45.123 .

[Tip]Tip

You can build compound statements and specify precedence by using parentheses. For example, you might use:

(SRVPORT==22 && SRVIP==123.45.67.89) || (SRVIP==89.67.45.123)

to specify all sessions which are either connections on port 22 to 123.45.67.89, or connections on ANY port to 89.67.45.123.

Statements are formed by combining field names (such as SRVIP) with comparators (such as ==) and values to compare them to. The following lists the available comparators and field names.

Table 3.6. Filter String Fields

FieldDescriptionValid Comparators
SRVIP server IP (or CIDR), IPv4: 123.45.67.89/32, or IPv6: fed9::c0:ffee/128 ==, !=
CLNIP client IP (or CIDR), same as SRVIP ==, !=
ADDR IP or CIDR block ==, !=
SRVPORT server port, integer number ==, !=, >=, <=, >, <
CLNPORT client port, integer number ==, !=, >=, <=, >, <
PORT port, integer number ==, !=, >=, <=, >, <
PROTO protocol, one of TCP/UDP/ICMP, or integer number ==, !=, >=, <=, >, <
CLNPKTS number of client transmitted packets, integer number ==, !=, >=, <=, >, <
SRVPKTS number of server transmitted packets, integer number ==, !=, >=, <=, >, <
PACKETS match either of the packet fields (server or client), integer number ==, !=, >=, <=, >, <
TOTPKTS total packets (server plus client), integer number ==, !=, >=, <=, >, <
CLNBYTS number of client transmitted bytes, integer number ==, !=, >=, <=, >, <
SRVBYTS number of server transmitted bytes, integer number ==, !=, >=, <=, >, <
BYTES match either of the bytes fields (server or client), integer number ==, !=, >=, <=, >, <
TOTBYTS total bytes (server plus client), integer number ==, !=, >=, <=, >, <
TTIME total time of session, floating point, in seconds: 2.5 ==, !=, >=, <=, >, <
TOS ToS, QoS, DiffServ, integer number 0-256 ==, !=, >=, <=, >, <
CLNCC client country code, two characters: 'US', 'NL' ==, !=
SRVCC server country code, same as client country code ==, !=
INIF inbound interface, integer number 0-65536 ==, !=, >=, <=, >, <
OUTIF outbound interface, integer number 0-65536 ==, !=, >=, <=, >, <
IFACE match either of the interface fields (inbound or outbound), integer number 0-65536 ==, !=, >=, <=, >, <
INVLAN inbound VLAN, integer number 0-4096 ==, !=, >=, <=, >, <
OUTVLAN outbound VLAN, integer number 0-4096 ==, !=, >=, <=, >, <
VLAN match either of the VLAN fields (inbound or outbound), integer number 0-4096 ==, !=, >=, <=, >, <
CLNAS client autonomous system number, integer number ==, !=, >=, <=, >, <
SRVAS server autonomous system number, integer number ==, !=, >=, <=, >, <
ASN match either of the autonomous system number fields (server or client), integer number ==, !=, >=, <=, >, <
ASAEVT ASA event code, integer number ==, !=, >=, <=, >, <
ASAEXTEVT ASA extended event code, integer number ==, !=, >=, <=, >, <
FLAGS TCP flags in session, one of: 'FSYN' (syn), 'FACK' (ack), 'FRST' (reset), 'FFIN' (fin), 'FPSH' (push), 'FECN' (ECN-echo), 'FCWR' (congestion window reduced), 'FURG' (urgent) ==, !=
EXPIP IP of the device that exported the record ==, !=
EXPV flow version, use: 1, 5, 7, 9 (NetFlow v1/5/7/9), 18, 20, 21 (sFlow v2/4/5) ==, !=

The FlowTraq Statistical Query Retrieval command ftstat creates tables and graphs of grouped items that are ranked by some criterion. For example, you can retrieve the list of hosts that sent the most packets during a given timeframe or the list of hosts that received the most packets during the same. You can also find out which port/application accounted for the most bytes on your network, find which host pair exchanged the most bytes, and more.

It is also possible to score by more complex criteria. For instance, it is possible to find the list of hosts that contacted the largest number of unique hosts, or the list of countries that contacted your servers on the largest number of unique server ports.

As with the ftsq command, you must specify a FlowTraq Server to connect to, supply login details, select a timeframe and (optionally) specify a filter. And like ftsq, the results are returned in a formatted table, by default, or in CSV format (use either the -c option for CSV without a header, or the -c+ option for CSV with a header line). Please refer to the complete list of parameters in Section 3.2.2, “Retrieving Raw Session Data from the Command Line with ftsq, Section 3.2.4, “Filter String Syntax” for more information on the filter language syntax, and Section 3.2.3, “Time Navigation” for information on timeframe specifications.

Where the usage of ftstat differs from that of ftsq is in specifying the desired statistic to calculate. Specify the statistic by using the -grp and -cnt paramaters:


[Tip]ftstat Example 1

To retrieve the top 25 hosts by bytes sent in the last week, use the following command:

[Tip]ftstat Example 2

To retrieve the five host-pairs that communicated over the largest number of ports during last five hours, use the following command:

[Tip]Tip

You may use the -g parameter to request the accompanying stack graph, and the -gx and -gy parameters to specify the size of the graph you would like.

[Tip]Tip

You may use the -w parameter to request a timeseries for each row of the table.

The session key reauthentication mechanism allows for FlowTraq's command line tools to be easily integrated with third-party applications and applications hosted on other systems. The use of session keys allows automated scripts and script-based interfaces such as web GUIs to call additional command line tools without the need to store the username and password in a client-side cookie. Since the session key automatically expires, and is only valid from the originating IP address, it is unnecessary to perform an explicit "log out."

[Important]Default Timeout 30 Minutes

The FlowTraq server daemon times session keys out automatically after they have not been used for 30 minutes. Additionally, session keys will only be accepted from the IP address that generated the session key. To change this default behavior, please refer to the Administration Section of this manual.

To create and use a session key, a command line tool must first provide a valid user's credentials to log into a session, and provide the -us parameter to request that a session key be created. Any command will work, but ftum is convenient because it doesn't need to interact with session data, so we use it in our example:

			ftum -un USERNAME -up PASSWORD -us
		

If the credentials provided are valid, the stderr output of the command will be a session key; for example:

			91389bd1127bce0a2615d390be08f696
		

The session key may subsequently used with the -us argument instead of a username/password combination to re-login to the same FlowTraq Server from the same IP address. Continuing our example:

			ftstat -us 91389bd1127bce0a2615d390be08f696 [...]
		
[Tip]Tip

Each time the session key is used, the timer is reset. The session key will eventually expire on the server side after the period of time specified in the userdata/maxsessionkeyage configuration parameter.