CFmt.exe


Description

This program provides general utility by formatting a BMC Defender stream of messages into text, html, xml, or csv format.  This can simplify the formatting of message records, such as when appending data to an e-mail message or creating a web method to BMC Defender Server data. 

Note

The program requires a BMC Defender message stream as input, and does not format messages piped from the Cpars.exe program or other non-BMC Defender Server message source.

Usage and Syntax

Usage:type (infile) | cfmt.exe "(opts)"
Also:   cfmt.exe -file (infile) "(opts)"

Opts:  -text
Opts:  -tblock
Opts:  -html
Opts:  -xml
Opts:  -json
Opts:  -csv[N]

Arguments

-file

This argument, if it exists, is the input file to process. The input file must be followed by a valid (infile) argument, that is the pathname of the file to process. If this option is omitted, the CFmt program reads standard input and writes the matched results to standard output.

(infile)

This argument must follow the -infile argument, and is the full or relative pathname of the file to process.

(opts)

This argument is one of the format options. Exactly one format option can be used, immediately following the CFmt.exe program invocation. (See options below.)

-text

This option formats the input into a list of text messages, where each message is followed by a blank line, and begins with the message record number, in #nnnnn format. (This format is found within the BMC Defender Server Reports > E-Mail screen.

-tblock (or –block)

This option formats the input into a list of records where each record is the field name followed by the value, followed by a newline. This is similar (but not identical) to JSON format. Each record is separated by a newline. (This format is found within the BMC Defender Server Reports > Audit > Text Report screens.)

-html

This option formats the input into a list of records where each record an HTML table entry. The resulting output is suitable for use as an HTML report, and contains the report header and JavaScript controls. (This format is found within the BMC Defender Server Reports > Audit > HTML Report screens.)

-xml

This option formats the input into a list of records where each record is an XML entry, The result is a well-formed XML document, that can be used as a web method rather easily (by using the command in a .bat file that produces the correct headers, executed as a CGI program.)

-json

This option formats the input into a list of records where each record is a JSON formatted entry, The result is a well-formed JSON document suitable for use with Java and other programming languages.

-csv[N]

This option formats the input into a list of records where each record is a correct comma separated value format. The resulting output can be redirected to a file and then opened with Microsoft Excel or another reader. (This format is found within the BMC Defender Server Reports > Audit > CSV Report screens.)

Note

The optional [N] qualifier can limit the columns of output (such as by executing -csv2, that creates two columns of output.) 


Application

The CFmt.exe program is commonly used as the final step of a pipeline, necessary to format messages for reporting. The program accepts as input a raw list of messages (such as that produced by the Cat functions described elsewhere.)

Note

The CFmt.exe program requires a BMC Defender message stream to operate correctly. If a message is received from standard input (or from within a file) the message must begin with a valid ISO date, such as 2018/01/01, and must contain the date, time, device, severity, severity, and message content in that order. Otherwise, the input line is bypassed and not included in the standard output.

Examples
REM: Format log messages residing in myfile.txt.
REM: The contents of the file should be CorreLog
REM: style log messages, i.e. ISO date time,
REM: device, severity, severity, and message
REM: content.

CFmt.exe –file myfile.txt -text

REM: Format the log data into a csv report suitable
REM: for use with Excel.

type my.log | CFmt.exe –csv > rept.csv

REM: Same as above, but using the < redirect operator.
REM: This is essentially the same as above,

CFmt.exe –csv < my.log > rept.csv

REM: Format the log data into CSV format using a long
REM: pipeline. CSV output is limited to four columns.

CatMsg my.txt | CExpr.exe "security" | CFmt.exe -csv4

REM: Format the log data into an HTML report suitable
REM: for display by a web browser. The messages are
REM: listed (to a maximum of 10,000 lines) by the
REM: CLI utility "CatMsg.exe", discussed elsewhere.

CatMsg.exe –maxcount 10000|Cfmt.exe –html > rept.html

REM: Format the log data into XML, including a CGI
REM: header.
echo Content-type: text/xml
echo.
type *.log|CFmt.exe –xml > page.xml

REM: Format the log data into messages that can be
REM: displayed easily in notepad.

type \correlog\logs\*.log | CFmt.exe –tblock > msg.txt

Related topic

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*