Trend is an amazing piece of software that packs incredible amount of functionality into tiny amount of code and brief syntax. Trend is your universal live data plotter. It can work as oscilloscope and it can work as a regular strip chart plotter. It can get data from fifo or from standard input. It can read data as text or in binary form. It is almost completely configurable in runtime. In short: it is a pinnacle of software engineering, a crown of creation, an answer to all our needs and everything.
Trend can be downloaded from:
http://freshmeat.net/projects/trend
So, how does it answer our need to, say, plot the rate of data output from the cluster through our new shiny GLB 0.7.0?
To begin with we need to start "the trend" which requires reading the manual, but it is justified:
$ mkfifo /tmp/trend
$ trend -S -s -v -F -g -t 'glb' -c 2a -I 00FF00,00FFFF /tmp/trend 600
This starts trend in strip chart mode for 600 data points along the X-axis, reading text data from /tmp/trend FIFO file and expecting data coming in pairs (-c 2a) &mdash for two graphs, one will be plotted green (00FF00) and another cyan (00FFFF).
Now we make SSH tunnel to an unsuspecting glbd which runs somewhere on Amason EC2 and listens at localhost:8081:
$ssh -i id_rsa-gsg-keypair -L 0.0.0.0:8081:localhost:8081 root@ec2-79-125-57-179.eu-west-1.compute.amazonaws.com
All that is left is query glbd for stats and feed them to trend:
while [ 1 ]; do echo "getstat" | nc -q 1 192.168.0.1 8081 | cut -d '' -f 4,14,24 | (read out conns elapsed; out=$(calc $out/$elapsed/1024) conns=$(calc $conns/$elapsed*10); echo $out $conns | sed s/\~//g) ; sleep 5; done > /tmp/trend
This produces a series of two floating numbers: output data rate in Kbyte/sec, connection rate in connections/sec (times 10 to increase the scale) and feeds them to trend. And here's what we get: