ic->showlegend = 1;
ic->altdate = 0;
ic->headertext[0] = '\0';
+ ic->databegin[0] = '\0';
+ ic->dataend[0] = '\0';
}
void drawimage(IMAGECONTENT *ic)
strncpy_nt(stampformat, cfg.tformat, 64);
limit = cfg.listtop;
offsetx = 30;
+ /* TODO: should data range selection be supported here? */
+ ic->databegin[0] = '\0';
+ ic->dataend[0] = '\0';
} else if (strcmp(listname, "hour") == 0) {
listtype = 5;
strncpy_nt(colname, listname, 8);
daybuff[0] = '\0';
e_rx = e_tx = 0;
- if (!db_getdata(&datalist, &datainfo, ic->interface.name, listname, (uint32_t)limit)) {
+ if (!db_getdata_range(&datalist, &datainfo, ic->interface.name, listname, (uint32_t)limit, ic->databegin, ic->dataend)) {
printf("Error: Failed to fetch %s data.\n", "day");
return;
}
interfaceinfo interface;
int cbackground, cedge, cheader, cheadertitle, cheaderdate, ctext, cline, clinel, cvnstat;
int crx, crxd, ctx, ctxd, cbgoffset, showheader, showedge, showlegend, altdate;
- char headertext[65];
+ char headertext[65], databegin[18], dataend[18];
time_t current;
} IMAGECONTENT;
#include "dbsql.h"
#include "image.h"
#include "cfg.h"
+#include "misc.h"
#include "vnstati.h"
int main(int argc, char *argv[])
if (debug)
printf("Rateunit changed: %d\n", cfg.rateunit);
}
+ } else if ((strcmp(argv[currentarg],"-b")==0) || (strcmp(argv[currentarg],"--begin")==0)) {
+ if (currentarg+1<argc) {
+ if (!validatedatetime(argv[currentarg+1])) {
+ printf("Error: Invalid date format, expected YYYY-MM-DD HH:MM, YYYY-MM-DD or YYYY-MM.\n");
+ return 1;
+ }
+ strncpy_nt(ic.databegin, argv[currentarg+1], 18);
+ currentarg++;
+ } else {
+ printf("Error: Date for %s missing.\n", argv[currentarg]);
+ return 1;
+ }
+ } else if ((strcmp(argv[currentarg],"-e")==0) || (strcmp(argv[currentarg],"--end")==0)) {
+ if (currentarg+1<argc) {
+ if (!validatedatetime(argv[currentarg+1])) {
+ printf("Error: Invalid date format, expected YYYY-MM-DD HH:MM, YYYY-MM-DD or YYYY-MM.\n");
+ return 1;
+ }
+ strncpy_nt(ic.dataend, argv[currentarg+1], 18);
+ currentarg++;
+ } else {
+ printf("Error: Date for %s missing.\n", argv[currentarg]);
+ return 1;
+ }
} else if ((strcmp(argv[currentarg],"-v")==0) || (strcmp(argv[currentarg],"--version"))==0) {
printf("vnStat image output %s by Teemu Toivola <tst at iki dot fi>\n", getversion());
return 0;