- Remove weekly output
- Remove merge of data from multiple interfaces to one output
- Remove --testkernel
+ - Remove --exportdb, use --oneline, --json or --xml instead
- Remove --importdb, -u / --update and related options using vnstat command
- Remove old style (default in versions up to 1.7) summary layout in
image output
* possibly more beta than seen with recent 1.x releases
* has been tested so far mainly in 24/7 running servers
* vnstatd (daemon) has all features implemented
- * some sanity checks may be missing or disabled
+ * some sanity checks may be missing
* vnstat (console output) has most features implemented
* vnstati (image output) has all intended original features implemented
* 5 minute resolution outputs available in both text and image formats
* `MonthRotate` configuration option
* kernel test
* provided some use mostly with 2.0 and 2.2 kernels
- * `--update` / `-u` using vnstat command
+ * `--update` / `-u` and several other database modifiers using vnstat command
+ * `--exportdb`, use `--oneline`, `--json` or `--xml` instead
* old style (default in versions up to 1.7) summary layout in image output
##### TODO
* decide if output type parameters should be renamed
* currently `-h` results in a graph style output when everything else gives a list
* `-h` to output list and have `-hg` (or similar) for the hourly graph?
- * decide if some outputs should be removed
- * `--exportdb` has now a different format which already breaks compatibility, `--json` and `--xml` still available
* documentation
* especially feature comparison with 1.x versions is needed as some features have been left out
* remember what else has been forgotten from this list
# output style
# 0 = minimal & narrow, 1 = bar column visible
-# 2 = same as 1 except rate in summary and weekly
+# 2 = same as 1 except rate in summary
# 3 = rate column visible
OutputStyle 3
Sampletime 5
# default query mode
-# 0 = normal, 1 = days, 2 = months, 3 = top10
-# 4 = exportdb, 5 = short, 6 = weeks, 7 = hours
+# 0 = normal, 1 = days, 2 = months, 3 = top, 5 = short
+# 7 = hours, 8 = xml, 9 = one line, 10 = json
QueryMode 0
# filesystem disk space check (1 = enabled, 0 = disabled)
] [
.B \-\-debug
] [
-.B \-\-exportdb
-] [
.B \-\-fiveminutes
.I count
.B \-\-help
.B "-D, --debug"
Show additional debug output.
-.TP
-.B "--exportdb"
-Instead of showing the database with a formatted output, this output will
-dump the whole database in a plain text based architecture independent format.
-Using the output for scripting is possible but the outputs of
-.B "--xml"
-and
-.B "--json"
-are likely to be more suitable. The dump uses ; as field delimiter.
-.TS
-l l.
- active;1 activity status
- interface;eth0 name for the interface
- alias;localnet alias (if given)
- created;1023895272 creation date in Unix time
- updated;1065467100 when the database was updated
- totalrx;569605 all time total received bytes
- totaltx;2023708 all time total transmitted bytes
- currx;621673719 latest interface counter rx value
- curtx;981730184 latest interface counter tx value
- btime;1059414541 system boot time in Unix time
-.TE
-
-Then follows lines like the following
-
- d;1;1078696800;559;7433
-
-where d = days, 1 = day index number in database, 1077314401 date in
-Unix time, 559 = rx bytes, 7433 = tx bytes.
-.TS
-l l.
- m;1;1078092000;48649;139704
- t;1;1078351200;5979;47155
- h;1;1078699800;118265;516545
- y;1;1483221600;4647879954;389902437
-.TE
-
-m = months, t = top, h = hours and y = years, all other fields are in the same order as in days.
-
.TP
.BI "-5, --fiveminutes " count
Show traffic statistics on a 5 minutes resolution for the last hours. The length of the list
.I number
to 0 for a more narrow output, 1 for enabling bar column, 2
for same as previous but with average traffic rate visible in summary
-and weekly outputs and 3 for enabling average traffic rate in all
-outputs where it is supported. 4 disables the use of terminal control
-characters in
+output and 3 for enabling average traffic rate in all outputs where it is
+supported. 4 disables the use of terminal control characters in
.B "-l / --live"
mode.
Modify the content and style of text outputs. 0 = minimal and
narrow output for terminal with limited width, 1 = normal output with
bar column visible, 2 = same as 1 except rate is visible in summary
-and weekly outputs, 3 = rate column is visible in all outputs where it
-is supported. (vnstat and vnstati only)
+output, 3 = rate column is visible in all outputs where it is supported.
+(vnstat and vnstati only)
.TP
.B QueryMode
Default query mode when no parameters are given. 0 = normal, 1 = days,
-2 = months, 3 = top10, 4 = exportdb, 5 = short, 6 = weeks, 7 = hours and
-8 = xml. (vnstat only)
+2 = months, 3 = top, 5 = short, 7 = hours, 8 = xml, 9 = one line
+and 10 = json. (vnstat only)
.TP
.B RateUnit
printf("# output style\n");
printf("# 0 = minimal & narrow, 1 = bar column visible\n");
- printf("# 2 = same as 1 except rate in summary and weekly\n");
+ printf("# 2 = same as 1 except rate in summary\n");
printf("# 3 = rate column visible\n");
printf("OutputStyle %d\n\n", cfg.ostyle);
printf("Sampletime %d\n\n", cfg.sampletime);
printf("# default query mode\n");
- printf("# 0 = normal, 1 = days, 2 = months, 3 = top10\n");
- printf("# 4 = exportdb, 5 = short, 6 = weeks, 7 = hours\n");
+ printf("# 0 = normal, 1 = days, 2 = months, 3 = top, 5 = short\n");
+ printf("# 7 = hours, 8 = xml, 9 = one line, 10 = json\n");
printf("QueryMode %d\n\n", cfg.qmode);
printf("# filesystem disk space check (1 = enabled, 0 = disabled)\n");
/* output style */
/* 0 = minimal/narrow, 1 = bars everywhere */
-/* 2 = same as 1 + rate in summary and weekly */
+/* 2 = same as 1 + rate in summary */
/* 3 = rate everywhere */
#define OSTYLE 3
#define MAXUPDATEINTERVAL 62
/* default query mode */
-/* 0 = normal, 1 = days, 2 = months, 3 = top10 */
-/* 4 = exportdb, 5 = short, 6 = weeks, 7 = hours */
-/* 8 = xml */
+/* 0 = normal, 1 = days, 2 = months, 3 = top, 5 = short */
+/* 7 = hours, 8 = xml, 9 = one line, 10 = json */
#define DEFQMODE 0
/* how much the boot time can variate between updates (seconds) */
case 3:
showlist(&info, "top");
break;
- case 4:
- exportdb(&info);
- break;
case 5:
showsummary(&info, 1);
break;
timeused(__func__, 0);
}
-void exportdb(const interfaceinfo *interface)
-{
- int i;
- dbdatalist *datalist = NULL, *datalist_i = NULL;
- dbdatalistinfo datainfo;
- const char *datatables[] = {"hour", "day", "month", "year", "top"};
-
- timeused(__func__, 1);
-
- printf("version;%s\n", db_getinfo("dbversion"));
- printf("vnstat;%s\n", db_getinfo("vnstatversion"));
- printf("active;%d\n", interface->active);
- printf("interface;%s\n", interface->name);
- printf("alias;%s\n", interface->alias);
- printf("created;%"PRIu64"\n", (uint64_t)interface->created);
- printf("updated;%"PRIu64"\n", (uint64_t)interface->updated);
-
- printf("totalrx;%"PRIu64"\n", interface->rxtotal);
- printf("totaltx;%"PRIu64"\n", interface->rxtotal);
- printf("currx;%"PRIu64"\n", interface->rxcounter);
- printf("curtx;%"PRIu64"\n", interface->txcounter);
- printf("btime;%s\n", db_getinfo("btime"));
-
- for (i=0; i<5; i++) {
-
- if (!db_getdata(&datalist, &datainfo, interface->name, datatables[i], 0)) {
- printf("Error: Failed to fetch %s data.\n", datatables[i]);
- return;
- }
- datalist_i = datalist;
- while (datalist_i != NULL) {
- printf("%c;%"PRId64";%"PRIu64";%"PRIu64";%"PRIu64"\n", datatables[i][0], datalist_i->rowid, (uint64_t)datalist_i->timestamp, datalist_i->rx, datalist_i->tx);
- datalist_i = datalist_i->next;
- }
- dbdatalistfree(&datalist);
- }
- timeused(__func__, 0);
-}
-
int showbar(const uint64_t rx, const uint64_t tx, const uint64_t max, const int len)
{
int i, l, width = len;
void showlist(const interfaceinfo *interface, const char *listname);
void showoneline(const interfaceinfo *interface);
void showhours(const interfaceinfo *interface);
-void exportdb(const interfaceinfo *interface);
int showbar(uint64_t rx, uint64_t tx, uint64_t max, const int len);
void indent(int i);
}
currentarg++;
}
- } else if ((strcmp(argv[currentarg],"--exportdb")==0) || (strcmp(argv[currentarg],"--dumpdb")==0)) {
- cfg.qmode=4;
} else if (strcmp(argv[currentarg],"--oneline")==0) {
cfg.qmode=9;
if (currentarg+1<argc && argv[currentarg+1][0]!='-') {
printf(" -s, --short use short output\n");
printf(" -ru, --rateunit swap configured rate unit\n");
printf(" --oneline show simple parseable format\n");
- printf(" --exportdb dump database in text format\n");
printf(" --json show database in json format\n");
printf(" --xml show database in xml format\n");