Saturday 22 August 2015

Using gnuplot for trend analysis

I was looking for a simple tool to draw trend info for data collected from my servers, i have been using cacti effectively and it is serving me quite well, still i need to be able to run some ad-hoc graphs from time to to time.
I came across gnuplot and didn't consider using it, but now, i found those 3 great resources that will change my apporache:

http://linux.byexamples.com/archives/487/plot-your-graphs-with-command-line-gnuplot/

http://people.duke.edu/~hpgavin/gnuplot.html

Those 2 articles made it very easy for me to understand the tool and be able to use its demos at:

http://gnuplot.sourceforge.net/demo_4.6/


below is my test script:

test.data:

#month reading consumption
1   700          830
2   1120         1125
3   1400         1400
4   1790         1750
5   2100         2150
6   2450         2455
7   2900         2910
8   3210         3230
9   3300         3350
10  3780         3785
11  4090         4110
12  4550         4640
13  4550         4950
14  4550         5350









test.gp:

reset
set terminal png


#set xdata time
#set timefmt "%d/%m/%Y %H:%M:%S"
#set format x "%H:%M"
set xlabel "Month #"

set ylabel "Monthly Reading"
#set yrange [0:31]

set title "M7YC Performance per Month"
#set key reverse Left outside
set key bottom center outside
#set key bottom horizontal center outside
set grid

#set style data linespoints
#set style data impulses
#set style data boxes
set style data histogram
set style histogram cluster gap 2
set style fill solid border 0
set boxwidth 1


#Plot with different patterns in one command
#plot "./test.data" using 1:2 title "Monthly Reading" with linespoints, \
#"" using 1:3 title "Actual consumption" with boxes

#Plot with style setting
#plot "./test.data" using 1:2 title "Monthly Reading" , \
#"" using 1:3 title "Actual consumption"



#Plot a histo
plot "./test.data" using 2 title "Monthly Reading" , \
"" using 3 title "Actual consumption"


#




The above have a lot of potential to generate png graphs that can be embeded in HTML pages and serve as needed.
Also we can customize the graphs and use shell scripting to tune and manipulate the script and the data dynamically.

will explore more about this and post the works . .




No comments:

Post a Comment