Hello community, here is the log from the commit of package vnstat for openSUSE:Factory checked in at 2019-08-27 12:01:39 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/vnstat (Old) and /work/SRC/openSUSE:Factory/.vnstat.new.7948 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "vnstat" Tue Aug 27 12:01:39 2019 rev:10 rq:726429 version:2.4 Changes: -------- --- /work/SRC/openSUSE:Factory/vnstat/vnstat.changes 2019-07-22 17:18:41.893943765 +0200 +++ /work/SRC/openSUSE:Factory/.vnstat.new.7948/vnstat.changes 2019-08-27 12:01:44.119648132 +0200 @@ -1,0 +2,14 @@ +Mon Aug 26 22:44:33 UTC 2019 - Martin Hauke <mar...@gmx.de> + +- Update to version 2.4 + Fixed + * Daemon didn't correctly wait when acquiring database lock for + data write which could result in unnecessary errors and even + process exit if an external database read operation had exactly + the same timing as the daemon write operation + * Move vnstatd man page from section 1 to section 8 + New + * Add --rename for renaming interfaces already existing the + database + +------------------------------------------------------------------- Old: ---- vnstat-2.3.tar.gz vnstat-2.3.tar.gz.sig New: ---- vnstat-2.4.tar.gz vnstat-2.4.tar.gz.sig ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ vnstat.spec ++++++ --- /var/tmp/diff_new_pack.r4VAGE/_old 2019-08-27 12:01:45.391647957 +0200 +++ /var/tmp/diff_new_pack.r4VAGE/_new 2019-08-27 12:01:45.391647957 +0200 @@ -22,7 +22,7 @@ %bcond_with systemd %endif Name: vnstat -Version: 2.3 +Version: 2.4 Release: 0 Summary: Network Traffic Monitor License: GPL-2.0-only @@ -162,7 +162,7 @@ %{_initddir}/vnstatd %endif %{_mandir}/man1/vnstat.1%{?ext_man} -%{_mandir}/man1/vnstatd.1%{?ext_man} +%{_mandir}/man8/vnstatd.8%{?ext_man} %{_mandir}/man5/vnstat.conf.5%{?ext_man} %attr(0755,vnstat,root) %{_localstatedir}/lib/vnstat ++++++ vnstat-2.3.tar.gz -> vnstat-2.4.tar.gz ++++++ ++++ 1610 lines of diff (skipped) ++++ retrying with extended exclude list diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/vnstat-2.3/CHANGES new/vnstat-2.4/CHANGES --- old/vnstat-2.3/CHANGES 2019-07-10 16:10:10.000000000 +0200 +++ new/vnstat-2.4/CHANGES 2019-08-18 14:19:21.000000000 +0200 @@ -1,3 +1,17 @@ +2.4 / 18-Aug-2019 + + - Fixed + - Daemon didn't correctly wait when acquiring database lock for data write + which could result in unnecessary errors and even process exit if an + external database read operation had exactly the same timing as the + daemon write operation + - Daemon didn't fork() even when requested to with --daemon when started + by PID 1 (issue seen at least in Docker containers) + - Move vnstatd man page from section 1 to section 8 + - New + - Add --rename for renaming interfaces already existing the database + + 2.3 / 10-Jul-2019 - Fixed diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/vnstat-2.3/Makefile.am new/vnstat-2.4/Makefile.am --- old/vnstat-2.3/Makefile.am 2019-06-16 16:35:43.000000000 +0200 +++ new/vnstat-2.4/Makefile.am 2019-07-22 23:19:44.000000000 +0200 @@ -1,7 +1,7 @@ SUBDIRS = . AM_CFLAGS = @CFLAG_EXTRAS@ -dist_man_MANS = man/vnstat.1 man/vnstat.conf.5 man/vnstatd.1 man/vnstati.1 +dist_man_MANS = man/vnstat.1 man/vnstat.conf.5 man/vnstatd.8 man/vnstati.1 EXTRA_DIST = cfg examples UPGRADE CHANGES FAQ INSTALL_BSD UNINSTALL @@ -139,6 +139,7 @@ ls -l $(PACKAGE_NAME)-$(PACKAGE_VERSION).tar.gz install-data-hook: install-exec + if [ -f $(DESTDIR)$(man1dir)/vnstatd.1 ]; then rm -f $(DESTDIR)$(man1dir)/vnstatd.1; fi $(MKDIR_P) $(DESTDIR)$(sysconfdir) if IS_CROSSCOMPILED if [ ! -f $(DESTDIR)$(sysconfdir)/vnstat.conf ]; \ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/vnstat-2.3/README new/vnstat-2.4/README --- old/vnstat-2.3/README 2019-04-13 18:06:21.000000000 +0200 +++ new/vnstat-2.4/README 2019-07-18 13:28:48.000000000 +0200 @@ -24,7 +24,8 @@ vnStat works best when installed. See the INSTALL or INSTALL_BSD file depending on used operating system. These files contain all needed information for the installing process. Instructions for upgrading from -a previous version are included in the UPGRADE file. +a previous version are included in the UPGRADE file. Release notes +can be found from the CHANGES file. # Available options and documentation diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/vnstat-2.3/UPGRADE new/vnstat-2.4/UPGRADE --- old/vnstat-2.3/UPGRADE 2019-05-13 19:27:52.000000000 +0200 +++ new/vnstat-2.4/UPGRADE 2019-08-18 14:19:21.000000000 +0200 @@ -1,6 +1,8 @@ # New configuration settings + * 2.4: (none) + * 2.3: DatabaseWriteAheadLogging, DatabaseSynchronous * 2.2: 64bitInterfaceCounters diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/vnstat-2.3/cfg/vnstat.conf new/vnstat-2.4/cfg/vnstat.conf --- old/vnstat-2.3/cfg/vnstat.conf 2019-07-10 16:08:33.000000000 +0200 +++ new/vnstat-2.4/cfg/vnstat.conf 2019-08-17 20:33:59.000000000 +0200 @@ -1,4 +1,4 @@ -# vnStat 2.3 config file +# vnStat 2.4 config file ## # default interface (leave empty for automatic selection) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/vnstat-2.3/configure.ac new/vnstat-2.4/configure.ac --- old/vnstat-2.3/configure.ac 2019-07-10 16:08:25.000000000 +0200 +++ new/vnstat-2.4/configure.ac 2019-08-17 20:34:54.000000000 +0200 @@ -1,6 +1,6 @@ # -*- Autoconf -*- # Process this file with autoconf to produce a configure script. -AC_INIT([vnstat], [2.3]) +AC_INIT([vnstat], [2.4]) AM_INIT_AUTOMAKE([foreign subdir-objects std-options -Wall -Werror]) AM_MAINTAINER_MODE diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/vnstat-2.3/man/vnstat.1 new/vnstat-2.4/man/vnstat.1 --- old/vnstat-2.3/man/vnstat.1 2019-07-10 16:08:41.000000000 +0200 +++ new/vnstat-2.4/man/vnstat.1 2019-08-17 20:33:24.000000000 +0200 @@ -1,4 +1,4 @@ -.TH VNSTAT 1 "JULY 2019" "version 2.3" "User Manuals" +.TH VNSTAT 1 "AUGUST 2019" "version 2.4" "User Manuals" .SH NAME vnstat \- a console-based network traffic monitor @@ -46,6 +46,8 @@ .RB [ \-\-rateunit .RI [ mode ]] .RB [ \-\-remove ] +.RB [ \-\-rename +.IR name ] .RB [ \-ru .RI [ mode ]] .RB [ \-\-setalias @@ -84,7 +86,7 @@ .B vnstat command is to provide an interface for querying the traffic information stored in the database whereas the daemon -.BR vnstatd (1) +.BR vnstatd (8) is responsible for data retrieval, caching and storage. Although the daemon process is constantly running as a service, it is actually spending most of its time sleeping between data updates. @@ -97,7 +99,8 @@ .B \-i or .B \-\-iface -option. +option. The daemon can be running during this operation but will not +automatically detect the addition without a restart. .TP .BI "-b, --begin " date @@ -283,7 +286,19 @@ .B \-i or .B \-\-iface -and stop monitoring it. +and stop monitoring it. The daemon can be running during this operation +and will automatically detect the change. + +.TP +.BI "--rename " name +Rename the interface specified with +.B \-i +or +.B \-\-iface +in the database with new name +.BR name . +The new name cannot already exist in the database. This operation doesn't +cause any data loss. The daemon should not be running during this operation. .TP .BI "-ru, --rateunit " [mode] @@ -299,7 +314,8 @@ .BI "--setalias " alias Set the selected interface .I alias -as an alias that will be displayed in queries. +as an alias that will be displayed in queries. The daemon can be running during +this operation. .TP .B "-s, --short" @@ -460,7 +476,7 @@ .SH "SEE ALSO" -.BR vnstatd (1), +.BR vnstatd (8), .BR vnstati (1), .BR vnstat.conf (5), .BR proc (5), diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/vnstat-2.3/man/vnstat.conf.5 new/vnstat-2.4/man/vnstat.conf.5 --- old/vnstat-2.3/man/vnstat.conf.5 2019-07-10 16:17:50.000000000 +0200 +++ new/vnstat-2.4/man/vnstat.conf.5 2019-08-17 20:33:33.000000000 +0200 @@ -1,4 +1,4 @@ -.TH VNSTAT.CONF 5 "JULY 2019" "version 2.3" "User Manuals" +.TH VNSTAT.CONF 5 "AUGUST 2019" "version 2.4" "User Manuals" .SH NAME vnstat.conf \- vnStat configuration file @@ -11,7 +11,7 @@ .BR vnstat (1), .BR vnstati (1) and -.BR vnstatd (1) +.BR vnstatd (8) all use the same configuration file for configuration related settings. Some of the settings are common for all three programs. The file consists of keyword-argument pairs, one per line. Empty lines and @@ -453,5 +453,5 @@ .BR vnstat (1), .BR vnstati (1), -.BR vnstatd (1), +.BR vnstatd (8), .BR units (7) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/vnstat-2.3/man/vnstatd.1 new/vnstat-2.4/man/vnstatd.1 --- old/vnstat-2.3/man/vnstatd.1 2019-07-10 16:08:56.000000000 +0200 +++ new/vnstat-2.4/man/vnstatd.1 1970-01-01 01:00:00.000000000 +0100 @@ -1,279 +0,0 @@ -.TH VNSTATD 1 "JULY 2019" "version 2.3" "User Manuals" -.SH NAME -vnstatd \- daemon based database updating for vnStat - -.SH SYNOPSIS - -.B vnstatd -.RB [ \-Ddnpsv? ] -.RB [ \-\-alwaysadd ] -.RB [ \-\-config -.IR file ] -.RB [ \-\-daemon ] -.RB [ \-\-debug ] -.RB [ \-g -.IR group ] -.RB [ \-\-group -.IR group ] -.RB [ \-\-help ] -.RB [ \-\-noadd ] -.RB [ \-\-nodaemon ] -.RB [ \-\-pidfile -.IR file ] -.RB [ \-\-sync ] -.RB [ \-\-u -.IR user ] -.RB [ \-\-user -.IR user ] -.RB [ \-\-version ] - -.SH DESCRIPTION - -The purpose of -.B vnstatd -is to provide a flexible and robust way for updating the database that -.BR vnstat (1) -uses. The availability of each interface is automatically tracked which -removes the need for additional scripts to be implemented and called when -an interface comes online or goes offline. -.PP -.B vnstatd -is the command for starting the daemon. The daemon can either fork -itself to run as a background process or stay attached to the terminal. -It supports logging to a user selectable file or using syslog. -.PP -Once started, the daemon will read -.BR vnstat.conf (5) -if available and then check if there is a database present -in the database directory that has been specified in the configuration -file. By default, if no database is found, a database will be created -during startup with entries for all available interfaces excluding pseudo -interfaces lo, lo0 and sit0. This automatic database entry creation behaviour -can be disabled using the -.B --noadd -option. Alternatively, it is possible to allow the daemon to create new -database entries whenever previously unseen interfaces become visible using the -.B --alwaysadd -option. -.PP -The daemon will proceed to track the availability of monitored interfaces, -process the interface traffic statistics and write new values to the database -at a configured interval. As a result, the daemon ends up spending most -of the time sleeping between updates. - -.SH OPTIONS - -.TP -.B "--alwaysadd" -Enable automatic creation of new database entries for previously unseen interfaces -even if the database directory already contains a database when the daemon -is started. New database entries will also get created for new interfaces seen while -the daemon is running. Pseudo interfaces lo, lo0 and sit0 are excluded from -getting added. - -.TP -.BI "--config " file -Use -.I file -as configuration file instead of using automatic configuration file search -functionality. - -.TP -.B "-d, --daemon" -Fork process to background and run as a daemon. - -.TP -.B "-D, --debug" -Provide additional output for debug purposes. The process will stay -attached to the terminal for output. - -.TP -.BI "-g, --group " group -Set daemon process group to -.I group -during startup. -.I group -can be either the name of the group or a numerical group id. This option -can only be used when the process is started as root. - -.TP -.B "--noadd" -Disable automatic creation of new database entries for all available interfaces -if the daemon is started with no database found. Pseudo interfaces -lo, lo0 and sit0 are excluded from getting added. - -.TP -.B "-n, --nodaemon" -Stay in foreground attached to the current terminal and start the update -process. - -.TP -.BI "-p, --pidfile " file -Write the process id to -.I file -and use it for locking so that another instance of the daemon cannot -be started if the same -.I file -is specified. - -.TP -.B "-s, --sync" -Synchronize internal counters in the database with interface -counters for all available interfaces before starting traffic monitoring. -Use this option if the traffic between the previous shutdown -and the current startup of the daemon needs to be ignored. This option -isn't required in normal use because the daemon will automatically synchronize -the internal counters after a system reboot, if enough time has passed -since the daemon was previously running or if the internal counters are -clearly out of sync. - -.TP -.BI "-u, --user " user -Set daemon process user to -.I user -during startup. -.I user -can be either the login of the user or a numerical user id. This option -can only be used when the process is started as root. - -.TP -.B "-v, --version" -Show current version of the daemon executable. - -.TP -.B "-?, --help" -Show a command option summary. - -.SH CONFIGURATION - -The behaviour of the daemon is configured mainly using the configuration -keywords -.B "UpdateInterval, PollInterval" -and -.B SaveInterval -in the configuration file. - -.PP -.B UpdateInterval -defines in seconds how often the interface data is fetched and updated. -This is similar to the run interval for alternative cron based updating. -However, the difference is that the data doesn't directly get written to disk -during updates. - -.PP -.B PollInterval -defines in seconds how often the list of available interfaces is checked -for possible changes. The minimum value is 2 seconds and the maximum 60 -seconds. -.B PollInterval -also defines the resolution for other intervals. - -.PP -.B SaveInterval -defines in minutes how often cached interface data is written to disk. -A write can only occur during the updating of interface data. Therefore, -the value should be a multiple of -.B UpdateInterval -with a maximum value of 60 minutes. - -.PP -The default values of -.B UpdateInterval -30, -.B SaveInterval -5 and -.B PollInterval -5 are usually suitable for most systems and provide a similar behaviour -as cron based updating does but with a better resolution for interface -changes and fast interfaces. - -.PP -For embedded and/or low power systems more tuned configurations are possible. -In such cases if the interfaces are mostly static the -.B PollInterval -can be increased to around 10-30 seconds and -.B UpdateInterval -set to 60 seconds. Higher values up to 300 seconds are possible if the -interface speed is 10 Mbit or less. -.B SaveInterval -can be increased for example to 15, 30 or even 60 minutes depending on how -often the data needs to be viewed. - -.SH SIGNALS - -The daemon is listening to signals -.B "SIGHUP, SIGINT" -and -.B SIGTERM. -Sending the -.B SIGHUP -signal to the daemon will cause cached data to be written to disk, -a rescan of the database directory and a reload of settings from the -configuration file. However, the pid file location will not be changed -even if it's configuration setting has been modified. - -.PP -.B SIGTERM -and -.B SIGINT -signals will cause the daemon to write all cached data to disk and -then exit. - -.SH FILES - -.TP -.I /var/lib/vnstat/ -Default database directory. - -.TP -.I /etc/vnstat.conf -Config file that will be used unless -.I $HOME/.vnstatrc -exists. See the configuration chapter and -.BR vnstat.conf (5) -for more information. - -.TP -.I /var/log/vnstat.log -Log file that will be used if logging to file is enable and no other file -is specified in the config file. - -.TP -.I /var/run/vnstat.pid -File used for storing the process id if no other file is specified in the -configuration file or using the command line parameter. - -.SH RESTRICTIONS - -Updates need to be executed at least as often as it is possible for the interface -to generate enough traffic to overflow the kernel interface traffic counter. Otherwise, -it is possible that some traffic won't be seen. With 32-bit kernels, the maximum time -between two updates depends on how fast the interface can transfer 4 GiB. Calculated -theoretical times are: -.RS -.TS -l l. -10 Mbit: 54 minutes -100 Mbit: 5 minutes -1000 Mbit: 30 seconds -.TE -.RE - -However, for 1000 Mbit interfaces updating once every minute is usually a -usable solution if a shorter update interval can't be used. -.PP -Virtual and aliased interfaces cannot be monitored because the kernel doesn't -provide traffic information for that type of interfaces. Such interfaces are -usually named eth0:0, eth0:1, eth0:2 etc. where eth0 is the actual interface -being aliased. - -.SH AUTHOR - -Teemu Toivola <tst at iki dot fi> - -.SH "SEE ALSO" - -.BR vnstat (1), -.BR vnstati (1), -.BR vnstat.conf (5), -.BR signal (7) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/vnstat-2.3/man/vnstatd.8 new/vnstat-2.4/man/vnstatd.8 --- old/vnstat-2.3/man/vnstatd.8 1970-01-01 01:00:00.000000000 +0100 +++ new/vnstat-2.4/man/vnstatd.8 2019-08-17 20:33:42.000000000 +0200 @@ -0,0 +1,279 @@ +.TH VNSTATD 8 "AUGUST 2019" "version 2.4" "User Manuals" +.SH NAME +vnstatd \- daemon based database updating for vnStat + +.SH SYNOPSIS + +.B vnstatd +.RB [ \-Ddnpsv? ] +.RB [ \-\-alwaysadd ] +.RB [ \-\-config +.IR file ] +.RB [ \-\-daemon ] +.RB [ \-\-debug ] +.RB [ \-g +.IR group ] +.RB [ \-\-group +.IR group ] +.RB [ \-\-help ] +.RB [ \-\-noadd ] +.RB [ \-\-nodaemon ] +.RB [ \-\-pidfile +.IR file ] +.RB [ \-\-sync ] +.RB [ \-\-u +.IR user ] +.RB [ \-\-user +.IR user ] +.RB [ \-\-version ] + +.SH DESCRIPTION + +The purpose of +.B vnstatd +is to provide a flexible and robust way for updating the database that +.BR vnstat (1) +uses. The availability of each interface is automatically tracked which +removes the need for additional scripts to be implemented and called when +an interface comes online or goes offline. +.PP +.B vnstatd +is the command for starting the daemon. The daemon can either fork +itself to run as a background process or stay attached to the terminal. +It supports logging to a user selectable file or using syslog. +.PP +Once started, the daemon will read +.BR vnstat.conf (5) +if available and then check if there is a database present +in the database directory that has been specified in the configuration +file. By default, if no database is found, a database will be created +during startup with entries for all available interfaces excluding pseudo +interfaces lo, lo0 and sit0. This automatic database entry creation behaviour +can be disabled using the +.B --noadd +option. Alternatively, it is possible to allow the daemon to create new +database entries whenever previously unseen interfaces become visible using the +.B --alwaysadd +option. +.PP +The daemon will proceed to track the availability of monitored interfaces, +process the interface traffic statistics and write new values to the database +at a configured interval. As a result, the daemon ends up spending most +of the time sleeping between updates. + +.SH OPTIONS + +.TP +.B "--alwaysadd" +Enable automatic creation of new database entries for previously unseen interfaces +even if the database directory already contains a database when the daemon +is started. New database entries will also get created for new interfaces seen while +the daemon is running. Pseudo interfaces lo, lo0 and sit0 are excluded from +getting added. + +.TP +.BI "--config " file +Use +.I file +as configuration file instead of using automatic configuration file search +functionality. + +.TP +.B "-d, --daemon" +Fork process to background and run as a daemon. + +.TP +.B "-D, --debug" +Provide additional output for debug purposes. The process will stay +attached to the terminal for output. + +.TP +.BI "-g, --group " group +Set daemon process group to +.I group +during startup. +.I group +can be either the name of the group or a numerical group id. This option +can only be used when the process is started as root. + +.TP +.B "--noadd" +Disable automatic creation of new database entries for all available interfaces +if the daemon is started with no database found. Pseudo interfaces +lo, lo0 and sit0 are excluded from getting added. + +.TP +.B "-n, --nodaemon" +Stay in foreground attached to the current terminal and start the update +process. + +.TP +.BI "-p, --pidfile " file +Write the process id to +.I file +and use it for locking so that another instance of the daemon cannot +be started if the same +.I file +is specified. + +.TP +.B "-s, --sync" +Synchronize internal counters in the database with interface +counters for all available interfaces before starting traffic monitoring. +Use this option if the traffic between the previous shutdown +and the current startup of the daemon needs to be ignored. This option +isn't required in normal use because the daemon will automatically synchronize +the internal counters after a system reboot, if enough time has passed +since the daemon was previously running or if the internal counters are +clearly out of sync. + +.TP +.BI "-u, --user " user +Set daemon process user to +.I user +during startup. +.I user +can be either the login of the user or a numerical user id. This option +can only be used when the process is started as root. + +.TP +.B "-v, --version" +Show current version of the daemon executable. + +.TP +.B "-?, --help" +Show a command option summary. + +.SH CONFIGURATION + +The behaviour of the daemon is configured mainly using the configuration +keywords +.B "UpdateInterval, PollInterval" +and +.B SaveInterval +in the configuration file. + +.PP +.B UpdateInterval +defines in seconds how often the interface data is fetched and updated. +This is similar to the run interval for alternative cron based updating. +However, the difference is that the data doesn't directly get written to disk +during updates. + +.PP +.B PollInterval +defines in seconds how often the list of available interfaces is checked +for possible changes. The minimum value is 2 seconds and the maximum 60 +seconds. +.B PollInterval +also defines the resolution for other intervals. + +.PP +.B SaveInterval +defines in minutes how often cached interface data is written to disk. +A write can only occur during the updating of interface data. Therefore, +the value should be a multiple of +.B UpdateInterval +with a maximum value of 60 minutes. + +.PP +The default values of +.B UpdateInterval +30, +.B SaveInterval +5 and +.B PollInterval +5 are usually suitable for most systems and provide a similar behaviour +as cron based updating does but with a better resolution for interface +changes and fast interfaces. + +.PP +For embedded and/or low power systems more tuned configurations are possible. +In such cases if the interfaces are mostly static the +.B PollInterval +can be increased to around 10-30 seconds and +.B UpdateInterval +set to 60 seconds. Higher values up to 300 seconds are possible if the +interface speed is 10 Mbit or less. +.B SaveInterval +can be increased for example to 15, 30 or even 60 minutes depending on how +often the data needs to be viewed. + +.SH SIGNALS + +The daemon is listening to signals +.B "SIGHUP, SIGINT" +and +.B SIGTERM. +Sending the +.B SIGHUP +signal to the daemon will cause cached data to be written to disk, +a rescan of the database directory and a reload of settings from the +configuration file. However, the pid file location will not be changed +even if it's configuration setting has been modified. + +.PP +.B SIGTERM +and +.B SIGINT +signals will cause the daemon to write all cached data to disk and +then exit. + +.SH FILES + +.TP +.I /var/lib/vnstat/ +Default database directory. + +.TP +.I /etc/vnstat.conf +Config file that will be used unless +.I $HOME/.vnstatrc +exists. See the configuration chapter and +.BR vnstat.conf (5) +for more information. + +.TP +.I /var/log/vnstat.log +Log file that will be used if logging to file is enable and no other file +is specified in the config file. + +.TP +.I /var/run/vnstat.pid +File used for storing the process id if no other file is specified in the +configuration file or using the command line parameter. + +.SH RESTRICTIONS + +Updates need to be executed at least as often as it is possible for the interface +to generate enough traffic to overflow the kernel interface traffic counter. Otherwise, +it is possible that some traffic won't be seen. With 32-bit kernels, the maximum time +between two updates depends on how fast the interface can transfer 4 GiB. Calculated +theoretical times are: +.RS +.TS +l l. +10 Mbit: 54 minutes +100 Mbit: 5 minutes +1000 Mbit: 30 seconds +.TE +.RE + +However, for 1000 Mbit interfaces updating once every minute is usually a +usable solution if a shorter update interval can't be used. +.PP +Virtual and aliased interfaces cannot be monitored because the kernel doesn't +provide traffic information for that type of interfaces. Such interfaces are +usually named eth0:0, eth0:1, eth0:2 etc. where eth0 is the actual interface +being aliased. + +.SH AUTHOR + +Teemu Toivola <tst at iki dot fi> + +.SH "SEE ALSO" + +.BR vnstat (1), +.BR vnstati (1), +.BR vnstat.conf (5), +.BR signal (7) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/vnstat-2.3/man/vnstati.1 new/vnstat-2.4/man/vnstati.1 --- old/vnstat-2.3/man/vnstati.1 2019-07-10 16:09:04.000000000 +0200 +++ new/vnstat-2.4/man/vnstati.1 2019-08-17 20:33:54.000000000 +0200 @@ -1,4 +1,4 @@ -.TH VNSTATI 1 "JULY 2019" "version 2.3" "User Manuals" +.TH VNSTATI 1 "AUGUST 2019" "version 2.4" "User Manuals" .SH NAME vnstati \- png image output support for vnStat @@ -346,6 +346,6 @@ .SH "SEE ALSO" .BR vnstat (1), -.BR vnstatd (1), +.BR vnstatd (8), .BR vnstat.conf (5), .BR units (7) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/vnstat-2.3/src/common.h new/vnstat-2.4/src/common.h --- old/vnstat-2.3/src/common.h 2019-06-16 16:00:45.000000000 +0200 +++ new/vnstat-2.4/src/common.h 2019-08-13 22:50:09.000000000 +0200 @@ -257,8 +257,10 @@ #define CTX "606060" #define CTXD "-" -/* number of retries for non-fatal database errors */ -#define DBRETRYLIMIT 3 +/* number of retries after non-fatal database errors, */ +/* will result in given number + 1 tries in total before exit, */ +/* a full disk (as reported by sqlite) will no cause retries or exit */ +#define DBRETRYLIMIT 5 /* internal config structure */ typedef struct { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/vnstat-2.3/src/daemon.c new/vnstat-2.4/src/daemon.c --- old/vnstat-2.3/src/daemon.c 2019-06-27 22:24:49.000000000 +0200 +++ new/vnstat-2.4/src/daemon.c 2019-08-12 23:41:26.000000000 +0200 @@ -16,10 +16,6 @@ int i; char str[10]; - if (getppid() == 1) { - return; /* already a daemon */ - } - i = (int)fork(); if (i < 0) { /* fork error */ @@ -272,7 +268,7 @@ s->prevwaldbcheckpoint = time(NULL); } -void preparedatabases(DSTATE *s) +void preparedatabase(DSTATE *s) { s->dbifcount = db_getinterfacecount(); @@ -670,7 +666,6 @@ if (db_intransaction && !db_errcode) { if (!db_committransaction()) { handledatabaseerror(s); - db_rollbacktransaction(); } else { /* clear xferlog now that everything is in database */ iterator = s->dcache; @@ -702,8 +697,8 @@ printe(PT_Error); } else { s->dbretrycount++; - if (s->dbretrycount >= DBRETRYLIMIT) { - snprintf(errorstring, 1024, "Database error retry limit %d reached, exiting.", DBRETRYLIMIT); + if (s->dbretrycount > DBRETRYLIMIT) { + snprintf(errorstring, 1024, "Database error retry limit of %d reached, exiting.", DBRETRYLIMIT); printe(PT_Error); errorexitdaemon(s, 1); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/vnstat-2.3/src/daemon.h new/vnstat-2.4/src/daemon.h --- old/vnstat-2.3/src/daemon.h 2019-06-27 22:16:54.000000000 +0200 +++ new/vnstat-2.4/src/daemon.h 2019-07-31 23:15:53.000000000 +0200 @@ -19,7 +19,7 @@ unsigned int addinterfaces(DSTATE *s); void initdstate(DSTATE *s); -void preparedatabases(DSTATE *s); +void preparedatabase(DSTATE *s); unsigned int importlegacydbs(DSTATE *s); void setsignaltraps(void); void filldatabaselist(DSTATE *s); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/vnstat-2.3/src/dbsql.c new/vnstat-2.4/src/dbsql.c --- old/vnstat-2.3/src/dbsql.c 2019-07-06 13:19:41.000000000 +0200 +++ new/vnstat-2.4/src/dbsql.c 2019-08-14 20:47:01.000000000 +0200 @@ -101,6 +101,7 @@ /* set pragmas */ if (!readonly) { + sqlite3_busy_timeout(db, cfg.updateinterval * 1000); if (!db_setpragmas()) { db_close(); return 0; @@ -391,6 +392,24 @@ return db_exec(sql); } +int db_renameinterface(const char *iface, const char *newifname) +{ + char sql[128]; + sqlite3_int64 ifaceid = 0; + + if (!strlen(newifname)) { + return 0; + } + + ifaceid = db_getinterfaceid(iface, 0); + if (ifaceid == 0) { + return 0; + } + + sqlite3_snprintf(128, sql, "update interface set name='%q' where id=%" PRId64 "", newifname, (int64_t)ifaceid); + return db_exec(sql); +} + uint64_t db_getinterfacecount(void) { return db_getinterfacecountbyname(""); @@ -904,11 +923,12 @@ printf("db: removing old entries\n"); } - if (!db_removeoldentries_top()) { + if (!db_begintransaction()) { return 0; } - if (!db_begintransaction()) { + if (!db_removeoldentries_top()) { + db_rollbacktransaction(); return 0; } @@ -1021,6 +1041,9 @@ int db_vacuum(void) { + if (debug) { + printf("db: vacuum\n"); + } return db_exec("VACUUM"); } @@ -1028,6 +1051,10 @@ { int rc; + if (debug) { + printf("db: begin transaction\n"); + } + rc = sqlite3_exec(db, "BEGIN IMMEDIATE", 0, 0, 0); if (rc) { db_errcode = rc; @@ -1043,15 +1070,23 @@ { int rc; + if (debug) { + printf("db: commit transaction\n"); + } + + db_intransaction = 0; + rc = sqlite3_exec(db, "COMMIT", 0, 0, 0); if (rc) { - db_errcode = rc; snprintf(errorstring, 1024, "Commit transaction to database failed (%d): %s", rc, sqlite3_errmsg(db)); printe(PT_Error); - db_intransaction = 0; + /* execute rollback if commit failure left the transaction open */ + if (!sqlite3_get_autocommit(db)) { + db_rollbacktransaction(); + } + db_errcode = rc; return 0; } - db_intransaction = 0; return 1; } @@ -1059,15 +1094,19 @@ { int rc; + if (debug) { + printf("db: rollback transaction\n"); + } + + db_intransaction = 0; + rc = sqlite3_exec(db, "ROLLBACK", 0, 0, 0); if (rc) { db_errcode = rc; snprintf(errorstring, 1024, "Transaction rollback failed (%d): %s", rc, sqlite3_errmsg(db)); printe(PT_Error); - db_intransaction = 0; return 0; } - db_intransaction = 0; return 1; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/vnstat-2.3/src/dbsql.h new/vnstat-2.4/src/dbsql.h --- old/vnstat-2.3/src/dbsql.h 2019-06-16 00:19:59.000000000 +0200 +++ new/vnstat-2.4/src/dbsql.h 2019-08-14 13:19:16.000000000 +0200 @@ -38,6 +38,7 @@ int db_create(void); int db_addinterface(const char *iface); int db_removeinterface(const char *iface); +int db_renameinterface(const char *iface, const char *newifname); uint64_t db_getinterfacecount(void); uint64_t db_getinterfacecountbyname(const char *iface); sqlite3_int64 db_getinterfaceid(const char *iface, const int createifnotfound); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/vnstat-2.3/src/vnstat.c new/vnstat-2.4/src/vnstat.c --- old/vnstat-2.3/src/vnstat.c 2019-07-06 13:21:58.000000000 +0200 +++ new/vnstat-2.4/src/vnstat.c 2019-08-14 20:48:17.000000000 +0200 @@ -361,6 +361,19 @@ } else if (strcmp(argv[currentarg], "--remove") == 0) { p.removeiface = 1; p.query = 0; + } else if (strcmp(argv[currentarg], "--rename") == 0) { + if (currentarg + 1 < argc) { + strncpy_nt(p.newifname, argv[currentarg + 1], 32); + if (debug) + printf("Given new interface name: \"%s\"\n", p.newifname); + p.renameiface = 1; + p.query = 0; + currentarg++; + continue; + } else { + printf("Error: New interface name for %s missing.\n", argv[currentarg]); + return 1; + } } else if ((strcmp(argv[currentarg], "-b") == 0) || (strcmp(argv[currentarg], "--begin") == 0)) { if (currentarg + 1 < argc) { if (!validatedatetime(argv[currentarg + 1])) { @@ -442,6 +455,7 @@ /* parameter handlers */ handleremoveinterface(&p); + handlerenameinterface(&p); handleaddinterface(&p); handlesetalias(&p); handleshowdatabases(&p); @@ -469,8 +483,8 @@ } /* cleanup */ - ibwflush(); db_close(); + ibwflush(); return 0; } @@ -491,8 +505,14 @@ p->livetraffic = 0; p->defaultiface = 1; p->removeiface = 0; + p->renameiface = 0; p->livemode = 0; p->ifacelist = NULL; + p->interface[0] = '\0'; + p->alias[0] = '\0'; + p->newifname[0] = '\0'; + p->filename[0] = '\0'; + p->definterface[0] = '\0'; p->cfgfile[0] = '\0'; p->jsonmode = 'a'; p->xmlmode = 'a'; @@ -555,6 +575,7 @@ printf(" --add add interface to database\n"); printf(" --remove remove interface from database\n"); + printf(" --rename <name> rename interface in database\n"); printf(" --setalias <alias> set alias for interface\n\n"); printf("Misc:\n"); @@ -587,6 +608,11 @@ return; } + if (p->defaultiface) { + printf("Error: Use -i parameter to specify an interface.\n"); + exit(EXIT_FAILURE); + } + if (!db_getinterfacecountbyname(p->interface)) { printf("Error: Interface \"%s\" not found in database.\n", p->interface); exit(EXIT_FAILURE); @@ -614,6 +640,52 @@ } } +void handlerenameinterface(PARAMS *p) +{ + if (!p->renameiface) { + return; + } + + if (p->defaultiface) { + printf("Error: Use -i parameter to specify an interface.\n"); + exit(EXIT_FAILURE); + } + + if (!strlen(p->newifname)) { + printf("Error: New interface name must be at least one character long.\n"); + exit(EXIT_FAILURE); + } + + if (!db_getinterfacecountbyname(p->interface)) { + printf("Error: Interface \"%s\" not found in database.\n", p->interface); + exit(EXIT_FAILURE); + } + + if (db_getinterfacecountbyname(p->newifname)) { + printf("Error: Interface \"%s\" already exists in database.\n", p->interface); + exit(EXIT_FAILURE); + } + + if (!p->force) { + printf("Warning:\nThe current option would rename\ninterface \"%s\" -> \"%s\" in the database.\n", p->interface, p->newifname); + printf("Use --force in order to really do that.\n"); + exit(EXIT_FAILURE); + } + + if (!db_close() || !db_open_rw(0)) { + printf("Error: Handling database \"%s/%s\" failing: %s\n", cfg.dbdir, DATABASEFILE, strerror(errno)); + exit(EXIT_FAILURE); + } + + if (db_renameinterface(p->interface, p->newifname)) { + printf("Interface \"%s\" has been renamed \"%s\".\n", p->interface, p->newifname); + exit(EXIT_SUCCESS); + } else { + printf("Error: Renaming interface \"%s\" -> \"%s\" failed.\n", p->interface, p->newifname); + exit(EXIT_FAILURE); + } +} + void handleaddinterface(PARAMS *p) { if (!p->addiface) { @@ -657,7 +729,7 @@ printf("\nRestart the vnStat daemon if it is currently running in order to start monitoring \"%s\".\n", p->interface); exit(EXIT_SUCCESS); } else { - printf("Error: Adding interface \"%s\" to database failed: %s\n", p->interface, strerror(errno)); + printf("Error: Adding interface \"%s\" to database failed.\n", p->interface); exit(EXIT_FAILURE); } } @@ -687,7 +759,7 @@ printf("Alias of interface \"%s\" set to \"%s\".\n", p->interface, p->alias); exit(EXIT_SUCCESS); } else { - printf("Error: Changing interface \"%s\" alias failed: %s\n", p->interface, strerror(errno)); + printf("Error: Setting interface \"%s\" alias failed.\n", p->interface); exit(EXIT_FAILURE); } } @@ -832,7 +904,7 @@ iflist *ifl = NULL; iflist *dbifl = NULL, *dbifl_iterator = NULL; - if (!p->defaultiface) { + if (!p->defaultiface || !p->query) { return; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/vnstat-2.3/src/vnstat.h new/vnstat-2.4/src/vnstat.h --- old/vnstat-2.3/src/vnstat.h 2019-06-27 22:09:14.000000000 +0200 +++ new/vnstat-2.4/src/vnstat.h 2019-08-13 23:21:02.000000000 +0200 @@ -4,9 +4,9 @@ typedef struct { int query, setalias; int addiface, force, traffic; - int livetraffic, defaultiface, removeiface, livemode; + int livetraffic, defaultiface, removeiface, renameiface, livemode; uint64_t dbifcount; - char interface[32], alias[32], filename[512]; + char interface[32], alias[32], newifname[32], filename[512]; char definterface[32], cfgfile[512], *ifacelist, jsonmode, xmlmode; char databegin[18], dataend[18]; } PARAMS; @@ -15,6 +15,7 @@ void showhelp(PARAMS *p); void showlonghelp(PARAMS *p); void handleremoveinterface(PARAMS *p); +void handlerenameinterface(PARAMS *p); void handleaddinterface(PARAMS *p); void handlesetalias(PARAMS *p); void handleshowdatabases(PARAMS *p); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/vnstat-2.3/src/vnstatd.c new/vnstat-2.4/src/vnstatd.c --- old/vnstat-2.3/src/vnstatd.c 2019-06-27 22:19:47.000000000 +0200 +++ new/vnstat-2.4/src/vnstatd.c 2019-08-13 22:33:42.000000000 +0200 @@ -165,7 +165,7 @@ } detectboot(&s); - preparedatabases(&s); + preparedatabase(&s); if (!db_removeoldentries()) { printf("Error: Database \"%s/%s\" cleanup failed: %s\n", cfg.dbdir, DATABASEFILE, strerror(errno)); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/vnstat-2.3/src/vnstati.c new/vnstat-2.4/src/vnstati.c --- old/vnstat-2.3/src/vnstati.c 2019-06-16 00:08:37.000000000 +0200 +++ new/vnstat-2.4/src/vnstati.c 2019-07-27 16:06:57.000000000 +0200 @@ -318,10 +318,9 @@ printf("Qmode: %d\n", cfg.qmode); drawimage(&ic); + db_close(); writeoutput(&p, &ic); - /* cleanup */ - db_close(); if (debug) printf("all done\n"); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/vnstat-2.3/tests/daemon_tests.c new/vnstat-2.4/tests/daemon_tests.c --- old/vnstat-2.3/tests/daemon_tests.c 2019-07-08 01:00:39.000000000 +0200 +++ new/vnstat-2.4/tests/daemon_tests.c 2019-08-13 22:57:34.000000000 +0200 @@ -191,7 +191,7 @@ } END_TEST -START_TEST(preparedatabases_exits_with_no_database_dir) +START_TEST(preparedatabase_exits_with_no_database_dir) { DSTATE s; @@ -200,11 +200,11 @@ suppress_output(); ck_assert_int_eq(remove_directory(TESTDIR), 1); - preparedatabases(&s); + preparedatabase(&s); } END_TEST -START_TEST(preparedatabases_exits_with_no_databases) +START_TEST(preparedatabase_exits_with_no_database) { DSTATE s; @@ -215,11 +215,11 @@ ck_assert_int_eq(remove_directory(TESTDIR), 1); ck_assert_int_eq(clean_testdbdir(), 1); - preparedatabases(&s); + preparedatabase(&s); } END_TEST -START_TEST(preparedatabases_exits_with_no_databases_and_noadd) +START_TEST(preparedatabase_exits_with_no_database_and_noadd) { DSTATE s; @@ -231,11 +231,11 @@ ck_assert_int_eq(remove_directory(TESTDIR), 1); ck_assert_int_eq(clean_testdbdir(), 1); - preparedatabases(&s); + preparedatabase(&s); } END_TEST -START_TEST(preparedatabases_with_no_databases_creates_databases) +START_TEST(preparedatabase_with_no_database_creates_database) { int ret; DSTATE s; @@ -253,7 +253,7 @@ ret = db_open_rw(1); ck_assert_int_eq(ret, 1); - preparedatabases(&s); + preparedatabase(&s); ck_assert_int_eq(db_getinterfacecountbyname("ethone"), 1); ck_assert_int_eq(db_getinterfacecountbyname("ethtwo"), 1); @@ -1073,7 +1073,7 @@ } END_TEST -START_TEST(handledatabaseerror_does_not_exit_if_limit_is_not_reached) +START_TEST(handledatabaseerror_does_not_exit_if_limit_is_not_exceeded) { int i; DSTATE s; @@ -1088,15 +1088,15 @@ ck_assert_int_eq(s.dbretrycount, 1); - for (i = 1; i < DBRETRYLIMIT - 1; i++) { + for (i = 1; i < DBRETRYLIMIT; i++) { handledatabaseerror(&s); } - ck_assert_int_eq(s.dbretrycount, DBRETRYLIMIT - 1); + ck_assert_int_eq(s.dbretrycount, DBRETRYLIMIT); } END_TEST -START_TEST(handledatabaseerror_exits_if_limit_is_reached) +START_TEST(handledatabaseerror_exits_if_limit_is_exceeded) { int i; DSTATE s; @@ -1111,7 +1111,7 @@ ck_assert_int_eq(s.dbretrycount, 1); - for (i = 1; i < DBRETRYLIMIT; i++) { + for (i = 1; i < DBRETRYLIMIT + 1; i++) { handledatabaseerror(&s); } } @@ -1445,10 +1445,10 @@ tcase_add_test(tc_daemon, addinterfaces_adds_interfaces); tcase_add_test(tc_daemon, addinterfaces_adds_only_new_interfaces); tcase_add_test(tc_daemon, addinterfaces_adds_to_cache_when_running); - tcase_add_exit_test(tc_daemon, preparedatabases_exits_with_no_database_dir, 1); - tcase_add_exit_test(tc_daemon, preparedatabases_exits_with_no_databases, 1); - tcase_add_exit_test(tc_daemon, preparedatabases_exits_with_no_databases_and_noadd, 1); - tcase_add_test(tc_daemon, preparedatabases_with_no_databases_creates_databases); + tcase_add_exit_test(tc_daemon, preparedatabase_exits_with_no_database_dir, 1); + tcase_add_exit_test(tc_daemon, preparedatabase_exits_with_no_database, 1); + tcase_add_exit_test(tc_daemon, preparedatabase_exits_with_no_database_and_noadd, 1); + tcase_add_test(tc_daemon, preparedatabase_with_no_database_creates_database); tcase_add_test(tc_daemon, setsignaltraps_does_not_exit); tcase_add_exit_test(tc_daemon, filldatabaselist_exits_with_no_database_dir, 1); tcase_add_test(tc_daemon, filldatabaselist_does_not_exit_with_empty_database_dir); @@ -1486,8 +1486,8 @@ tcase_add_test(tc_daemon, detectboot_sets_btime_for_new_database); tcase_add_test(tc_daemon, detectboot_can_detect_boot); tcase_add_exit_test(tc_daemon, handledatabaseerror_exits_on_fatal_error, 1); - tcase_add_test(tc_daemon, handledatabaseerror_does_not_exit_if_limit_is_not_reached); - tcase_add_exit_test(tc_daemon, handledatabaseerror_exits_if_limit_is_reached, 1); + tcase_add_test(tc_daemon, handledatabaseerror_does_not_exit_if_limit_is_not_exceeded); + tcase_add_exit_test(tc_daemon, handledatabaseerror_exits_if_limit_is_exceeded, 1); tcase_add_test(tc_daemon, cleanremovedinterfaces_allows_interfaces_to_be_removed); tcase_add_test(tc_daemon, processifinfo_syncs_when_needed); tcase_add_test(tc_daemon, processifinfo_skips_update_if_timestamps_make_no_sense); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/vnstat-2.3/tests/dbsql_tests.c new/vnstat-2.4/tests/dbsql_tests.c --- old/vnstat-2.3/tests/dbsql_tests.c 2019-07-07 22:03:41.000000000 +0200 +++ new/vnstat-2.4/tests/dbsql_tests.c 2019-08-14 20:49:10.000000000 +0200 @@ -488,6 +488,71 @@ } END_TEST +START_TEST(db_renameinterface_knows_if_interface_exists) +{ + int ret; + + defaultcfg(); + + ret = db_open_rw(1); + ck_assert_int_eq(ret, 1); + + ret = db_renameinterface("eth0", "eth1"); + ck_assert_int_eq(ret, 0); + ret = db_renameinterface("nothing", "something"); + ck_assert_int_eq(ret, 0); + ret = db_renameinterface("", ""); + ck_assert_int_eq(ret, 0); + + ret = db_close(); + ck_assert_int_eq(ret, 1); +} +END_TEST + +START_TEST(db_renameinterface_can_rename_interfaces) +{ + int ret; + + defaultcfg(); + + ret = db_open_rw(1); + ck_assert_int_eq(ret, 1); + + ret = db_addinterface("eth0"); + ck_assert_int_eq(ret, 1); + ret = db_addinterface("eth1"); + ck_assert_int_eq(ret, 1); + ret = db_addinterface("eth2"); + ck_assert_int_eq(ret, 1); + + ck_assert_int_eq(db_getinterfacecount(), 3); + ck_assert_int_eq(db_getinterfacecountbyname("eth0"), 1); + ck_assert_int_eq(db_getinterfacecountbyname("eth1"), 1); + ck_assert_int_eq(db_getinterfacecountbyname("eth2"), 1); + ck_assert_int_eq(db_getinterfacecountbyname("eth3"), 0); + + ret = db_renameinterface("eth0", "eth1"); + ck_assert_int_eq(ret, 0); + ret = db_renameinterface("eth2", "eth3"); + ck_assert_int_eq(ret, 1); + ret = db_renameinterface("eth1", "eth2"); + ck_assert_int_eq(ret, 1); + ret = db_renameinterface("eth0", ""); + ck_assert_int_eq(ret, 0); + ret = db_renameinterface("eth0", "eth1"); + ck_assert_int_eq(ret, 1); + + ck_assert_int_eq(db_getinterfacecount(), 3); + ck_assert_int_eq(db_getinterfacecountbyname("eth0"), 0); + ck_assert_int_eq(db_getinterfacecountbyname("eth1"), 1); + ck_assert_int_eq(db_getinterfacecountbyname("eth2"), 1); + ck_assert_int_eq(db_getinterfacecountbyname("eth3"), 1); + + ret = db_close(); + ck_assert_int_eq(ret, 1); +} +END_TEST + START_TEST(db_getinterfacecount_counts_interfaces) { int ret; @@ -2216,6 +2281,8 @@ tcase_add_test(tc_dbsql, db_addinterface_can_not_add_same_interface_twice); tcase_add_test(tc_dbsql, db_removeinterface_knows_if_interface_exists); tcase_add_test(tc_dbsql, db_removeinterface_can_remove_interfaces); + tcase_add_test(tc_dbsql, db_renameinterface_knows_if_interface_exists); + tcase_add_test(tc_dbsql, db_renameinterface_can_rename_interfaces); tcase_add_test(tc_dbsql, db_getcounters_with_no_interface); tcase_add_test(tc_dbsql, db_setcounters_with_no_interface); tcase_add_test(tc_dbsql, db_interface_info_manipulation);