Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions config/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ type OptionsType struct {

Printer string `short:"p" long:"printer" description:"the output printer to use (valid printers: ncurses, text, json)" default:"ncurses"`

Output string `short:"o" long:"output" description:"the output channel to send printer output (valid output: stdout, file, tcp, udp)" default:"stdout"`
OutputTarget string `long:"target" description:"for output 'file' the location, for 'tcp' or 'udp' the url (host:port) to the server"`
Output string `short:"o" long:"output" description:"the output channel to send printer output (valid output: stdout, file, tcp, udp)" default:"stdout"`
OutputTarget string `long:"target" description:"for output 'file' the location, for 'tcp' or 'udp' the url (host:port) to the server"`
OutputTargetTruncate bool `long:"targettruncate" description:"for output 'file' the target will only contain the latest result (can be used for prometheus json exporter)"`

NetworkDevice string `long:"netdev" description:"The network device used for the virtual traffic"`
StorageDevice string `long:"storedev" description:"The storage device used for the virtual block devices"`
Expand Down
8 changes: 8 additions & 0 deletions runners/printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ func InitializePrinter(wg *sync.WaitGroup) {

// Print runs one printing cycle
func Print() {
if config.Options.Output == "file" && config.Options.OutputTargetTruncate {
err := os.Truncate(config.Options.OutputTarget, 0)
if err != nil {
fmt.Fprintf(os.Stderr, "failed to truncate the output file")
os.Exit(1)
}
}

printable := models.Printable{}

// add general domain fields first
Expand Down