Use RRDtool to monitor RMB exchange rate in Linux

Source: Internet
Author: User
Tags php script rrd rrdtool


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:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.