1, use RRDtool to establish RRD documents, to the RMB against the U.S. dollar rate every 20 seconds to crawl (SETP = 20s)
RRDtool Create usdcny.rrd\
--start ' Date +%s ' \
--step 20\
Ds:content:gauge:100:0:u\
rra:average:0:1:400
2, through Yahoo to provide exchange rate inquiries to obtain the current exchange rate, and deposited in RRD documents
#!/bin/bash
Path= '/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin '
Rrdfile= '/TMP/361WAY/USDCNY.RRD '
While True
Todo
timestamp= ' Date +%s '
Rmbrate= ' curl ' http://download.finance.yahoo.com/d/quotes.csv?s=USDCNY=X&f=sl1d1t1&e=.csv ' 2>/dev/ null | Awk-f, ' {print $} '
RRDtool Update $rrdfile ${timestamp}:${rmbrate}
Sleep 19
Echo ' Get Now '
Done
3. Use PHP script to show RMB exchange rate RRD chart
# Cat Rmb.php
<?php
Header ("Content-type:image/png");
$cmd = '
/usr/bin/rrdtool Graph-\
-H 120-w 500\
--start now-1h\
-V "RMB/USD"--title "RMB-USD Rate" \
Def:rmbrate=/tmp/361way/usdcny.rrd:content:average\
LINE:RMBRATE#00CF00FF: "RMB Rate" \
COMMENT: "\ n"
';
PassThru ($cmd);
?>
The effect chart is as follows: