#!/usr/bin/perl
use strict;
use warnings;
use LWP;
use URI::Escape;
use JSON;
use Time::Local;
my $lwpua = LWP::UserAgent->new;
my $url="https://api.iijmio.jp/mobile/d/v1/log/packet/";
my $developerid="<DeveloperID>";
my $usertoken ="<アクセストークン>";
my $lwpreq = HTTP::Request->new(GET => "$url");
$lwpreq->header("X-IIJmio-Developer" => "$developerid");
$lwpreq->header("X-IIJmio-Authorization" => "$usertoken");
my $lwpres= $lwpua->request($lwpreq);
my $data = decode_json($lwpres->content);
for(my $i=0;$i<@{$data->{packetLogInfo}};$i++){
#print $i . ":" . $data->{packetLogInfo}->[$i]->{hddServiceCode} ."\n";
my $hddServiceCode=$data->{packetLogInfo}->[$i]->{hddServiceCode};
for(my $j=0;$j<@{$data->{packetLogInfo}->[$i]->{hdoInfo}};$j++){
#print $i . "-" . $j . ":" . $data->{packetLogInfo}->[$i]->{hdoInfo}->[$j]->{hdoServiceCode} . "\n";
my $hdoServiceCode=$data->{packetLogInfo}->[$i]->{hdoInfo}->[$j]->{hdoServiceCode};
if(! -f "$hdoServiceCode.rrd"){
print "rrdtool create $hdoServiceCode.rrd --start 1384786740 --step 86400 DS:withCoupon:GAUGE:86400:0:U DS:withoutCoupon:GAUGE:86400:0:U RRA:LAST:0.5:1:100000 \n";
system("rrdtool create $hdoServiceCode.rrd --start 1384786740 --step 86400 DS:withCoupon:GAUGE:86400:0:U DS:withoutCoupon:GAUGE:86400:0:U RRA:LAST:0.5:1:100000");
}
for(my $k=0;$k<@{$data->{packetLogInfo}->[$i]->{hdoInfo}->[$j]->{packetLog}};$k++){
#print " " . $data->{packetLogInfo}->[$i]->{hdoInfo}->[$j]->{packetLog}->[$k]->{date} ;
#print ":" . $data->{packetLogInfo}->[$i]->{hdoInfo}->[$j]->{packetLog}->[$k]->{withCoupon} ;
#print ":" . $data->{packetLogInfo}->[$i]->{hdoInfo}->[$j]->{packetLog}->[$k]->{withoutCoupon} ;
#print "\n";
my $d=$data->{packetLogInfo}->[$i]->{hdoInfo}->[$j]->{packetLog}->[$k]->{date};
my $year = substr($d,0,4);
my $mon = substr($d,4,2) - 1;
my $mday = substr($d,6,2);
my $unixtime = timelocal(0,59,23,$mday,$mon,$year);
my $withCoupon=$data->{packetLogInfo}->[$i]->{hdoInfo}->[$j]->{packetLog}->[$k]->{withCoupon};
my $withoutCoupon=$data->{packetLogInfo}->[$i]->{hdoInfo}->[$j]->{packetLog}->[$k]->{withoutCoupon};
print "rrdtool update $hdoServiceCode.rrd $unixtime:$withCoupon:$withoutCoupon \n";
system("rrdtool update $hdoServiceCode.rrd $unixtime:$withCoupon:$withoutCoupon");
}
}
}
これを「get.pl」というファイル名で保存します。
実行すると、「hdo810xxxxx.rrd」というような感じのファイルがSIMカード分作成されます。
なお、手抜きをしているので、2回目以降は、同じ値を入力しようとし、「ERROR: hdo8371xxxx.rrd: illegal attempt to update using time 1387378740 when last update time is 1387378740 (minimum one second step)」みたいなエラーがでてしまいますが、仕様です。
また、rrdtoolは一度登録した情報の更新ができない構造をしているので、日付が変わる直前に実行することを推奨します。
osakanataro@ubuntu:/work/B2G$ ./repo list abi/cpp
abi/cpp : platform/abi/cpp
osakanataro@ubuntu:/work/B2G$ ./repo info abi/cpp
error: manifest required for this command -- please run init
Manifest branch: sprdroid4.0.3_vlx_3.0_b2g
Manifest merge branch: master
Manifest groups: all,-notdefault
----------------------------
Project: platform/abi/cpp
Mount path: /work/B2G/abi/cpp
Current revision: sprdroid4.0.3_vlx_3.0_b2g
osakanataro@ubuntu:/work/B2G$
abi/cpp関連で怪しそうな情報をfind/grepで探してみる。
osakanataro@ubuntu:/work/B2G/.repo/projects/abi/cpp.git$ cat config
[core]
repositoryformatversion = 0
filemode = true
[user]
email = osakanataro@~
[remote "sprd"]
url = http://sprdsource.spreadtrum.com:8085/b2g/platform/abi/cpp
projectname = platform/abi/cpp
fetch = +refs/heads/*:refs/remotes/sprd/*
osakanataro@ubuntu:/work/B2G/.repo/projects/abi/cpp.git$ cat FETCH_HEAD
6426040f1be4a844082c9769171ce7f5341a5528 branch 'ics-factoryrom-2
-release' of http://sprdsource.spreadtrum.com:8085/b2g/platform/abi/cpp
6426040f1be4a844082c9769171ce7f5341a5528 branch 'ics-mr0' of http
://sprdsource.spreadtrum.com:8085/b2g/platform/abi/cpp
6426040f1be4a844082c9769171ce7f5341a5528 branch 'ics-mr0-release'
of http://sprdsource.spreadtrum.com:8085/b2g/platform/abi/cpp
6426040f1be4a844082c9769171ce7f5341a5528 branch 'ics-mr1' of http
://sprdsource.spreadtrum.com:8085/b2g/platform/abi/cpp
6426040f1be4a844082c9769171ce7f5341a5528 branch 'ics-mr1-release'
of http://sprdsource.spreadtrum.com:8085/b2g/platform/abi/cpp
6426040f1be4a844082c9769171ce7f5341a5528 branch 'ics-plus-aosp' o
f http://sprdsource.spreadtrum.com:8085/b2g/platform/abi/cpp
eb789ea833d8d800662b67914d9c1785a58c2caa branch 'jb-dev' of http:
//sprdsource.spreadtrum.com:8085/b2g/platform/abi/cpp
eb789ea833d8d800662b67914d9c1785a58c2caa branch 'jb-release' of h
ttp://sprdsource.spreadtrum.com:8085/b2g/platform/abi/cpp
eb789ea833d8d800662b67914d9c1785a58c2caa branch 'master' of http:
//sprdsource.spreadtrum.com:8085/b2g/platform/abi/cpp
6426040f1be4a844082c9769171ce7f5341a5528 branch 'tools_r20' of ht
tp://sprdsource.spreadtrum.com:8085/b2g/platform/abi/cpp
22e70042effef3aca9526d3e22f63eac23de782e not-for-merge tag 'FIREFOXOS_t
esttwo' of http://sprdsource.spreadtrum.com:8085/b2g/platform/abi/cpp
a858064180600aed773e7b5e365b43e872dc119d not-for-merge tag 'FIREFOXOS_v
osakanataro@ubuntu:/work/B2G/.repo/projects/abi/cpp.git$ cat FETCH_HEAD
6426040f1be4a844082c9769171ce7f5341a5528 branch 'ics-factoryrom-2-release' of http://sprdsource.spreadtrum.com:8085/b2g/platform/abi/cpp
6426040f1be4a844082c9769171ce7f5341a5528 branch 'ics-mr0' of http://sprdsource.spreadtrum.com:8085/b2g/platform/abi/cpp
6426040f1be4a844082c9769171ce7f5341a5528 branch 'ics-mr0-release' of http://sprdsource.spreadtrum.com:8085/b2g/platform/abi/cpp
6426040f1be4a844082c9769171ce7f5341a5528 branch 'ics-mr1' of http://sprdsource.spreadtrum.com:8085/b2g/platform/abi/cpp
6426040f1be4a844082c9769171ce7f5341a5528 branch 'ics-mr1-release' of http://sprdsource.spreadtrum.com:8085/b2g/platform/abi/cpp
6426040f1be4a844082c9769171ce7f5341a5528 branch 'ics-plus-aosp' of http://sprdsource.spreadtrum.com:8085/b2g/platform/abi/cpp
eb789ea833d8d800662b67914d9c1785a58c2caa branch 'jb-dev' of http://sprdsource.spreadtrum.com:8085/b2g/platform/abi/cpp
eb789ea833d8d800662b67914d9c1785a58c2caa branch 'jb-release' of http://sprdsource.spreadtrum.com:8085/b2g/platform/abi/cpp
eb789ea833d8d800662b67914d9c1785a58c2caa branch 'master' of http://sprdsource.spreadtrum.com:8085/b2g/platform/abi/cpp
6426040f1be4a844082c9769171ce7f5341a5528 branch 'tools_r20' of http://sprdsource.spreadtrum.com:8085/b2g/platform/abi/cpp
22e70042effef3aca9526d3e22f63eac23de782e not-for-merge tag 'FIREFOXOS_testtwo' of http://sprdsource.spreadtrum.com:8085/b2g/platform/abi/cpp
a858064180600aed773e7b5e365b43e872dc119d not-for-merge tag 'FIREFOXOS_v1.2_W13.42.4' of http://sprdsource.spreadtrum.com:8085/b2g/platform/abi/cpp
755b7feb3226223f6b77377a5e748e1ac47cfbd4 not-for-merge tag 'android-4.0.1_r1' of http://sprdsource.spreadtrum.com:8085/b2g/platform/abi/cpp
6e21cf94291ff0ff67ead081e907b21c46b74075 not-for-merge tag 'android-4.0.1_r1.1' of http://sprdsource.spreadtrum.com:8085/b2g/platform/abi/cpp
9bf3f8b31fc175df486596ae123d4416321cc8c4 not-for-merge tag 'android-4.0.1_r1.2' of http://sprdsource.spreadtrum.com:8085/b2g/platform/abi/cpp
a4f468880c7d2058fed25e19a90ad288c6d22925 not-for-merge tag 'android-4.0.2_r1' of http://sprdsource.spreadtrum.com:8085/b2g/platform/abi/cpp
1f7abe1dd3a3d37f7c852aa877c576f3cdb4a042 not-for-merge tag 'android-4.0.3_r1' of http://sprdsource.spreadtrum.com:8085/b2g/platform/abi/cpp
1613612046aeadcad431fbea9e056685904f93a1 not-for-merge tag 'android-4.0.3_r1.1' of http://sprdsource.spreadtrum.com:8085/b2g/platform/abi/cpp
437e3997ed5275a19b7e2cf3b130c765c791c9b9 not-for-merge tag 'android-4.0.4_r1' of http://sprdsource.spreadtrum.com:8085/b2g/platform/abi/cpp
0a03a7b231c2ae0529e22c8c7604d44f7e3f3e68 not-for-merge tag 'android-4.0.4_r1.1' of http://sprdsource.spreadtrum.com:8085/b2g/platform/abi/cpp
711142b99de01e9129dec2cc7325315e54996d10 not-for-merge tag 'android-4.0.4_r1.2' of http://sprdsource.spreadtrum.com:8085/b2g/platform/abi/cpp
00d1d44867ab708d09f7259b29ddfe8ab57008d7 not-for-merge tag 'android-4.0.4_r2' of http://sprdsource.spreadtrum.com:8085/b2g/platform/abi/cpp
dd924f92906085b831bf1cbbc7484d3c043d613c not-for-merge tag 'android-4.0.4_r2.1' of http://sprdsource.spreadtrum.com:8085/b2g/platform/abi/cpp
e98b9655ab62adbdc22f7acbe083dbec8ee32c29 not-for-merge tag 'android-4.1.1_r1' of http://sprdsource.spreadtrum.com:8085/b2g/platform/abi/cpp
54d67e380f48d003d8922c17908adc192b375d02 not-for-merge tag 'android-4.1.1_r1.1' of http://sprdsource.spreadtrum.com:8085/b2g/platform/abi/cpp
e519a423ee05d3f3c66e530264626504d66cb7d4 not-for-merge tag 'android-4.1.1_r2' of http://sprdsource.spreadtrum.com:8085/b2g/platform/abi/cpp
a0ea794ba309c907492e3a4f8da80f604bc6e1ce not-for-merge tag 'android-4.1.1_r3' of http://sprdsource.spreadtrum.com:8085/b2g/platform/abi/cpp
ea461d03727143eb07764870765948a0eca9c0a8 not-for-merge tag 'android-cts-4.0.3_r1' of http://sprdsource.spreadtrum.com:8085/b2g/platform/abi/cpp
c9afdbb55d6ea53b805341ea2dcbffac816483f3 not-for-merge tag 'android-cts-4.0.3_r2' of http://sprdsource.spreadtrum.com:8085/b2g/platform/abi/cpp
b97e7e49feba85359a8770d731cf4817b31ff1ad not-for-merge tag 'android-cts-4.0_r1' of http://sprdsource.spreadtrum.com:8085/b2g/platform/abi/cpp
6bee6a867b7ede626161d81419166b5e6a0c1239 not-for-merge tag 'android-cts-verifier-4.0.3_r1' of http://sprdsource.spreadtrum.com:8085/b2g/platform/abi/cpp
4d171d013d1230af6b2ec7d35b63b2abc05c46df not-for-merge tag 'android-cts-verifier-4.0_r1' of http://sprdsource.spreadtrum.com:8085/b2g/platform/abi/cpp
5ddf451125b935e18a6ef60c753a483293790091 not-for-merge tag 'android-sdk-4.0.3-tools_r1' of http://sprdsource.spreadtrum.com:8085/b2g/platform/abi/cpp
460f661655dc22d49a03ab841c60dc7740041740 not-for-merge tag 'android-sdk-4.0.3_r1' of http://sprdsource.spreadtrum.com:8085/b2g/platform/abi/cpp
6c842d709146619646cb4e38e0f6d6ad8b7d7601 not-for-merge tag 'android-sdk-adt_r16.0.1' of http://sprdsource.spreadtrum.com:8085/b2g/platform/abi/cpp
117d9f9e9275b88650f0465776b859d982f591f2 not-for-merge tag 'android-sdk-adt_r20' of http://sprdsource.spreadtrum.com:8085/b2g/platform/abi/cpp
osakanataro@ubuntu:/work/B2G/.repo/projects/abi/cpp.git$