LinuxCommandLibrary

ttyplot

Plot data from standard input in terminal

TLDR

Plot the values 1, 2 and 3 (Note: cat prevents ttyplot from exiting)

$ { echo [1 2 3]; cat; } | ttyplot
copy

Set a specific title and unit
$ { echo [1 2 3]; cat; } | ttyplot -t [title] -u [unit]
copy

Use a while loop to continuously plot random values
$ { while [true]; do echo [$RANDOM]; sleep [1]; done } | ttyplot
copy

Parse the output from ping and visualize it
$ ping [8.8.8.8] | sed -u '[s/^.*time=//g; s/ ms//g]' | ttyplot -t "[ping to 8.8.8.8]" -u [ms]
copy

SYNOPSIS

ttyplot [OPTIONS]

PARAMETERS

-h
    Displays a help message and exits.

-c
    Enables compact mode, reducing vertical plot space.

-r
    Sets the refresh rate in Hertz (Hz). Default is 10 Hz.

-u
    Specifies a unit string to display on the Y-axis.

-s
    Applies a numerical scale factor to input data before plotting. Default is 1.0.

-m
    Sets a fixed minimum value for the Y-axis.

-M
    Sets a fixed maximum value for the Y-axis.

-t
    Sets a custom title for the plot.

-b
    Defines the number of samples to keep in the buffer and display on screen. Default is 1000.

-A
    Forces always auto-scale for the Y-axis, overriding any -m or -M settings.

-J
    In multi-value input mode, joins points with lines instead of discrete points.

-B
    Sets the background character used for the plot area. Default is '.'.

-F
    Sets the foreground character used for plotting the data points. Default is '#'.

-C
    Enables color output for the plot.

-g
    Draws grid lines on the plot.

DESCRIPTION

ttyplot is a lightweight command-line utility designed for plotting real-time numerical data directly in your terminal. It reads numerical input from standard input (stdin) and renders it as a scrolling ASCII art graph. It's particularly useful for monitoring system metrics, network activity, or any continuous stream of numerical values generated by other commands like vmstat, iostat, ping, or custom scripts. ttyplot automatically scales the Y-axis by default, and allows customization of refresh rate, plot title, units, and appearance (colors, characters). Its simplicity and low resource usage make it an excellent tool for quick, live visualizations without needing a graphical environment.

CAVEATS

  • Input Format: ttyplot strictly expects numerical input on stdin. Non-numerical data will be ignored or can cause unexpected behavior.
  • Terminal Size: The plot's appearance and visible buffer size are limited by the width and height of the terminal window.
  • Resource Usage: While generally light, very high refresh rates with large buffer sizes can consume more CPU and memory, especially for complex, multi-value plots.
  • No History Saving: The plots are real-time and ephemeral; there's no built-in way to save or export the plotted data or graph for later analysis.

COMMON USAGE PATTERNS

ttyplot is most commonly used in conjunction with other Linux commands that output continuous streams of numerical data. Users typically pipe the output of commands like vmstat, iostat, or ping through text processing tools like awk or sed to extract the desired numerical column(s) before feeding them into ttyplot.

Example: vmstat 1 | awk '{print $15}' | ttyplot -t "Idle CPU %" -u "%" -C

Example for multiple values: vmstat 1 | awk '{print $13, $14}' | ttyplot -t "CPU User/System" -C -J

MULTI-VALUE PLOTTING

If ttyplot receives multiple space-separated numerical values on a single line of input, it will plot each value as a separate line on the graph. This allows for simultaneous visualization of related metrics.

SEE ALSO

gnuplot(1), vmstat(8), iostat(1), netstat(8), ping(8), awk(1), sed(1)

Copied to clipboard