Question

ok I am trying to plot graphs for a different set of datafiles (9 in total) So i created this shell script:

!/bin/bash
datastorenum=9
PlotOutputLoc=/root/bin/SANscripts/graphs
PlotGname=datastore
Pfext=png
PlotInputName=desktop
PNext=dat
PlotInputLoc=/root/bin/SANscripts/inputdata

write_plotgraph()
{
        i=1
        while [ $datastorenum != $i ]
        do
        gnuplot <<- EOF
        set term png large size 1200,1024
        set output "$PlotOutputLoc/$PlotGname-$i.$Pfext"
        set xdata time
        set timefmt '%H:%M'
        set style data lines
        set ylabel "IOs-Avg-%-kb"
        set ytics 50
        set autoscale
        set xlabel "Hour"
        plot "$PlotInputLoc/$PlotInputName-$i.$PNext" using 1:2 title "Total IOs", "$PlotInputLoc/$PlotInputName-$i.$PNext " using 1:3 title "Read %", "$PlotInputLoc/$PlotInputName-$i.$PNext" using 1:4 title "CacheHit %", "$PlotInputLoc/$PlotInputName-$i.$PNext" using 1:5 title "Current Kb/sec", "$PlotInputLoc/$PlotInputName-$i.$PNext" using 1:6 title "Maximum Kb/sec", "$PlotInputLoc/$PlotInputName-$i.$PNext" using 1:7 title "Current IO/sec", "$PlotInputLoc/$PlotInputName-$i.$PNext" using 1:8 title "Maximum IO/sec"

        i=$(( $i + 1 ))
        EOF
        done
}

write_plotgraph

It doesnt work exaclty i get bunch of this:

     line 0: warning: Skipping unreadable file "/root/bin/SANscripts/inputdata/desktop-1.dat "
     line 0: warning: Skipping unreadable file "/root/bin/SANscripts/inputdata/desktop-1.dat "
     line 0: warning: Skipping unreadable file "/root/bin/SANscripts/inputdata/desktop-1.dat "

Thanks for the help

Ok so now what about if I want to pass another function? I like this function to only graph the totalio?

write_plotTios()
{
        i=1
        while [ $datastorenum != $i ]
        do
        gnuplot <<- EOF
        set term png large size 1200,1024
        set output "$PlotOutputLoc/$PlotGname-$i-$TIOS.$Pfext"
        set xdata time
        set timefmt '%H:%M'
        set style data lines
        set ylabel "IOs-Avg-%-kb"
        set ytics 50
        set autoscale
        set xlabel "Hour"
        plot "$PlotInputLoc/$PlotInputName-$i.$PNext" using 1:2 title "Total IOs"

        EOF
        i=$(( $i + 1 ))
        done
}

write_plotTios

this doesn't work i get an error that says:

 /plot_datastore1t.sh: line 54: warning: here-document at line 37 delimited by end-of-file (wanted `EOF')
./plot_datastore1t.sh: line 55: syntax error: unexpected end of file
Was it helpful?

Solution

One of the arguments passed to the "plot" command has a trailing space following it. It's possible that this is being interpreted as part of the filename. Remove the trailing space and see if the behavior improves.

You use the construct "$PlotInputLoc/$PlotInputName-$i.$PNext" many times. You may find it less error-prone (and more readable) to store this as a variable instead of copy/pasting the same thing over and over.

Also, your code that increments the i variable is inside the script that gets passed to gnuplot. The bash variable i in never being updated, so you'll loop continuously. Try swapping your EOF and i=$(( $i + 1 )) lines.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top