* full data import from vnStat 1.x database format including reconstructed yearly data
* legacy database is not kept in memory for each interface during daemon runtime
* new configuration options for data retention durations
- * the daemon doesn't however yet use these new options
+ * features can be disabled
+ * database cleanup isn't being called
##### TODO
sqlite3_int64 ifaceid = 0;
char *datatables[] = {"fiveminute", "hour", "day", "month", "year"};
+ int32_t *featurecfg[] = {&cfg.fiveminutehours, &cfg.hourlydays, &cfg.dailydays, &cfg.monthlymonths, &cfg.yearlyyears};
char *datadates[] = {"datetime(%1$s, ('-' || (strftime('%%M', %1$s)) || ' minutes'), ('-' || (strftime('%%S', %1$s)) || ' seconds'), ('+' || (round(strftime('%%M', %1$s)/5,0)*5) || ' minutes'), 'localtime')", \
"strftime('%%Y-%%m-%%d %%H:00:00', %s, 'localtime')", \
"date(%s, 'localtime')", \
}
/* time specific */
- /* TODO: skip if feature disabled in configuration */
for (i=0; i<5; i++) {
+ if (featurecfg[i] == 0) {
+ continue;
+ }
snprintf(datebuffer, 512, datadates[i], nowdate);
sqlite3_snprintf(1024, sql, "insert or ignore into %s (interface, date, rx, tx) values (%"PRId64", %s, 0, 0);", datatables[i], (int64_t)ifaceid, datebuffer);
if (!db_exec(sql)) {