- Add yearly and 5 minute resolution statistics
- Add pebibyte and exbibyte support
- Add options the configure the length of each list output
+ - Add option to limit the length of --json and --xml outputs
- Add hourly list output as alternative
- Remove weekly output
- Remove merge of data from multiple interfaces to one output
.B \-\-iflist
] [
.B \-\-json
-.I mode
+.I "mode limit"
] [
.B \-\-live
.I mode
.B \-\-version
] [
.B \-\-xml
-.I mode
+.I "mode limit"
]
.SH DESCRIPTION
Show list of currently available interfaces.
.TP
-.BI "--json " mode
+.BI "--json " "mode limit"
Show database content for selected interface or all interfaces in json format. All
traffic values in the output are in bytes. An optional
.I mode
parameter can be used for limiting the output to only selected information.
Everything is shown by default. Setting
.I mode
-to '5' will output only 5 minute resolution entries, 'h' hours, 'd' days, 'm' months,
-'y' years and 't' the top days. This option can also be used in combination with
+to 'f' will output only 5 minute resolution entries, 'h' hours, 'd' days, 'm' months, 'y'
+years and 't' the top days. An optional
+.I limit
+parameter can be used to limit the number results to a given number of most recent
+entries. The
+.BI "--json"
+option can be used in combination with
.B "-l, --live"
and
.B "-tr"
Show current version.
.TP
-.BI "--xml " mode
+.BI "--xml " "mode limit"
Show database content for selected interface or all interfaces in xml format. All
traffic values in the output are in bytes. An optional
.I mode
parameter can be used for limiting the output to only selected information.
Everything is shown by default. Setting
.I mode
-to '5' will output only 5 minute resolution entries, 'h' hours, 'd' days, 'm' months,
-'y' years and 't' the top days.
+to 'f' will output only 5 minute resolution entries, 'h' hours, 'd' days, 'm' months, 'y'
+years and 't' the top days. An optional
+.I limit
+parameter can be used to limit the number results to a given number of most recent
+entries.
.TP
.B "-?, --help"
cfg.listmonths = LISTMONTHS;
cfg.listyears = LISTYEARS;
cfg.listtop = LISTTOP;
+ cfg.listjsonxml = LISTJSONXML;
cfg.fiveminutehours = FIVEMINUTEHOURS;
cfg.hourlydays = HOURLYDAYS;
#define LISTMONTHS 12
#define LISTYEARS 0
#define LISTTOP 10
+#define LISTJSONXML 0
/* data retention defaults */
#define FIVEMINUTEHOURS 48
int32_t timesyncwait, updateinterval, pollinterval, saveinterval, offsaveinterval, savestatus;
int32_t uselogging, createdirs, updatefileowner, bwdetection, bwdetectioninterval, utflocale;
int32_t fiveminutehours, hourlydays, dailydays, monthlymonths, yearlyyears, topdayentries;
- int32_t listfivemins, listhours, listdays, listmonths, listyears, listtop;
+ int32_t listfivemins, listhours, listdays, listmonths, listyears, listtop, listjsonxml;
} CFG;
/* internal interface information structure */
case 'y':
jsondump(&info, "year", 4);
break;
- case '5':
+ case 'f':
jsondump(&info, "fiveminute", 2);
break;
case 'a':
dbdatalist *datalist = NULL, *datalist_i = NULL;
dbdatalistinfo datainfo;
- if (!db_getdata(&datalist, &datainfo, interface->name, tablename, 0)) {
+ if (!db_getdata(&datalist, &datainfo, interface->name, tablename, (uint32_t)cfg.listjsonxml)) {
printf("Error: Failed to fetch %s data.\n", tablename);
return;
}
case 'y':
xmldump(&info, "year", 4);
break;
- case '5':
+ case 'f':
xmldump(&info, "fiveminute", 2);
break;
case 'a':
dbdatalist *datalist = NULL, *datalist_i = NULL;
dbdatalistinfo datainfo;
- if (!db_getdata(&datalist, &datainfo, interface->name, tablename, 0)) {
+ if (!db_getdata(&datalist, &datainfo, interface->name, tablename, (uint32_t)cfg.listjsonxml)) {
printf("Error: Failed to fetch %s data.\n", tablename);
return;
}
}
}
} else if (strcmp(argv[currentarg],"--xml")==0) {
- if (currentarg+1<argc && argv[currentarg+1][0]!='-') {
+ if (currentarg+1<argc && argv[currentarg+1][0]!='-' && !isdigit(argv[currentarg+1][0])) {
p.xmlmode = argv[currentarg+1][0];
- if (strlen(argv[currentarg+1])!=1 || strchr("a5hdmyt", p.xmlmode)==NULL) {
+ if (strlen(argv[currentarg+1])!=1 || strchr("afhdmyt", p.xmlmode)==NULL) {
printf("Error: Invalid mode parameter \"%s\" for --xml.\n", argv[currentarg+1]);
printf(" Valid parameters:\n");
printf(" a - all (default)\n");
- printf(" 5 - only 5 minutes\n");
+ printf(" f - only 5 minutes\n");
printf(" h - only hours\n");
printf(" d - only days\n");
printf(" m - only months\n");
printf(" y - only years\n");
- printf(" t - only top 10\n");
+ printf(" t - only top\n");
+ return 1;
+ }
+ currentarg++;
+ }
+ if (currentarg+1<argc && isdigit(argv[currentarg+1][0])) {
+ cfg.listjsonxml = atoi(argv[currentarg+1]);
+ if (cfg.listjsonxml < 0) {
+ printf("Error: Invalid limit parameter \"%s\" for %s. Only a zero and positive numbers are allowed.\n", argv[currentarg+1], argv[currentarg]);
return 1;
}
currentarg++;
}
cfg.qmode=8;
} else if (strcmp(argv[currentarg],"--json")==0) {
- if (currentarg+1<argc && argv[currentarg+1][0]!='-') {
+ if (currentarg+1<argc && argv[currentarg+1][0]!='-' && !isdigit(argv[currentarg+1][0])) {
p.jsonmode = argv[currentarg+1][0];
- if (strlen(argv[currentarg+1])!=1 || strchr("a5hdmyt", p.jsonmode)==NULL) {
+ if (strlen(argv[currentarg+1])!=1 || strchr("afhdmyt", p.jsonmode)==NULL) {
printf("Error: Invalid mode parameter \"%s\" for --json.\n", argv[currentarg+1]);
printf(" Valid parameters:\n");
printf(" a - all (default)\n");
- printf(" 5 - only 5 minutes\n");
+ printf(" f - only 5 minutes\n");
printf(" h - only hours\n");
printf(" d - only days\n");
printf(" m - only months\n");
printf(" y - only years\n");
- printf(" t - only top 10\n");
+ printf(" t - only top\n");
+ return 1;
+ }
+ currentarg++;
+ }
+ if (currentarg+1<argc && isdigit(argv[currentarg+1][0])) {
+ cfg.listjsonxml = atoi(argv[currentarg+1]);
+ if (cfg.listjsonxml < 0) {
+ printf("Error: Invalid limit parameter \"%s\" for %s. Only a zero and positive numbers are allowed.\n", argv[currentarg+1], argv[currentarg]);
return 1;
}
currentarg++;
showxml("something", 't');
showxml("something", 'h');
showxml("something", 'y');
- showxml("something", '5');
+ showxml("something", 'f');
showxml("something", 'a');
showxml("nothing", 'a');
xmlfooter();
showjson("something", 0, 't');
showjson("something", 0, 'h');
showjson("something", 0, 'y');
- showjson("something", 0, '5');
+ showjson("something", 0, 'f');
showjson("something", 1, 'a');
showjson("nothing", 0, 'a');
jsonfooter();
showxml("something", 't');
showxml("something", 'h');
showxml("something", 'y');
- showxml("something", '5');
+ showxml("something", 'f');
showxml("something", 'a');
xmlfooter();
showjson("something", 0, 't');
showjson("something", 0, 'h');
showjson("something", 0, 'y');
- showjson("something", 0, '5');
+ showjson("something", 0, 'f');
showjson("something", 1, 'a');
showjson("nothing", 0, 'a');
jsonfooter();