src/common.c src/common.h \
src/misc.c src/misc.h \
src/cfg.c src/cfg.h \
+ src/cfgoutput.c src/cfgoutput.h \
src/ibw.c src/ibw.h \
src/fs.c src/fs.h \
src/id.c src/id.h \
tests/daemon_tests.c tests/daemon_tests.h
check_vnstat_SOURCES += src/cfg.c src/cfg.h \
+ src/cfgoutput.c src/cfgoutput.h \
src/common.c src/common.h \
src/daemon.c src/daemon.h \
src/dbsql.c src/dbsql.h \
tests/ifinfo_tests.h tests/misc_tests.c tests/misc_tests.h \
tests/fs_tests.c tests/fs_tests.h tests/id_tests.c \
tests/id_tests.h tests/daemon_tests.c tests/daemon_tests.h \
- src/cfg.c src/cfg.h src/common.c src/common.h src/daemon.c \
- src/daemon.h src/dbsql.c src/dbsql.h src/dbaccess.c \
- src/dbaccess.h src/datacache.c src/datacache.h src/dbshow.c \
- src/dbshow.h src/dbjson.c src/dbjson.h src/dbxml.c src/dbxml.h \
- src/ibw.c src/ibw.h src/ifinfo.c src/ifinfo.h src/misc.c \
- src/misc.h src/fs.c src/fs.h src/id.c src/id.h \
- tests/image_tests.c tests/image_tests.h src/image.c \
- src/image.h
+ src/cfg.c src/cfg.h src/cfgoutput.c src/cfgoutput.h \
+ src/common.c src/common.h src/daemon.c src/daemon.h \
+ src/dbsql.c src/dbsql.h src/dbaccess.c src/dbaccess.h \
+ src/datacache.c src/datacache.h src/dbshow.c src/dbshow.h \
+ src/dbjson.c src/dbjson.h src/dbxml.c src/dbxml.h src/ibw.c \
+ src/ibw.h src/ifinfo.c src/ifinfo.h src/misc.c src/misc.h \
+ src/fs.c src/fs.h src/id.c src/id.h tests/image_tests.c \
+ tests/image_tests.h src/image.c src/image.h
am__dirstamp = $(am__leading_dot)dirstamp
@HAVE_CHECK_TRUE@@HAVE_LIBGD_TRUE@am__objects_1 = tests/check_vnstat-image_tests.$(OBJEXT) \
@HAVE_CHECK_TRUE@@HAVE_LIBGD_TRUE@ src/check_vnstat-image.$(OBJEXT)
@HAVE_CHECK_TRUE@ tests/check_vnstat-id_tests.$(OBJEXT) \
@HAVE_CHECK_TRUE@ tests/check_vnstat-daemon_tests.$(OBJEXT) \
@HAVE_CHECK_TRUE@ src/check_vnstat-cfg.$(OBJEXT) \
+@HAVE_CHECK_TRUE@ src/check_vnstat-cfgoutput.$(OBJEXT) \
@HAVE_CHECK_TRUE@ src/check_vnstat-common.$(OBJEXT) \
@HAVE_CHECK_TRUE@ src/check_vnstat-daemon.$(OBJEXT) \
@HAVE_CHECK_TRUE@ src/check_vnstat-dbsql.$(OBJEXT) \
am_vnstat_OBJECTS = src/vnstat.$(OBJEXT) src/ifinfo.$(OBJEXT) \
src/dbsql.$(OBJEXT) src/dbxml.$(OBJEXT) src/dbjson.$(OBJEXT) \
src/dbshow.$(OBJEXT) src/common.$(OBJEXT) src/misc.$(OBJEXT) \
- src/cfg.$(OBJEXT) src/ibw.$(OBJEXT) src/fs.$(OBJEXT) \
- src/id.$(OBJEXT) src/traffic.$(OBJEXT)
+ src/cfg.$(OBJEXT) src/cfgoutput.$(OBJEXT) src/ibw.$(OBJEXT) \
+ src/fs.$(OBJEXT) src/id.$(OBJEXT) src/traffic.$(OBJEXT)
vnstat_OBJECTS = $(am_vnstat_OBJECTS)
vnstat_LDADD = $(LDADD)
am_vnstatd_OBJECTS = src/vnstatd.$(OBJEXT) src/ifinfo.$(OBJEXT) \
src/common.c src/common.h \
src/misc.c src/misc.h \
src/cfg.c src/cfg.h \
+ src/cfgoutput.c src/cfgoutput.h \
src/ibw.c src/ibw.h \
src/fs.c src/fs.h \
src/id.c src/id.h \
@HAVE_CHECK_TRUE@ tests/fs_tests.h tests/id_tests.c \
@HAVE_CHECK_TRUE@ tests/id_tests.h tests/daemon_tests.c \
@HAVE_CHECK_TRUE@ tests/daemon_tests.h src/cfg.c src/cfg.h \
-@HAVE_CHECK_TRUE@ src/common.c src/common.h src/daemon.c \
-@HAVE_CHECK_TRUE@ src/daemon.h src/dbsql.c src/dbsql.h \
-@HAVE_CHECK_TRUE@ src/dbaccess.c src/dbaccess.h src/datacache.c \
+@HAVE_CHECK_TRUE@ src/cfgoutput.c src/cfgoutput.h src/common.c \
+@HAVE_CHECK_TRUE@ src/common.h src/daemon.c src/daemon.h \
+@HAVE_CHECK_TRUE@ src/dbsql.c src/dbsql.h src/dbaccess.c \
+@HAVE_CHECK_TRUE@ src/dbaccess.h src/datacache.c \
@HAVE_CHECK_TRUE@ src/datacache.h src/dbshow.c src/dbshow.h \
@HAVE_CHECK_TRUE@ src/dbjson.c src/dbjson.h src/dbxml.c \
@HAVE_CHECK_TRUE@ src/dbxml.h src/ibw.c src/ibw.h src/ifinfo.c \
@: > src/$(DEPDIR)/$(am__dirstamp)
src/check_vnstat-cfg.$(OBJEXT): src/$(am__dirstamp) \
src/$(DEPDIR)/$(am__dirstamp)
+src/check_vnstat-cfgoutput.$(OBJEXT): src/$(am__dirstamp) \
+ src/$(DEPDIR)/$(am__dirstamp)
src/check_vnstat-common.$(OBJEXT): src/$(am__dirstamp) \
src/$(DEPDIR)/$(am__dirstamp)
src/check_vnstat-daemon.$(OBJEXT): src/$(am__dirstamp) \
src/$(DEPDIR)/$(am__dirstamp)
src/misc.$(OBJEXT): src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp)
src/cfg.$(OBJEXT): src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp)
+src/cfgoutput.$(OBJEXT): src/$(am__dirstamp) \
+ src/$(DEPDIR)/$(am__dirstamp)
src/ibw.$(OBJEXT): src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp)
src/fs.$(OBJEXT): src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp)
src/id.$(OBJEXT): src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp)
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/cfg.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/cfgoutput.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/check_vnstat-cfg.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/check_vnstat-cfgoutput.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/check_vnstat-common.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/check_vnstat-daemon.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/check_vnstat-datacache.Po@am__quote@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(check_vnstat_CFLAGS) $(CFLAGS) -c -o src/check_vnstat-cfg.obj `if test -f 'src/cfg.c'; then $(CYGPATH_W) 'src/cfg.c'; else $(CYGPATH_W) '$(srcdir)/src/cfg.c'; fi`
+src/check_vnstat-cfgoutput.o: src/cfgoutput.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(check_vnstat_CFLAGS) $(CFLAGS) -MT src/check_vnstat-cfgoutput.o -MD -MP -MF src/$(DEPDIR)/check_vnstat-cfgoutput.Tpo -c -o src/check_vnstat-cfgoutput.o `test -f 'src/cfgoutput.c' || echo '$(srcdir)/'`src/cfgoutput.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/check_vnstat-cfgoutput.Tpo src/$(DEPDIR)/check_vnstat-cfgoutput.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/cfgoutput.c' object='src/check_vnstat-cfgoutput.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(check_vnstat_CFLAGS) $(CFLAGS) -c -o src/check_vnstat-cfgoutput.o `test -f 'src/cfgoutput.c' || echo '$(srcdir)/'`src/cfgoutput.c
+
+src/check_vnstat-cfgoutput.obj: src/cfgoutput.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(check_vnstat_CFLAGS) $(CFLAGS) -MT src/check_vnstat-cfgoutput.obj -MD -MP -MF src/$(DEPDIR)/check_vnstat-cfgoutput.Tpo -c -o src/check_vnstat-cfgoutput.obj `if test -f 'src/cfgoutput.c'; then $(CYGPATH_W) 'src/cfgoutput.c'; else $(CYGPATH_W) '$(srcdir)/src/cfgoutput.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/check_vnstat-cfgoutput.Tpo src/$(DEPDIR)/check_vnstat-cfgoutput.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/cfgoutput.c' object='src/check_vnstat-cfgoutput.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(check_vnstat_CFLAGS) $(CFLAGS) -c -o src/check_vnstat-cfgoutput.obj `if test -f 'src/cfgoutput.c'; then $(CYGPATH_W) 'src/cfgoutput.c'; else $(CYGPATH_W) '$(srcdir)/src/cfgoutput.c'; fi`
+
src/check_vnstat-common.o: src/common.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(check_vnstat_CFLAGS) $(CFLAGS) -MT src/check_vnstat-common.o -MD -MP -MF src/$(DEPDIR)/check_vnstat-common.Tpo -c -o src/check_vnstat-common.o `test -f 'src/common.c' || echo '$(srcdir)/'`src/common.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/check_vnstat-common.Tpo src/$(DEPDIR)/check_vnstat-common.Po
#include "common.h"
#include "cfg.h"
-void printcfgfile(void)
-{
- ibwnode *p = ifacebw;
-
- /* common/vnstat section */
- printf("# vnStat %s config file\n", getversion());
- printf("##\n\n");
-
- printf("# default interface\n");
- printf("Interface \"%s\"\n\n", cfg.iface);
-
- printf("# location of the database directory\n");
- printf("DatabaseDir \"%s\"\n\n", cfg.dbdir);
-
- printf("# locale (LC_ALL) (\"-\" = use system locale)\n");
- printf("Locale \"%s\"\n\n", cfg.locale);
-
- printf("# date output formats for -d, -m, -t and -w\n");
- printf("DayFormat \"%s\"\n", cfg.dformat);
- printf("MonthFormat \"%s\"\n", cfg.mformat);
- printf("TopFormat \"%s\"\n\n", cfg.tformat);
-
- printf("# characters used for visuals\n");
- printf("RXCharacter \"%c\"\n", cfg.rxchar[0]);
- printf("TXCharacter \"%c\"\n", cfg.txchar[0]);
- printf("RXHourCharacter \"%c\"\n", cfg.rxhourchar[0]);
- printf("TXHourCharacter \"%c\"\n\n", cfg.txhourchar[0]);
-
- printf("# how units are prefixed when traffic is shown\n");
- printf("# 0 = IEC standard prefixes (KiB/MiB/GiB...)\n");
- printf("# 1 = old style binary prefixes (KB/MB/GB...)\n");
- printf("# 2 = SI decimal prefixes (kB/MB/GB...)\n");
- printf("UnitMode %d\n\n", cfg.unitmode);
-
- printf("# used rate unit (0 = bytes, 1 = bits)\n");
- printf("RateUnit %d\n\n", cfg.rateunit);
-
- printf("# how units are prefixed when traffic rate is shown in bits\n");
- printf("# 0 = IEC binary prefixes (Kibit/s...)\n");
- printf("# 1 = SI decimal prefixes (kbit/s...)\n");
- printf("RateUnitMode %d\n\n", cfg.rateunitmode);
-
- printf("# output style\n");
- printf("# 0 = minimal & narrow, 1 = bar column visible\n");
- printf("# 2 = same as 1 except rate in summary\n");
- printf("# 3 = rate column visible\n");
- printf("OutputStyle %d\n\n", cfg.ostyle);
-
- printf("# number of decimals to use in outputs\n");
- printf("DefaultDecimals %d\n", cfg.defaultdecimals);
- printf("HourlyDecimals %d\n\n", cfg.hourlydecimals);
-
- printf("# spacer for separating hourly sections (0 = none, 1 = '|', 2 = '][', 3 = '[ ]')\n");
- printf("HourlySectionStyle %d\n\n", cfg.hourlystyle);
-
- printf("# how many seconds should sampling for -tr take by default\n");
- printf("Sampletime %d\n\n", cfg.sampletime);
-
- printf("# default query mode\n");
- printf("# 0 = normal, 1 = days, 2 = months, 3 = top, 5 = short\n");
- printf("# 7 = hours, 8 = xml, 9 = one line, 10 = json\n");
- printf("QueryMode %d\n\n", cfg.qmode);
-
- printf("# default list output entry count (0 = all)\n");
- printf("List5Mins %2d\n", cfg.listfivemins);
- printf("ListHours %2d\n", cfg.listhours);
- printf("ListDays %2d\n", cfg.listdays);
- printf("ListMonths %2d\n", cfg.listmonths);
- printf("ListYears %2d\n", cfg.listyears);
- printf("ListTop %2d\n", cfg.listtop);
-
- printf("\n\n");
-
- /* vnstatd section */
- printf("# vnstatd\n##\n\n");
-
- printf("# switch to given user when started as root (leave empty to disable)\n");
- printf("DaemonUser \"%s\"\n\n", cfg.daemonuser);
-
- printf("# switch to given user when started as root (leave empty to disable)\n");
- printf("DaemonGroup \"%s\"\n\n", cfg.daemongroup);
-
- printf("# try to detect interface maximum bandwidth, 0 = disable feature\n");
- printf("# MaxBandwidth will be used as fallback value when enabled\n");
- printf("BandwidthDetection %d\n\n", cfg.bwdetection);
-
- printf("# maximum bandwidth (Mbit) for all interfaces, 0 = disable feature\n# (unless interface specific limit is given)\n");
- printf("MaxBandwidth %d\n\n", cfg.maxbw);
-
- printf("# interface specific limits\n");
- printf("# example 8Mbit limit for eth0 (remove # to activate):\n");
- printf("#MaxBWeth0 8\n");
-
- while (p != NULL) {
- printf("MaxBW%s %u\n", p->interface, p->limit);
- p = p->next;
- }
-
- printf("\n");
-
- printf("# data retention durations (-1 = unlimited, 0 = feature disabled)\n");
- printf("5MinuteHours %2d\n", cfg.fiveminutehours);
- printf("HourlyDays %2d\n", cfg.hourlydays);
- printf("DailyDays %2d\n", cfg.dailydays);
- printf("MonthlyMonths %2d\n", cfg.monthlymonths);
- printf("YearlyYears %2d\n", cfg.yearlyyears);
- printf("TopDayEntries %2d\n\n", cfg.topdayentries);
-
- printf("# how often (in seconds) interface data is updated\n");
- printf("UpdateInterval %d\n\n", cfg.updateinterval);
-
- printf("# how often (in seconds) interface status changes are checked\n");
- printf("PollInterval %d\n\n", cfg.pollinterval);
-
- printf("# how often (in minutes) data is saved to database\n");
- printf("SaveInterval %d\n\n", cfg.saveinterval);
-
- printf("# how often (in minutes) data is saved when all interface are offline\n");
- printf("OfflineSaveInterval %d\n\n", cfg.offsaveinterval);
-
- printf("# on which day should months change\n");
- printf("MonthRotate %d\n\n", cfg.monthrotate);
-
- printf("# filesystem disk space check (1 = enabled, 0 = disabled)\n");
- printf("CheckDiskSpace %d\n\n", cfg.spacecheck);
-
- printf("# how much the boot time can variate between updates (seconds)\n");
- printf("BootVariation %d\n\n", cfg.bvar);
-
- printf("# log days without traffic to daily list (1 = enabled, 0 = disabled)\n");
- printf("TrafficlessDays %d\n\n", cfg.traflessday);
-
- printf("# how many minutes to wait during daemon startup for system clock to\n");
- printf("# sync time if most recent database update appears to be in the future\n");
- printf("TimeSyncWait %d\n\n", cfg.timesyncwait);
-
- printf("# how often (in minutes) bandwidth detection is done when\n");
- printf("# BandwidthDetection is enabled (0 = disabled)\n");
- printf("BandwidthDetectionInterval %d\n\n", cfg.bwdetectioninterval);
-
- printf("# force data save when interface status changes (1 = enabled, 0 = disabled)\n");
- printf("SaveOnStatusChange %d\n\n", cfg.savestatus);
-
- printf("# enable / disable logging (0 = disabled, 1 = logfile, 2 = syslog)\n");
- printf("UseLogging %d\n\n", cfg.uselogging);
-
- printf("# create dirs if needed (1 = enabled, 0 = disabled)\n");
- printf("CreateDirs %d\n\n", cfg.createdirs);
-
- printf("# update ownership of files if needed (1 = enabled, 0 = disabled)\n");
- printf("UpdateFileOwner %d\n\n", cfg.updatefileowner);
-
- printf("# file used for logging if UseLogging is set to 1\n");
- printf("LogFile \"%s\"\n\n", cfg.logfile);
-
- printf("# file used as daemon pid / lock file\n");
- printf("PidFile \"%s\"\n", cfg.pidfile);
-
- printf("\n\n");
-
- /* vnstati section */
- printf("# vnstati\n##\n\n");
-
- printf("# title timestamp format\n");
- printf("HeaderFormat \"%s\"\n\n", cfg.hformat);
-
- printf("# show hours with rate (1 = enabled, 0 = disabled)\n");
- printf("HourlyRate %d\n\n", cfg.hourlyrate);
-
- printf("# show rate in summary (1 = enabled, 0 = disabled)\n");
- printf("SummaryRate %d\n\n", cfg.summaryrate);
-
- printf("# transparent background (1 = enabled, 0 = disabled)\n");
- printf("TransparentBg %d\n\n", cfg.transbg);
-
- printf("# image colors\n");
- printf("CBackground \"%s\"\n", cfg.cbg);
- printf("CEdge \"%s\"\n", cfg.cedge);
- printf("CHeader \"%s\"\n", cfg.cheader);
- printf("CHeaderTitle \"%s\"\n", cfg.cheadertitle);
- printf("CHeaderDate \"%s\"\n", cfg.cheaderdate);
- printf("CText \"%s\"\n", cfg.ctext);
- printf("CLine \"%s\"\n", cfg.cline);
- printf("CLineL \"%s\"\n", cfg.clinel);
- printf("CRx \"%s\"\n", cfg.crx);
- printf("CTx \"%s\"\n", cfg.ctx);
- printf("CRxD \"%s\"\n", cfg.crxd);
- printf("CTxD \"%s\"\n", cfg.ctxd);
-
-}
-
int loadcfg(const char *cfgfile)
{
FILE *fd;
short found;
};
-void printcfgfile(void);
int loadcfg(const char *cfgfile);
void validatecfg(void);
void defaultcfg(void);
--- /dev/null
+#include "common.h"
+#include "cfgoutput.h"
+
+void printcfgfile(void)
+{
+ ibwnode *p = ifacebw;
+
+ /* common/vnstat section */
+ printf("# vnStat %s config file\n", getversion());
+ printf("##\n\n");
+
+ printf("# default interface\n");
+ printf("Interface \"%s\"\n\n", cfg.iface);
+
+ printf("# location of the database directory\n");
+ printf("DatabaseDir \"%s\"\n\n", cfg.dbdir);
+
+ printf("# locale (LC_ALL) (\"-\" = use system locale)\n");
+ printf("Locale \"%s\"\n\n", cfg.locale);
+
+ printf("# date output formats for -d, -m, -t and -w\n");
+ printf("DayFormat \"%s\"\n", cfg.dformat);
+ printf("MonthFormat \"%s\"\n", cfg.mformat);
+ printf("TopFormat \"%s\"\n\n", cfg.tformat);
+
+ printf("# characters used for visuals\n");
+ printf("RXCharacter \"%c\"\n", cfg.rxchar[0]);
+ printf("TXCharacter \"%c\"\n", cfg.txchar[0]);
+ printf("RXHourCharacter \"%c\"\n", cfg.rxhourchar[0]);
+ printf("TXHourCharacter \"%c\"\n\n", cfg.txhourchar[0]);
+
+ printf("# how units are prefixed when traffic is shown\n");
+ printf("# 0 = IEC standard prefixes (KiB/MiB/GiB...)\n");
+ printf("# 1 = old style binary prefixes (KB/MB/GB...)\n");
+ printf("# 2 = SI decimal prefixes (kB/MB/GB...)\n");
+ printf("UnitMode %d\n\n", cfg.unitmode);
+
+ printf("# used rate unit (0 = bytes, 1 = bits)\n");
+ printf("RateUnit %d\n\n", cfg.rateunit);
+
+ printf("# how units are prefixed when traffic rate is shown in bits\n");
+ printf("# 0 = IEC binary prefixes (Kibit/s...)\n");
+ printf("# 1 = SI decimal prefixes (kbit/s...)\n");
+ printf("RateUnitMode %d\n\n", cfg.rateunitmode);
+
+ printf("# output style\n");
+ printf("# 0 = minimal & narrow, 1 = bar column visible\n");
+ printf("# 2 = same as 1 except rate in summary\n");
+ printf("# 3 = rate column visible\n");
+ printf("OutputStyle %d\n\n", cfg.ostyle);
+
+ printf("# number of decimals to use in outputs\n");
+ printf("DefaultDecimals %d\n", cfg.defaultdecimals);
+ printf("HourlyDecimals %d\n\n", cfg.hourlydecimals);
+
+ printf("# spacer for separating hourly sections (0 = none, 1 = '|', 2 = '][', 3 = '[ ]')\n");
+ printf("HourlySectionStyle %d\n\n", cfg.hourlystyle);
+
+ printf("# how many seconds should sampling for -tr take by default\n");
+ printf("Sampletime %d\n\n", cfg.sampletime);
+
+ printf("# default query mode\n");
+ printf("# 0 = normal, 1 = days, 2 = months, 3 = top, 5 = short\n");
+ printf("# 7 = hours, 8 = xml, 9 = one line, 10 = json\n");
+ printf("QueryMode %d\n\n", cfg.qmode);
+
+ printf("# default list output entry count (0 = all)\n");
+ printf("List5Mins %2d\n", cfg.listfivemins);
+ printf("ListHours %2d\n", cfg.listhours);
+ printf("ListDays %2d\n", cfg.listdays);
+ printf("ListMonths %2d\n", cfg.listmonths);
+ printf("ListYears %2d\n", cfg.listyears);
+ printf("ListTop %2d\n", cfg.listtop);
+
+ printf("\n\n");
+
+ /* vnstatd section */
+ printf("# vnstatd\n##\n\n");
+
+ printf("# switch to given user when started as root (leave empty to disable)\n");
+ printf("DaemonUser \"%s\"\n\n", cfg.daemonuser);
+
+ printf("# switch to given user when started as root (leave empty to disable)\n");
+ printf("DaemonGroup \"%s\"\n\n", cfg.daemongroup);
+
+ printf("# try to detect interface maximum bandwidth, 0 = disable feature\n");
+ printf("# MaxBandwidth will be used as fallback value when enabled\n");
+ printf("BandwidthDetection %d\n\n", cfg.bwdetection);
+
+ printf("# maximum bandwidth (Mbit) for all interfaces, 0 = disable feature\n# (unless interface specific limit is given)\n");
+ printf("MaxBandwidth %d\n\n", cfg.maxbw);
+
+ printf("# interface specific limits\n");
+ printf("# example 8Mbit limit for eth0 (remove # to activate):\n");
+ printf("#MaxBWeth0 8\n");
+
+ while (p != NULL) {
+ printf("MaxBW%s %u\n", p->interface, p->limit);
+ p = p->next;
+ }
+
+ printf("\n");
+
+ printf("# data retention durations (-1 = unlimited, 0 = feature disabled)\n");
+ printf("5MinuteHours %2d\n", cfg.fiveminutehours);
+ printf("HourlyDays %2d\n", cfg.hourlydays);
+ printf("DailyDays %2d\n", cfg.dailydays);
+ printf("MonthlyMonths %2d\n", cfg.monthlymonths);
+ printf("YearlyYears %2d\n", cfg.yearlyyears);
+ printf("TopDayEntries %2d\n\n", cfg.topdayentries);
+
+ printf("# how often (in seconds) interface data is updated\n");
+ printf("UpdateInterval %d\n\n", cfg.updateinterval);
+
+ printf("# how often (in seconds) interface status changes are checked\n");
+ printf("PollInterval %d\n\n", cfg.pollinterval);
+
+ printf("# how often (in minutes) data is saved to database\n");
+ printf("SaveInterval %d\n\n", cfg.saveinterval);
+
+ printf("# how often (in minutes) data is saved when all interface are offline\n");
+ printf("OfflineSaveInterval %d\n\n", cfg.offsaveinterval);
+
+ printf("# on which day should months change\n");
+ printf("MonthRotate %d\n\n", cfg.monthrotate);
+
+ printf("# filesystem disk space check (1 = enabled, 0 = disabled)\n");
+ printf("CheckDiskSpace %d\n\n", cfg.spacecheck);
+
+ printf("# how much the boot time can variate between updates (seconds)\n");
+ printf("BootVariation %d\n\n", cfg.bvar);
+
+ printf("# log days without traffic to daily list (1 = enabled, 0 = disabled)\n");
+ printf("TrafficlessDays %d\n\n", cfg.traflessday);
+
+ printf("# how many minutes to wait during daemon startup for system clock to\n");
+ printf("# sync time if most recent database update appears to be in the future\n");
+ printf("TimeSyncWait %d\n\n", cfg.timesyncwait);
+
+ printf("# how often (in minutes) bandwidth detection is done when\n");
+ printf("# BandwidthDetection is enabled (0 = disabled)\n");
+ printf("BandwidthDetectionInterval %d\n\n", cfg.bwdetectioninterval);
+
+ printf("# force data save when interface status changes (1 = enabled, 0 = disabled)\n");
+ printf("SaveOnStatusChange %d\n\n", cfg.savestatus);
+
+ printf("# enable / disable logging (0 = disabled, 1 = logfile, 2 = syslog)\n");
+ printf("UseLogging %d\n\n", cfg.uselogging);
+
+ printf("# create dirs if needed (1 = enabled, 0 = disabled)\n");
+ printf("CreateDirs %d\n\n", cfg.createdirs);
+
+ printf("# update ownership of files if needed (1 = enabled, 0 = disabled)\n");
+ printf("UpdateFileOwner %d\n\n", cfg.updatefileowner);
+
+ printf("# file used for logging if UseLogging is set to 1\n");
+ printf("LogFile \"%s\"\n\n", cfg.logfile);
+
+ printf("# file used as daemon pid / lock file\n");
+ printf("PidFile \"%s\"\n", cfg.pidfile);
+
+ printf("\n\n");
+
+ /* vnstati section */
+ printf("# vnstati\n##\n\n");
+
+ printf("# title timestamp format\n");
+ printf("HeaderFormat \"%s\"\n\n", cfg.hformat);
+
+ printf("# show hours with rate (1 = enabled, 0 = disabled)\n");
+ printf("HourlyRate %d\n\n", cfg.hourlyrate);
+
+ printf("# show rate in summary (1 = enabled, 0 = disabled)\n");
+ printf("SummaryRate %d\n\n", cfg.summaryrate);
+
+ printf("# transparent background (1 = enabled, 0 = disabled)\n");
+ printf("TransparentBg %d\n\n", cfg.transbg);
+
+ printf("# image colors\n");
+ printf("CBackground \"%s\"\n", cfg.cbg);
+ printf("CEdge \"%s\"\n", cfg.cedge);
+ printf("CHeader \"%s\"\n", cfg.cheader);
+ printf("CHeaderTitle \"%s\"\n", cfg.cheadertitle);
+ printf("CHeaderDate \"%s\"\n", cfg.cheaderdate);
+ printf("CText \"%s\"\n", cfg.ctext);
+ printf("CLine \"%s\"\n", cfg.cline);
+ printf("CLineL \"%s\"\n", cfg.clinel);
+ printf("CRx \"%s\"\n", cfg.crx);
+ printf("CTx \"%s\"\n", cfg.ctx);
+ printf("CRxD \"%s\"\n", cfg.crxd);
+ printf("CTxD \"%s\"\n", cfg.ctxd);
+
+}
--- /dev/null
+#ifndef CFGOUTPUT_H
+#define CFGOUTPUT_H
+
+void printcfgfile(void);
+
+#endif
{
int i, used;
uint64_t rxsum, txsum;
+ const char *invaliddb = "Invalid database";
if (debug) {
printf("validating loaded database\n");
data->nick[sizeof(data->nick)-1] = '\0';
if (data->version>LEGACYDBVERSION) {
- snprintf(errorstring, 1024, "%s: Invalid database version: %d", data->interface, data->version);
+ snprintf(errorstring, 1024, "%s: %s version: %d", data->interface, invaliddb, data->version);
printe(PT_Error);
return 0;
}
if (data->active<0 || data->active>1) {
- snprintf(errorstring, 1024, "%s: Invalid database activity status: %d", data->interface, data->active);
+ snprintf(errorstring, 1024, "%s: %s activity status: %d", data->interface, invaliddb, data->active);
printe(PT_Error);
return 0;
}
if (!strlen(data->interface)) {
- snprintf(errorstring, 1024, "Invalid database interface string: %s", data->interface);
+ snprintf(errorstring, 1024, "%s interface string: %s", invaliddb, data->interface);
printe(PT_Error);
return 0;
}
if (!data->created || !data->lastupdated || !data->btime) {
- snprintf(errorstring, 1024, "%s: Invalid database timestamp.", data->interface);
+ snprintf(errorstring, 1024, "%s: %s timestamp.", data->interface, invaliddb);
printe(PT_Error);
return 0;
}
used = 1;
for (i=0; i<30; i++) {
if (data->day[i].used<0 || data->day[i].used>1) {
- snprintf(errorstring, 1024, "%s: Invalid database daily use information: %d %d", data->interface, i, data->day[i].used);
+ snprintf(errorstring, 1024, "%s: %s daily use information: %d %d", data->interface, invaliddb, i, data->day[i].used);
printe(PT_Error);
return 0;
}
if (data->day[i].rxk<0 || data->day[i].txk<0) {
- snprintf(errorstring, 1024, "%s: Invalid database daily traffic: %d", data->interface, i);
+ snprintf(errorstring, 1024, "%s: %s daily traffic: %d", data->interface, invaliddb, i);
printe(PT_Error);
return 0;
}
if (data->day[i].used && !used) {
- snprintf(errorstring, 1024, "%s: Invalid database daily use order: %d", data->interface, i);
+ snprintf(errorstring, 1024, "%s: %s daily use order: %d", data->interface, invaliddb, i);
printe(PT_Error);
return 0;
} else if (!data->day[i].used) {
break;
}
if (data->day[i-1].date < data->day[i].date) {
- snprintf(errorstring, 1024, "%s: Invalid database daily date order: %u (%d) < %u (%d)", data->interface, (unsigned int)data->day[i-1].date, i-1, (unsigned int)data->day[i].date, i);
+ snprintf(errorstring, 1024, "%s: %s daily date order: %u (%d) < %u (%d)", data->interface, invaliddb, (unsigned int)data->day[i-1].date, i-1, (unsigned int)data->day[i].date, i);
printe(PT_Error);
return 0;
}
}
if (data->totalrx < rxsum || data->totaltx < txsum) {
- snprintf(errorstring, 1024, "%s: Invalid database total traffic compared to daily usage.", data->interface);
+ snprintf(errorstring, 1024, "%s: %s total traffic compared to daily usage.", data->interface, invaliddb);
printe(PT_Error);
return 0;
}
used = 1;
for (i=0; i<12; i++) {
if (data->month[i].used<0 || data->month[i].used>1) {
- snprintf(errorstring, 1024, "%s: Invalid database monthly use information: %d %d", data->interface, i, data->month[i].used);
+ snprintf(errorstring, 1024, "%s: %s monthly use information: %d %d", data->interface, invaliddb, i, data->month[i].used);
printe(PT_Error);
return 0;
}
if (data->month[i].rxk<0 || data->month[i].txk<0) {
- snprintf(errorstring, 1024, "%s: Invalid database monthly traffic: %d", data->interface, i);
+ snprintf(errorstring, 1024, "%s: %s monthly traffic: %d", data->interface, invaliddb, i);
printe(PT_Error);
return 0;
}
if (data->month[i].used && !used) {
- snprintf(errorstring, 1024, "%s: Invalid database monthly use order: %d", data->interface, i);
+ snprintf(errorstring, 1024, "%s: %s monthly use order: %d", data->interface, invaliddb, i);
printe(PT_Error);
return 0;
} else if (!data->month[i].used) {
break;
}
if (data->month[i-1].month < data->month[i].month) {
- snprintf(errorstring, 1024, "%s: Invalid database monthly date order: %u (%d) < %u (%d)", data->interface, (unsigned int)data->month[i-1].month, i-1, (unsigned int)data->month[i].month, i);
+ snprintf(errorstring, 1024, "%s: %s monthly date order: %u (%d) < %u (%d)", data->interface, invaliddb, (unsigned int)data->month[i-1].month, i-1, (unsigned int)data->month[i].month, i);
printe(PT_Error);
return 0;
}
}
if (data->totalrx < rxsum || data->totaltx < txsum) {
- snprintf(errorstring, 1024, "%s: Invalid database total traffic compared to monthly usage.", data->interface);
+ snprintf(errorstring, 1024, "%s: %s total traffic compared to monthly usage.", data->interface, invaliddb);
printe(PT_Error);
return 0;
}
used = 1;
for (i=0; i<10; i++) {
if (data->top10[i].used<0 || data->top10[i].used>1) {
- snprintf(errorstring, 1024, "%s: Invalid database top10 use information: %d %d", data->interface, i, data->top10[i].used);
+ snprintf(errorstring, 1024, "%s: %s top10 use information: %d %d", data->interface, invaliddb, i, data->top10[i].used);
printe(PT_Error);
return 0;
}
if (data->top10[i].rxk<0 || data->top10[i].txk<0) {
- snprintf(errorstring, 1024, "%s: Invalid database top10 traffic: %d", data->interface, i);
+ snprintf(errorstring, 1024, "%s: %s top10 traffic: %d", data->interface, invaliddb, i);
printe(PT_Error);
return 0;
}
if (data->top10[i].used && !used) {
- snprintf(errorstring, 1024, "%s: Invalid database top10 use order: %d", data->interface, i);
+ snprintf(errorstring, 1024, "%s: %s top10 use order: %d", data->interface, invaliddb, i);
printe(PT_Error);
return 0;
} else if (!data->top10[i].used) {
#include "dbshow.h"
#include "misc.h"
#include "cfg.h"
+#include "cfgoutput.h"
#include "ibw.h"
#include "fs.h"
#include "vnstat.h"
#include "vnstat_tests.h"
#include "config_tests.h"
#include "cfg.h"
+#include "cfgoutput.h"
#include "ibw.h"
START_TEST(validatecfg_default)