Gnuplot for postfix

After wasting time with spreadsheets I decided to return back to the univeristy times and use Gnuplot.

The result was this nice script - – that monitors postfix queues and uses Little’s Law to print queues thruput. Running with -g plots immediatly the graph on your X display.

Now our gnuplot fast-track. Run #gnuplot and type

# don't have to write the file name: gnuplot uses variables ;)
f = "/tmp/data.csv"

# format graph, show grid and titles
set xlabel "time"
set key outside bottom
set ylabel "%"
set grid
set ylabel "items"
set title "Postfix Queue Stats"

# Use a logarithmic scale on y axis, so that
# we can plot graphs based on different
# units (eg. mail/sec and kB/s)
set autoscale
set log y

# Our csv has a human-readable timestamp for
# x axis, so we tell gnuplot how to read the data:
# parse a time using a given format
set xdata time
set timefmt "%d-%m-%Y %H:%M:%S"

# ...and set the x label output to be
# for our graph
set format x "%H:%M"

# the boxes in the plot should be filled
# with a 0.5 transparency factor
set style fill solid 0.5 border

# now let's plot our csv (we assigned it to the "f" variable, remember?)
# first the 3rd column (using 1:3), then the 4th and 5th
# We started at 3 because 1:1 and 1:2 are used for the x axis.
# Gnuplot columns are space-separated, and the date format contains a space
# so covers 2 column (1:1 is for the date, 1:2 for the hour)
# For each column, we set a title
# and a style (eg boxes aka histograms)
# with a color 1 (lc 1)
plot f using 1:3 title "tot" with boxes lc 1, \\
f using 1:4 title "active" with boxes, \\
f using 1:5 title "kB" with lines

Lascia un commento