# script to display the power consumption. This thing generates a plot from # data in logfiles. The result gets generated as a png file, and the script # is intended to be invoked from a higher level perl script which generates # a dynamical web page, containing this image. # Definition of core file, number of points, sampling, source directory, # target directory etc. These parameters get set via some direct input of the # calling script to adapt for things which should not be static in the # gnuplot script. For testing, uncomment the appropriate lines below. # Some directory paths # logdir="/home/chris/construction/BTUmetering/log" # imgdir="/home/chris/construction/BTUmetering/web/img" # Define the output format and size of the resulting graphic set terminal png font "DroidSansMono,11" size 800,480 set output imgdir.'/'.outfilename # define time format for input set xdata time set timefmt "%m/%d/%y %H:%M:%S" # This is the source file plus a filter for the last n entries src1='< tail -n '.num.' '.logdir.'/emeter_94529479.log' ctratio1=50; name1="MDB1" src2='< tail -n '.num.' '.logdir.'/emeter_94529480.log' ctratio2=30; name2="E-MDB1" src3='< tail -n '.num.' '.logdir.'/emeter_94529485.log' ctratio3=12; name3="EAHU1" src4='< tail -n '.num.' '.logdir.'/emeter_94529481.log' ctratio4=50; name4="MDB2" src5='< tail -n '.num.' '.logdir.'/emeter_94529484.log' ctratio5=20; name5="E-MDB2" src6='< tail -n '.num.' '.logdir.'/emeter_94529486.log' ctratio6=12; name6="EAHU2" src7='< tail -n '.num.' '.logdir.'/emeter_94529482.log' ctratio7=50; name7="MDB3" src8='< tail -n '.num.' '.logdir.'/emeter_94529487.log' ctratio8=12; name8="EAHU3" src9='< tail -n '.num.' '.logdir.'/emeter_94529483.log' ctratio9=20; name9="MDB4" src10='< tail -n '.num.' '.logdir.'/emeter_94529488.log' ctratio10=12; name10="EAHU4" src11='< tail -n '.num.' '.logdir.'/emeter_99828529.log' ctratio11=40; name11="MDB6" src12='< tail -n '.num.' '.logdir.'/emeter_99828528.log' ctratio12=12; name12="EAHU6" src13='< tail -n '.num.' '.logdir.'/emeter_38751745.log' ctratio13=12; name13="MDB3-S14" src14='< tail -n '.num.' '.logdir.'/emeter_40183481.log' ctratio14=1; name14="E-MDB3-S14" src15='< tail -n '.num.' '.logdir.'/emeter_38751742.log' ctratio15=12; name15="EAHU3-S14" # date text on this plot set format x ofmt set ylabel 'Apparent power (kVA)' set grid xtics ytics set yrange [:80] set key outside top right # Do the actual plot plot src1 every evr using 1:(($4*$7+$5*$8+$6*$9)*ctratio1/1000) \ w l lt 1 lw 2 lc rgb "#d8d800" title name1, \ src2 every evr using 1:(($4*$7+$5*$8+$6*$9)*ctratio2/1000) \ w l lt 1 lw 1 lc rgb "#d8d800" title name2, \ src3 every evr using 1:(($4*$7+$5*$8+$6*$9)*ctratio3/1000) \ w l lt 0 lw 1 lc rgb "#d8d800" title name3, \ src4 every evr using 1:(($4*$7+$5*$8+$6*$9)*ctratio4/1000) \ w l lt 1 lw 2 lc rgb "#d000d0" title name4, \ src5 every evr using 1:(($4*$7+$5*$8+$6*$9)*ctratio5/1000) \ w l lt 1 lw 1 lc rgb "#d000d0" title name5, \ src6 every evr using 1:(($4*$7+$5*$8+$6*$9)*ctratio6/1000) \ w l lt 0 lw 1 lc rgb "#d000d0" title name6, \ src7 every evr using 1:(($4*$7+$5*$8+$6*$9)*ctratio7/1000) \ w l lt 1 lw 2 lc rgb "#00ffff" title name7, \ src8 every evr using 1:(($4*$7+$5*$8+$6*$9)*ctratio8/1000) \ w l lt 1 lw 1 lc rgb "#00ffff" title name8, \ src9 every evr using 1:(($4*$7+$5*$8+$6*$9)*ctratio9/1000) \ w l lt 1 lw 2 lc rgb "#00e700" title name9, \ src10 every evr using 1:(($4*$7+$5*$8+$6*$9)*ctratio10/1000) \ w l lt 1 lw 1 lc rgb "#00e700" title name10, \ src11 every evr using 1:(($4*$7+$5*$8+$6*$9)*ctratio11/1000) \ w l lt 1 lw 2 lc rgb "#c0c0c0" title name11, \ src12 every evr using 1:(($4*$7+$5*$8+$6*$9)*ctratio12/1000) \ w l lt 1 lw 1 lc rgb "#c0c0c0" title name12, \ src13 every evr using 1:(($4*$7+$5*$8+$6*$9)*ctratio13/1000) \ w l lt 1 lw 1 lc rgb "#4040ff" title name13, \ src14 every evr using 1:(($4*$7+$5*$8+$6*$9)*ctratio14/1000) \ w l lt 1 lw 1 lc rgb "#4040ff" title name14, \ src15 every evr using 1:(($4*$7+$5*$8+$6*$9)*ctratio15/1000) \ w l lt 1 lw 1 lc rgb "#4040ff" title name15