ttyplot – a real time plotting utility for the terminal

(This is a guest post from Antoni Sawicki aka Tenox)

I spend most of time in a day staring at a terminal window often running various performance monitoring tools and reading metrics.

Inspired by tools like gtop, vtop and gotop I wished for a more generic terminal based tool that would visualize data coming from unix pipeline directly on the terminal. For example graph some column or field from sar, iostat, vmstat, snmpget, etc. continuously in real time.

Yes gnuplot and several other utilities can plot on terminal already but none of them easily read data from stdin and plot continuously in real time.

In just couple of evenings ttyplot was born. The utility reads data from stdin and plots it on a terminal with curses. Simple as that. Here is a most trivial example:

To make it happen you take ping command and pipe the output via sed to extract the right column and remove unwanted characters:

ping | sed -u 's/^.*time=//g; s/ ms//g' | ttyplot 

Ttyplot can also read two inputs and plot with two lines, the second being in reverse-video. This is useful when you want to plot in/out or read/write at the same time.

A lot of performance metrics are presented in as a “counter” type which needs to be converted in to a “rate”. Prometheus and Graphana have rate() or irate() function for that. I have added a simple -r option. The time difference is calculated automatically. This is an example using snmpget which is show in screenshot above:

{ while true; do snmpget -v 2c -c public{10,16}.9 | gawk '{ print $NF/1000/1000 }'; sleep 10; done } | ttyplot -2 -r -u "MB/s"

I now find myself plotting all sorts of useful stuff which otherwise would be cumbersome. This includes a lot of metrics from Prometheus for which you normally need a web browser. And how do you plot metrics from Prometheus? With curl:

{ while true; do curl -s | grep "^node_load1 " | cut -d" " -f2; sleep 1; done } | ttyplot

If you need to plot a lot of different metrics ttyplot fits nicely in to panels in tmux, which also allows the graphs to run for longer time periods.

Of course in text mode the graphs are not very precise, but this is not the intent. I just want to be able to easily spot spikes here and there plus see some trends like up/down – which works exactly as intended.I do dig fancy braille line graphs and colors but this is not my priority at the moment. They may get added later, but most importantly I want the utility to work reliably on most operating systems and terminals. 

You can find compiled binaries here and source code and examples to get you started – here.

If you get to plot something cool that deserves to be listed as an example please send it on!

VAX Snoopy!

Hey Snoopy!

Hey Snoopy!

Following up on Adventures with Snoopy, Mihai has delivered!  Snoopy printed out from a VAX onto a real 9 pin printer, onto paper!

Just the way we used to do things a million years ago!

Be sure to check out the whole thing on,  complete with pictures, and source material!  Totally check it out, for that real programmer’s vibe!

And for those who have no idea, here is where it all started.

Virtual Printers

So I got this SPAM today.. Ebay now tracks if you’ve clicked on anything (even when not signed in) and will alert you (and the seller no doubt) that something is price reduced.

Ebay at it's worst.

Ebay at it’s worst.

I was looking at some old setup, and I remembered back in the 80s I had an Okimate 10 printer.  It was without a doubt the worst printer I’ve ever used.  Not only was it god awfully slow, it required special ink cartridges that were almost impossible to find (and if you did they were very expensive) but to print properly it required special glossy paper.

The 10's test page

The 10’s test page

And if you hit the wrong button on the printer, you’d get this fabulous test page. Over and over. Ugh.  It banded a full Yellow/Magenta/Cyan stripe on every pass.  If you got 10 pages out of a ribbon it was amazing.  But on my nostalgic trip to remember how badly this printer sucked, I found a Virtual OkiMate 20!  It’s a javascript program of all things, that’ll interpret the graphics output of an OkiMate 20 dump file.

Test file from an Amiga

Test file from an Amiga

The test image is a picture from an Amiga Workbench.  It’s immediately recognizable.  But what is really cool, if you scroll down you’ll see something like this:

How the Oki works

How the Oki works

And here you can see how the OkiMate 20 was busy devouring a colour band from it’s virtual cartridge.

Peter has quite a few virtual printers on his blog, The one that caught my eye was the Epson JX-80.  Windows NT supports that printer (probably many other OS’s but I was going to stick with something quick and easy).  I took my 10 crash screen, and printed it out!

Printing from Windows NT 4.0 at 120x144

Printing from Windows NT 4.0 at 120×144

Pretty cool!

For some reason the printer emulator only is printing in monochrome, it’ll interpret the colour bands, but it doesn’t switch ink colours.  I guess it automagically is doing that.  Also I had to change the default Windows resolution of 144×240 to 144×120, to get it to print.

Of course if you wanted to the best thing to do is install an Apple Laser Write II printer, and have it output to a file, as they are PostScript printers.  Then you can use ghostscript to convert your postscript file to a PDF, and print that email it, or remember what a pain write only devices are.

As an update you can download all of the printer emulators from the authors blog

Printing within Qemu

For a while I was unsure of the syntax of printing from within Qemu. I know for the Xenix crowd this is kind of ‘a big deal’. Along with more serial ports for consoles & stuff…

Anyways for the printer I found an example on line, and it’s quite easy:

qemu xenix_hard_disk.vhd -parallel file:lpt1: -M isapc -m 16 -k en-us

Now I’ve seen it actually spool stuff to the printer once the emulator is exited… I’m sure there is some way to kick these jobs better… I’ve also been trying to keep it as dumb as possible and there is a chance my HP printer /scanner thing doesn’t talk like a 1970’s style printer.. I’ll know more tomorrow..

But at the moment this should serve enough to get people started. Also you could redirect the parallel port out to a file, and then open that file in say word and print from there as well.
This is becoming a bigger deal now that future versions of Virtual PC no longer support things like parallel ports, floppy disks & sound blasters…. Qemu will be the only out for a few people.