Wednesday, November 23, 2011

More trickery with gnuplot dumb terminal

In my post "Plotting memory usage on console" the chart doesn't panned the data.
Now, using a named pipe, the effect got a little bit nicer.
First we have to run the script to get a file filled with memory usage info:
./ > memUsage.dat &
Then we have to create a named pipe:
mkfifo pipe
Now we have to run another process to tail only the last 64 lines from the memUsage.dat
while [ 1 ]; do tail -64 memUsage.dat> pipe; done &
And now we just have to plot the data from the pipe:
watch -n 1 'gnuplot -e "set terminal dumb;p \"pipe\" with lines"'
And that is it!


  1. An even better effect can be achieved using:
    "unset border"
    "unset xtics"
    "unset ytics"
    and plotting with notitle
    as follows
    watch -n 1 'gnuplot -e "set terminal dumb;unset border; unset xtics;unset ytics;p \"pipe\" with impulses notitle"'

  2. No need to run the second process! You can simply run gnuplot and pass the following file "< tail -64 memUsage.dat"