GNU Plot Basics with XEN metrics

Grabbing the Metrics

Say that you want to get a plot against XEN guests activity, from a XEN host.

cd /data/guests/
xl create load1/load1
xl create load2/load2
xl create load3/load3

Three seconds is the default delay for xentop to deliver the metrics. And we usually get rid of the first metric, either because the percentage is zero or because we need to substract the overall count from the previous iteration. So during one minute,

mkdir -p /var/tmp/xentop/
cd /var/tmp/xentop/
rm -f xentop*
(( time = 0 )); until (( time >= 60 )); do (( time++ )); echo -n "$time "; sleep 1; done &
xentop -f -b -i$(( 60 / 3 + 1 )) > xentop
unset time

to help your stress the guest in due time,

stress --help
date
nice stress --cpu 16

Grab each guest’s metrics in a separate file,

for guest in load1 load2 load3; do
    egrep "^[[:space:]]*$guest " xentop > xentop.$guest
    wc -l xentop.$guest
done; unset guest

Taking CPU(sec), not CPU(%), we need to substract the values from the previous iteration,

vi convertcpu

#!/bin/ksh
[[ -z $1 ]] && print what guest? && exit 1
guest=$1
(( sec = 0 ))
for time in `awk '{print $3}' xentop.$guest`; do
        (( diff = time - timeold ))
        print "$sec\t$diff"
        (( sec = sec +3 ))
        timeold=$time
done; unset cputime

chmod +x convertcpu

As a result you get the time on the first col, and CPU(sec) on the second col.

for guest in load1 load2 load3; do
    ./convertcpu $guest | sed 1d > table.$guest
done; unset guest

Note. we are removing the first line from those tables, as its diff would not make any sense.

Delivering the Plot

#apt install gnome-themes-standard
#gnome-themes-extra

vi script.gp

set term png
set output "output.png"

set title "load1,2,3 vcpu usage"
set xlabel "60 seconds"
set ylabel "vcpu times"
set xrange [0:60]
set yrange [0:35]

set multiplot

set key at 60,35
plot "table.load1" title "load1" smooth csplines lt 1

set key at 60,34
plot "table.load2" title "load2" smooth csplines lt 2

set key at 60,33
plot "table.load3" title "load3" smooth csplines lt 3

gnuplot -c script.gp

Interactive use

Other useful commands,

reset
replot

Other nice terminals,

#set term pdf mono
#set output "output.pdf"

Check for avaiable terminals,

set term

References

Plotting Data with gnuplot https://www.cs.hmc.edu/~vrable/gnuplot/using-gnuplot.html

GNUPLOT 4.2 - A Brief Manual and Tutorial https://web.archive.org/web/20190616032406/https://people.duke.edu/~hpgavin/gnuplot.html

output formats

Output terminals http://www.gnuplotting.org/output-terminals/

multiple graphs

gnuplot plotting multiple line graphs https://stackoverflow.com/questions/10792015/gnuplot-plotting-multiple-line-graphs

smooth lines

How to output smooth cspline curve as a data file https://stackoverflow.com/questions/30474631/how-to-output-smooth-cspline-curve-as-a-data-file

examples

Library – Gnuplot Examples http://www2.yukawa.kyoto-u.ac.jp/~akira.ohnishi/Lib/gnuplot.html

gnuplot Frequency Plot http://psy.swansea.ac.uk/staff/carter/gnuplot/gnuplot_frequency.htm

design

Gnuplot line types https://stackoverflow.com/questions/19412382/gnuplot-line-types

gnuplot demo script: lines_arrows.dem http://gnuplot.sourceforge.net/demo/lines_arrows.html

Linetypes, colors, and styles http://www.bersch.net/gnuplot-doc/linetypes,-colors,-and-styles.html

Gnuplot Line Styles for Display and Printing https://jblevins.org/log/lines

15 Linetype, colors, and styles http://www.gnuplot.info/docs_4.2/gnuplot.html#x1-6200015 http://gnuplot.sourceforge.net/docs_4.2/node62.html

linestyle http://www.gnuplotting.org/tag/linestyle/

Multiple lines with different colors http://www.gnuplotting.org/multiple-lines-with-different-colors/

more

Gnuplotting http://www.gnuplotting.org/

Library – Gnuplot Examples https://www2.yukawa.kyoto-u.ac.jp/~akira.ohnishi/Lib/gnuplot.html

1.17.2 linestyles vs linetypes http://soc.if.usp.br/manual/gnuplot-doc/htmldocs/linestyles_005fvs_005flinetypes.html

How to plot a bar graph on Gnuplot http://ask.xmodulo.com/plot-bar-graph-gnuplot.html


HOME | GUIDES | LECTURES | LAB | SMTP HEALTH | HTML5 | CONTACT
Copyright © 2024 Pierre-Philipp Braun