#define PIDFILE "/var/run/vnstat/vnstat.pid"
#define IS64BIT -2
#define WALDB 0
+#define WALDBCHECKPOINTINTERVALMINS 240
/* no transparency by default */
#define TRANSBG 0
s->cleanuphour = getcurrenthour();
s->dbretrycount = 0;
s->dcache = NULL;
+ s->prevwaldbcheckpoint = time(NULL);
}
void preparedatabases(DSTATE *s)
uint64_t dbifcount;
char cfgfile[512], dirname[512];
char user[33], group[33];
- time_t current, prevdbupdate, prevdbsave;
+ time_t current, prevdbupdate, prevdbsave, prevwaldbcheckpoint;
datacache *dcache;
} DSTATE;
}
}
+void db_walcheckpoint(void)
+{
+ timeused(__func__, 1);
+ if (debug)
+ printf("wal checkpoint");
+ sqlite3_wal_checkpoint_v2(db, NULL, SQLITE_CHECKPOINT_TRUNCATE, NULL, NULL);
+ timeused(__func__, 0);
+}
+
int dbiflistadd(dbiflist **dbifl, const char *iface)
{
dbiflist *newif;
int db_committransaction(void);
int db_rollbacktransaction(void);
int db_iserrcodefatal(int errcode);
+void db_walcheckpoint(void);
int dbiflistadd(dbiflist **dbifl, const char *iface);
void dbiflistfree(dbiflist **dbifl);
}
}
+ timeused("daemon_startup", 1);
+
/* load config if available */
if (!loadcfg(s.cfgfile)) {
return 1;
}
}
+ timeused("daemon_startup", 0);
s.running = 1;
#if defined(__linux__)
processdatacache(&s);
+ if (cfg.waldb && (s.current - s.prevwaldbcheckpoint) >= WALDBCHECKPOINTINTERVALMINS * 60) {
+ db_walcheckpoint();
+ s.prevwaldbcheckpoint = s.current;
+ }
+
if (debug) {
printf("\n");
}