From: Teemu Toivola Date: Sat, 24 Mar 2018 17:53:23 +0000 (+0200) Subject: add data time range to image output X-Git-Tag: v2.0~40 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c14d08fef0ace57747ca6f4d115726d66c36e49f;p=vnstat add data time range to image output --- diff --git a/src/image.c b/src/image.c index 32fc525..92df829 100644 --- a/src/image.c +++ b/src/image.c @@ -11,6 +11,8 @@ void initimagecontent(IMAGECONTENT *ic) ic->showlegend = 1; ic->altdate = 0; ic->headertext[0] = '\0'; + ic->databegin[0] = '\0'; + ic->dataend[0] = '\0'; } void drawimage(IMAGECONTENT *ic) @@ -467,6 +469,9 @@ void drawlist(IMAGECONTENT *ic, const char *listname) 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); @@ -490,7 +495,7 @@ void drawlist(IMAGECONTENT *ic, const char *listname) 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; } diff --git a/src/image.h b/src/image.h index f2fc1cb..cfd92ba 100644 --- a/src/image.h +++ b/src/image.h @@ -21,7 +21,7 @@ typedef struct { 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; diff --git a/src/vnstati.c b/src/vnstati.c index b30e6c7..ee1046c 100644 --- a/src/vnstati.c +++ b/src/vnstati.c @@ -19,6 +19,7 @@ vnStat image output - Copyright (c) 2007-2018 Teemu Toivola #include "dbsql.h" #include "image.h" #include "cfg.h" +#include "misc.h" #include "vnstati.h" int main(int argc, char *argv[]) @@ -265,6 +266,30 @@ 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\n", getversion()); return 0;