forked from bjd/vnstat-php-frontend
-
Notifications
You must be signed in to change notification settings - Fork 3
export formats
Thomas Rausch edited this page Aug 26, 2020
·
1 revision
The old vnstat manual has this to say about --dumpdb:
--dumpdb
Instead of showing the database with a formated output, this
output will dump the whole database in a format that should be
easy to parse with most script languages. Use this for example
with php or perl to make a custom webpage. The dump uses ; as
field delimeter.
active;1 activity status
interface;eth0 name for the interface
nick;inet nick (if given)
created;1023895272 creation date in Unix time
updated;1065467100 when the database was updated
totalrx;569605 all time total received MB
totaltx;2023708 all time total transmitted MB
currx;621673719 latest rx value in /proc
curtx;981730184 latest tx value in /proc
totalrxk;644 total rx kB counter
totaltxk;494 total tx kB counter
btime;1059414541 system boot time in Unix time
Then follows 30 lines like the following
d;0;1078696800;559;7433;68;557;1
where d = days, 0 = day number in database (0 is today),
1077314401 date in Unix time, 559 = rx MB, 7433 = tx MB, 68 = rx
kB, 557 = tx kB and 1 tells that vnStat has filled this value
and it is in use.
m;0;1078092000;48649;139704;527;252;1 (x12)
t;0;1078351200;5979;47155;362;525;1 (x10)
h;0;1078699800;118265;516545 (x24)
m = months, t = top10 and h = hours, all other fields are in the
same order as in days except hours that doesn't have a separate
kB value. For hours the forth and fifth fields have values in
kB.
This is an example of a --dumpdb output:
vnstat --dumpdb
version;3
active;1
interface;eth0
nick;eth0
created;1341841971
updated;1366767678
totalrx;486429
totaltx;114408
currx;21163008
curtx;3586048
totalrxk;594
totaltxk;347
btime;1366765859
d;0;1366741822;33;4;891;799;1
d;1;1366671121;2203;876;89;409;1
d;2;1366569020;1707;328;682;784;1
d;3;1366482613;2569;890;248;481;1
d;4;1366396220;1633;713;380;476;1
d;5;1366309810;2200;335;584;470;1
d;6;1366248560;1718;171;172;360;1
d;7;1366137029;1899;233;673;273;1
d;8;1366077369;2401;547;893;146;1
d;9;1365964222;2223;684;286;89;1
d;10;1365877809;2462;524;65;962;1
d;11;1365791423;2154;331;701;148;1
d;12;1365705026;1202;174;384;608;1
d;13;1365618624;2638;323;445;760;1
d;14;1365532209;2138;235;289;233;1
d;15;1365445810;2939;283;931;236;1
d;16;1365359408;1805;504;950;898;1
d;17;1365273011;1738;361;637;410;1
d;18;1365186600;2161;728;548;296;1
d;19;1365100221;1987;866;130;587;1
d;20;1365013807;2487;348;999;832;1
d;21;1364927426;2994;380;102;107;1
d;22;1364841027;3194;638;748;935;1
d;23;1364754605;1587;194;532;1023;1
d;24;1364690693;2211;828;150;246;1
d;25;1364581828;1755;836;52;804;1
d;26;1364495425;2428;659;441;35;1
d;27;1364409012;2516;798;635;520;1
d;28;1364323565;2388;562;234;582;1
d;29;1364236212;2196;153;891;100;1
m;0;1364754605;50084;10682;71;34;1
m;1;1362112153;72186;22334;579;560;1
m;2;1359657017;61292;16326;179;671;1
m;3;1356978612;82875;17332;54;440;1
m;4;1354315099;50286;10261;689;981;1
m;5;1351824117;58871;16794;984;276;1
m;6;1349029819;9347;3599;132;41;1
m;7;1346437819;41958;10096;920;341;1
m;8;1343759416;32742;3679;831;684;1
m;9;1341841971;26784;3301;251;415;1
m;10;0;0;0;0;0;0
m;11;0;0;0;0;0;0
t;0;1344105023;10408;1115;265;279;1
t;1;1357065005;5807;485;647;755;1
t;2;1349029819;4426;1720;314;269;1
t;3;1362112153;5232;852;184;899;1
t;4;1362371181;5040;847;738;575;1
t;5;1347129001;4586;1268;739;794;1
t;6;1343847285;5252;528;583;174;1
t;7;1359657017;4248;1142;595;220;1
t;8;1354315099;3954;648;527;639;1
t;9;1362162617;3629;969;730;170;1
h;0;1366742542;14016;1393
h;1;0;0;0
h;2;0;0;0
h;3;0;0;0
h;4;0;0;0
h;5;0;0;0
h;6;1366766988;15059;2687
h;7;1366767678;5608;815
h;8;1366686773;92896;12176
h;9;0;0;0
h;10;0;0;0
h;11;0;0;0
h;12;1366702190;115614;46249
h;13;1366705790;113765;91096
h;14;1366709390;98634;53702
h;15;1366712990;192603;86513
h;16;1366716591;203136;80963
h;17;1366720191;213087;87053
h;18;1366723791;216805;95934
h;19;1366727391;159035;73066
h;20;1366730991;168349;85014
h;21;1366734592;196507;85331
h;22;1366738192;179376;43809
h;23;1366741792;107695;12939
The new --json output looks like this (when converted into an array using json_decode(str, TRUE):
Array
(
[vnstatversion] => 2.6
[jsonversion] => 2
[interfaces] => Array
(
[0] => Array
(
[name] => eth0
[alias] =>
[created] => Array
(
[date] => Array
(
[year] => 2017
[month] => 8
[day] => 5
)
)
[updated] => Array
(
[date] => Array
(
[year] => 2020
[month] => 8
[day] => 25
)
[time] => Array
(
[hour] => 16
[minute] => 50
)
)
[traffic] => Array
(
[total] => Array
(
[rx] => 1714875442776
[tx] => 2524910783058
)
[fiveminute] => Array
(
[0] => Array
(
[id] => 48032
[date] => Array
(
[year] => 2020
[month] => 8
[day] => 23
)
[time] => Array
(
[hour] => 16
[minute] => 0
)
[rx] => 2538730
[tx] => 2175640
)
[1] => Array
(
[id] => 48035
[date] => Array
(
[year] => 2020
[month] => 8
[day] => 23
)
[time] => Array
(
[hour] => 16
[minute] => 5
)
[rx] => 2382951
[tx] => 2550150
)
// ...
)
[hour] => Array
(
[0] => Array
(
[id] => 3930
[date] => Array
(
[year] => 2020
[month] => 8
[day] => 21
)
[time] => Array
(
[hour] => 16
[minute] => 0
)
[rx] => 35248460
[tx] => 38861073
)
[1] => Array
(
[id] => 3933
[date] => Array
(
[year] => 2020
[month] => 8
[day] => 21
)
[time] => Array
(
[hour] => 17
[minute] => 0
)
[rx] => 33368999
[tx] => 35312783
)
// ...
)
[day] => Array
(
[0] => Array
(
[id] => 63
[date] => Array
(
[year] => 2020
[month] => 6
[day] => 24
)
[rx] => 891788288
[tx] => 796843008
)
[1] => Array
(
[id] => 64
[date] => Array
(
[year] => 2020
[month] => 6
[day] => 25
)
[rx] => 1086601216
[tx] => 882546688
)
// ...
)
[month] => Array
(
[0] => Array
(
[id] => 16
[date] => Array
(
[year] => 2019
[month] => 7
)
[rx] => 41531186176
[tx] => 69598707712
)
[1] => Array
(
[id] => 17
[date] => Array
(
[year] => 2019
[month] => 8
)
[rx] => 49551489024
[tx] => 107136193536
)
// ...
)
[year] => Array
(
[0] => Array
(
[id] => 6
[date] => Array
(
[year] => 2019
)
[rx] => 273417997312
[tx] => 639350433792
)
[1] => Array
(
[id] => 7
[date] => Array
(
[year] => 2020
)
[rx] => 267876600408
[tx] => 340121624146
)
)
[top] => Array
(
[0] => Array
(
[id] => 23
[date] => Array
(
[year] => 2017
[month] => 8
[day] => 16
)
[rx] => 131920626688
[tx] => 1566385152
)
[1] => Array
(
[id] => 22
[date] => Array
(
[year] => 2020
[month] => 3
[day] => 19
)
[rx] => 31413368832
[tx] => 71637612544
)
[2] => Array
(
[id] => 21
[date] => Array
(
[year] => 2017
[month] => 9
[day] => 25
)
[rx] => 9149853696
[tx] => 75455699968
)
// ...
)
)
)
)
)
)