I have a data file of the following format:
servername,2013-05-11 17:46:03,SomeText,195,195,11,202
servername,2013-05-11 17:47:03,SomeText,192,192,23,103
servername,2013-05-11 17:48:03,SomeText,189,190,14,117
servername,2013-05-11 17:49:03,SomeText,196,195,24,231
...
...
I want to plot a graph where the x-axis has the time (%H:%M:%S) values (don't need the date part. The y-axis should have the two last columns.
Here's a sample bash script I have to run this.
#!/usr/bin/bash
basedir="app-stats"
termsize="1200,600"
xtics="1800"
type="proc"
range="*:"
echo $server-$filenm.data
gnuplot -persist << EOF
reset
set terminal pngcairo size ${termsize} enhanced font 'Verdana,8'
set xdata time
set timefmt "%Y/%m/%d %H:%M:%S'"
set format x "%H:%M:%S"
set datafile separator ","
set xtics nomirror rotate
set xtics ${xtics}
set ytics nomirror
set y2tics
set grid xtics lt 0 lw 1 lc rgb "#000000"
set grid ytics lt 0 lw 1 lc rgb "#880000"
set grid y2tics lt 0 lw 1 lc rgb "#008800"
set ylabel 'servername'
set y2label 'proc'
set auto fix
set offsets graph 0, graph 0, graph 0.1, graph 0
show offsets
set title "App Statistics for ${host}" enhanced font 'Verdana Bold,10'
set label "Date: 02/07/13" at screen 0.01, 0.97
set label "SomeLabel" at screen 0.98, 0.97 right
set key inside center bottom horizontal Right noreverse enhanced autotitles box linetype -1 linewidth 1.000
set output "$server-$filenm.png"
plot '$server-$filenm.data' using 1:6 title 'proc/s' with lines lt rgbcolor "light-red" lw 2, \
'$server-$filenm.data' using 1:7 axes x1y2 title 'cswch/s' with lines lt rgbcolor "blue" lw 2
EOF
exit
I can plot this successfully if the time data doesn't contain "date space time" but only time and the server name isn't the first field (see below).
17:46:03,SomeText,195,195,11,202
17:47:03,SomeText,192,192,23,103
...
...
My questions are:
-
Can I have a non-xdata column before the xdata column like "servername" and identify where the xdata column is in the "using (1:6)" statement, substituting 1:6 with say, 3:6 if the xdata column is the third column? I'm not able to get this to work.
-
If the first column is
2013-05-11 17:46:03
, how can I get it to plot correctly using either
set timefmt "%Y/%m/%d %H:%M:%S'"
set format x "%H:%M:%S"
or
set timefmt "%Y/%m/%d %H:%M:%S'"
set format x "%Y/%m/%d %H:%M:%S"
Cheers,
Beery