落絮飞雁的个人网站

顺流而下,把梦做完

Use API to monitor IDCF data transfer usage

IDCF is a large enterprise which provides VPS service at an affordable price in Japan. It provides 3TB data transfer for free each month, Extra transfer fee should be paid after exceed the free plan. So it’s a wise choice to balance the data transfer from the different zone.

Firstly, let’s clarify this free plan: When you set up a VPS, there are three different regions available for selection(east JP1, east JP2, and west JP), each region has several zones which named by physical units, like Pascal, Henry, or Joule (all of them in the east JP1 region), all zone list here. After you choose the region you want. Each zone has 3,240GB (almost 3TB) data transfer (transfer in AND transfer out) per month. So we need to calculate all VPS from the same region, add inbound transfer and outbound transfer altogether.

You can enable a new zone in zone management panel. You can select zone by yourself when you launch a new Virtual Machine. One IDCF account can launch up to 20 VMs.

Fortunately, IDCF provides enormous API with a detailed doc. Although it is written in Japanese but contains a large number of English words, So docs can be read without translation. There’s two API about the Internet Data Transfer: listUsageRecords and list_billing_detail. I used the later one in my project.

Firstly, you need to get your own API in the user panel, refer the official example to make a request.

My code(written in Python3):

Collect data from json result, and use it in your own project. In addition, IDCF also provide CLI and cloudstack-api. You also can get data via those tools.

 

REF:


原文转自:Use API to monitor IDCF data transfer usage|落絮飞雁的个人网站
授权协议:创作共用 署名-非商业性使用 2.5 中国大陆
除注明外,本站文章均为原创;转载时请保留上述链接。