From 95fe840b7c2f94149dc3eafad4ef9e9d761cf6ab Mon Sep 17 00:00:00 2001 From: Teemu Toivola Date: Wed, 21 Mar 2018 16:48:32 +0200 Subject: [PATCH] remove --exportdb --- CHANGES | 1 + README.md | 7 +++---- cfg/vnstat.conf | 6 +++--- man/vnstat.1 | 46 ++-------------------------------------------- man/vnstat.conf.5 | 8 ++++---- src/cfg.c | 6 +++--- src/common.h | 7 +++---- src/dbshow.c | 42 ------------------------------------------ src/dbshow.h | 1 - src/vnstat.c | 3 --- 10 files changed, 19 insertions(+), 108 deletions(-) diff --git a/CHANGES b/CHANGES index 564364e..12b76af 100644 --- a/CHANGES +++ b/CHANGES @@ -12,6 +12,7 @@ - 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 diff --git a/README.md b/README.md index fa99c17..e186bed 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ durations. Yearly and five-minute resolution statistics are now included. * 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 @@ -89,7 +89,8 @@ durations. Yearly and five-minute resolution statistics are now included. * `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 @@ -105,8 +106,6 @@ durations. Yearly and five-minute resolution statistics are now included. * 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 diff --git a/cfg/vnstat.conf b/cfg/vnstat.conf index 706bd31..21a3650 100644 --- a/cfg/vnstat.conf +++ b/cfg/vnstat.conf @@ -37,7 +37,7 @@ RateUnitMode 1 # 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 @@ -67,8 +67,8 @@ MaxBWethnone 8 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) diff --git a/man/vnstat.1 b/man/vnstat.1 index 09c9392..17ddf48 100644 --- a/man/vnstat.1 +++ b/man/vnstat.1 @@ -26,8 +26,6 @@ vnstat \- a console-based network traffic monitor ] [ .B \-\-debug ] [ -.B \-\-exportdb -] [ .B \-\-fiveminutes .I count .B \-\-help @@ -153,45 +151,6 @@ file or the hardcoded default if no configuration file is available. .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 @@ -323,9 +282,8 @@ Modify the content and style of outputs. Set .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. diff --git a/man/vnstat.conf.5 b/man/vnstat.conf.5 index 4be6a97..966416b 100644 --- a/man/vnstat.conf.5 +++ b/man/vnstat.conf.5 @@ -150,14 +150,14 @@ the first day. Value range: 1..28 (vnstat and vnstatd only) 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 diff --git a/src/cfg.c b/src/cfg.c index 2596f7a..c89ffbf 100644 --- a/src/cfg.c +++ b/src/cfg.c @@ -44,7 +44,7 @@ void printcfgfile(void) 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); @@ -80,8 +80,8 @@ void printcfgfile(void) 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"); diff --git a/src/common.h b/src/common.h index 797a094..6c903e1 100644 --- a/src/common.h +++ b/src/common.h @@ -100,7 +100,7 @@ and most can be changed later from the config file. /* 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 @@ -150,9 +150,8 @@ and most can be changed later from the config file. #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) */ diff --git a/src/dbshow.c b/src/dbshow.c index 9da933e..69d05e1 100644 --- a/src/dbshow.c +++ b/src/dbshow.c @@ -33,9 +33,6 @@ void showdb(const char *interface, int qmode) case 3: showlist(&info, "top"); break; - case 4: - exportdb(&info); - break; case 5: showsummary(&info, 1); break; @@ -803,45 +800,6 @@ void showhours(const interfaceinfo *interface) 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; diff --git a/src/dbshow.h b/src/dbshow.h index caf8a2b..4b8286c 100644 --- a/src/dbshow.h +++ b/src/dbshow.h @@ -13,7 +13,6 @@ void showsummary(const interfaceinfo *interface, const int shortmode); 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); diff --git a/src/vnstat.c b/src/vnstat.c index 9e3bc78..acee5c8 100644 --- a/src/vnstat.c +++ b/src/vnstat.c @@ -237,8 +237,6 @@ int main(int argc, char *argv[]) { } 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