hi jeff,

what i noticed with that url.. it just updated every hour... 5 minutes
after an hour is already good enough... that script is idempotent...
meaning if you run several times on the same hour.. it will give you
the same results....

yes... ive been relocated here in the US (home of MIT and Harvard)...
good thing not in finland because salary there is too low compare to
singapore and china (my previous work countries) when it comes to net
income... but singapore is still the best place to work in my
opinion..

in 3 to 5 years time.. ill be retiring as a technical guy and totally
shift career to as a business man (as my business in the philippines
is growing exponentially)... at that time... i dont work for money
anymore and i'll let the money work for me while enjoying the beauty
of our home country...

fooler.


On Sun, Apr 5, 2015 at 9:29 AM, Cayab, JE <[email protected]> wrote:
> hi fooler,
>
> good to see you around!
>
> isn't every 5 mins is */5? I'm talking about the cron entry
>
> how you been? you've been relocated again?
>
> On Fri, Apr 3, 2015 at 12:07 PM, fooler mail <[email protected]> wrote:
>>
>> On Thu, Apr 2, 2015 at 12:48 AM, Roberto Verzola <[email protected]>
>> wrote:
>> >
>> > So the software we need has to do something like this:
>> > - download the PDF or CSV Luzon file from WESM every 3-5 mins after the
>> >   hour
>> > - add the target megawatts as a red horizontal line
>> > - generate the jpeg/png graph.
>> > - upload to server for mirroring/download by everyone else.
>> >
>> >
>> > PS. A peaceful Holy Week to you Mr. fooler! Maybe your extraordinary
>> > programming expertise can help in this activity.
>> >
>>
>> ok here is a bash script (also file attached) to make your holy week
>> more peaceful...
>>
>> you need the following:
>>
>> 1) yum -y install curl
>> 2) yum -y install gnuplot
>>
>> $ cat -n wesm.sh
>>      1  #!/bin/bash
>>      2
>>      3  #Target in MegaWatts
>>      4  TARGET=4500
>>      5
>>      6  DATE=`date +%Y%m%d`
>>      7  HOUR=`date +%H`
>>      8  DATETITLE=`date +"%b %d, %Y"`
>>      9  CSVFILE=$DATE$HOUR.csv
>>     10  PNGFILE=$DATE$HOUR.png
>>     11
>>     12  curl -s
>>
>> "http://www.wesm.ph/chart/export/luzon_dmd_csv_export.php?date=$DATE&hour=$HOUR";
>> | head -n 25 | tail -n 24 | awk -F ',' -v OFS=', ' -v "target=$TARGET"
>> '{print $1,target,$2,$3,$4,$5,$6,$7}' > $CSVFILE
>>     13
>>     14  gnuplot << EOF
>>     15  set output "$PNGFILE"
>>     16  set terminal png nocrop font small size 640,480
>>     17  set xtics 1
>>     18  set key outside center bottom Left reverse
>>     19  set style data linespoints
>>     20  set title "Luzon Market Demand (MW) - $DATETITLE"
>>     21  set xlabel "HOURS"
>>     22  set ylabel "MEGAWATT"
>>     23  plot "$CSVFILE" using 1:2 title 'Target', "$CSVFILE" using 1:3
>> title 'Day Ahead Projection (DAP)', "$CSVFILE" using 1:4 title 'Hour
>> Ahead Projection (RTD)', "$CSVFILE" using 1:5 title 'Current Demand
>> (RTX)'
>>     24  EOF
>>
>> at line 4, change the TARGET to whatever megawatt your desired value....
>>
>> at line 12, is the one fetching and reformatting the output and
>> inserted the "TARGET" value at column 2 for gnuplot to be able to
>> understand the format...
>>
>> at line 14, gnuplot is the one creating the graph....
>>
>> when you run that command.. it will create two files:
>>
>> 1) YYYYMMDDHH.csv
>> 2) YYYYMMDDHH.png
>>
>> where:
>>
>> YYYY - year in 4 digits
>> MM - month in 2 digits
>> DD - day in 2 digits
>> HH - hour in 2 digits
>>
>> change the file permission to executable (eg. chmod 700 wesm.sh) and
>> then run (eg. ./wesm.sh)
>>
>> if you run on the next hour... it will create another set of two files
>> because of line 6 and 7...
>>
>> if you want to automate the fetching... put it in cron job...
>>
>> eg.
>>
>> 5 * * * * /path/to/wesm.sh
>>
>> the above line it will fetch 5 minutes after an hour...
>>
>> make sure you set your PATH and default folder properly in your cron
>> job to run curl and gnuplot properly or modify the script to have an
>> absolute path...
>>
>> feel free to modify the script to suit your needs and  feel free to
>> asks questions if you need further help as im pretty sure our experts
>> here in plug will be happy to assist you...
>>
>> fooler.
>>
>> _________________________________________________
>> Philippine Linux Users' Group (PLUG) Mailing List
>> http://lists.linux.org.ph/mailman/listinfo/plug
>> Searchable Archives: http://archives.free.net.ph
>
>
>
>
> --
> jef
>
> _________________________________________________
> Philippine Linux Users' Group (PLUG) Mailing List
> http://lists.linux.org.ph/mailman/listinfo/plug
> Searchable Archives: http://archives.free.net.ph
_________________________________________________
Philippine Linux Users' Group (PLUG) Mailing List
http://lists.linux.org.ph/mailman/listinfo/plug
Searchable Archives: http://archives.free.net.ph

Reply via email to