Gnuplot in bash

Hi,

I want a graph plot using gnuplot for df -h command.

like filesystem, total size and avail size.

Thanks,
Anjan

---------- Post updated at 02:35 PM ---------- Previous update was at 02:34 PM ----------

I want a graph plot using gnuplot for df -h command per hour.

I suggest you find a demo that is close to what you want. You should also familiarize yourself with the gnuplot language. Here is a sample...
gnuplot demo script: gantt.dem

Yes I am looking at gnuplot. I have installed and checking. If you help that will be good.

Firstly your going to need to collect hourly usage data into a datafile, cron is probably the best way perhaps something like this:

for filesystem in var usr tmp
do
   df -Pm /$filesystem | awk -v d=$(date date '+%Y/%m/%d %T') 'NR==2{print d,$3,$4}' OFS="\t" >> /usr/lib/${filesystem}_disk_data
done

Once you have your data you can use gnuplot to produce the grap, below is an example for the var datafile:

#!/usr/bin/gnuplot

set terminal png font "helvetica"
set output 'var_graph.png'

# For pdf output (requires ps2pdf) replace with below
# set terminal postscript landscape color
# set output '| ps2pdf - var_usage.pdf'

set title "Var filesystem usage over Time"
set timestamp "Last updated: %m/%d/%Y, %H:%M" top

set xlabel "Date (mm/yy)"
set timefmt "%Y/%m/%d %H:%M"
set xdata time
set format x "%m/%Y"

set ylabel "GB"
set yrange [ 0 : ]

set key left
set grid
set datafile separator "\t"

show variables

plot '/usr/lib/var_disk_data'     using 1:2 t 'Used' with lines

That is impressively quick.