vnstat-2.13/ 0000755 0000000 0000000 00000000000 14751712735 011470 5 ustar root root vnstat-2.13/install-sh 0000755 0000000 0000000 00000033255 13037475074 013502 0 ustar root root #!/bin/sh
# install - install a program, script, or datafile
scriptversion=2011-11-20.07; # UTC
# This originates from X11R5 (mit/util/scripts/install.sh), which was
# later released in X11R6 (xc/config/util/install.sh) with the
# following copyright and license.
#
# Copyright (C) 1994 X Consortium
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# Except as contained in this notice, the name of the X Consortium shall not
# be used in advertising or otherwise to promote the sale, use or other deal-
# ings in this Software without prior written authorization from the X Consor-
# tium.
#
#
# FSF changes to this file are in the public domain.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# 'make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch.
nl='
'
IFS=" "" $nl"
# set DOITPROG to echo to test this script
# Don't use :- since 4.3BSD and earlier shells don't like it.
doit=${DOITPROG-}
if test -z "$doit"; then
doit_exec=exec
else
doit_exec=$doit
fi
# Put in absolute file names if you don't have them in your path;
# or use environment vars.
chgrpprog=${CHGRPPROG-chgrp}
chmodprog=${CHMODPROG-chmod}
chownprog=${CHOWNPROG-chown}
cmpprog=${CMPPROG-cmp}
cpprog=${CPPROG-cp}
mkdirprog=${MKDIRPROG-mkdir}
mvprog=${MVPROG-mv}
rmprog=${RMPROG-rm}
stripprog=${STRIPPROG-strip}
posix_glob='?'
initialize_posix_glob='
test "$posix_glob" != "?" || {
if (set -f) 2>/dev/null; then
posix_glob=
else
posix_glob=:
fi
}
'
posix_mkdir=
# Desired mode of installed file.
mode=0755
chgrpcmd=
chmodcmd=$chmodprog
chowncmd=
mvcmd=$mvprog
rmcmd="$rmprog -f"
stripcmd=
src=
dst=
dir_arg=
dst_arg=
copy_on_change=false
no_target_directory=
usage="\
Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
or: $0 [OPTION]... SRCFILES... DIRECTORY
or: $0 [OPTION]... -t DIRECTORY SRCFILES...
or: $0 [OPTION]... -d DIRECTORIES...
In the 1st form, copy SRCFILE to DSTFILE.
In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
In the 4th, create DIRECTORIES.
Options:
--help display this help and exit.
--version display version info and exit.
-c (ignored)
-C install only if different (preserve the last data modification time)
-d create directories instead of installing files.
-g GROUP $chgrpprog installed files to GROUP.
-m MODE $chmodprog installed files to MODE.
-o USER $chownprog installed files to USER.
-s $stripprog installed files.
-t DIRECTORY install into DIRECTORY.
-T report an error if DSTFILE is a directory.
Environment variables override the default commands:
CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
RMPROG STRIPPROG
"
while test $# -ne 0; do
case $1 in
-c) ;;
-C) copy_on_change=true;;
-d) dir_arg=true;;
-g) chgrpcmd="$chgrpprog $2"
shift;;
--help) echo "$usage"; exit $?;;
-m) mode=$2
case $mode in
*' '* | *' '* | *'
'* | *'*'* | *'?'* | *'['*)
echo "$0: invalid mode: $mode" >&2
exit 1;;
esac
shift;;
-o) chowncmd="$chownprog $2"
shift;;
-s) stripcmd=$stripprog;;
-t) dst_arg=$2
# Protect names problematic for 'test' and other utilities.
case $dst_arg in
-* | [=\(\)!]) dst_arg=./$dst_arg;;
esac
shift;;
-T) no_target_directory=true;;
--version) echo "$0 $scriptversion"; exit $?;;
--) shift
break;;
-*) echo "$0: invalid option: $1" >&2
exit 1;;
*) break;;
esac
shift
done
if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
# When -d is used, all remaining arguments are directories to create.
# When -t is used, the destination is already specified.
# Otherwise, the last argument is the destination. Remove it from $@.
for arg
do
if test -n "$dst_arg"; then
# $@ is not empty: it contains at least $arg.
set fnord "$@" "$dst_arg"
shift # fnord
fi
shift # arg
dst_arg=$arg
# Protect names problematic for 'test' and other utilities.
case $dst_arg in
-* | [=\(\)!]) dst_arg=./$dst_arg;;
esac
done
fi
if test $# -eq 0; then
if test -z "$dir_arg"; then
echo "$0: no input file specified." >&2
exit 1
fi
# It's OK to call 'install-sh -d' without argument.
# This can happen when creating conditional directories.
exit 0
fi
if test -z "$dir_arg"; then
do_exit='(exit $ret); exit $ret'
trap "ret=129; $do_exit" 1
trap "ret=130; $do_exit" 2
trap "ret=141; $do_exit" 13
trap "ret=143; $do_exit" 15
# Set umask so as not to create temps with too-generous modes.
# However, 'strip' requires both read and write access to temps.
case $mode in
# Optimize common cases.
*644) cp_umask=133;;
*755) cp_umask=22;;
*[0-7])
if test -z "$stripcmd"; then
u_plus_rw=
else
u_plus_rw='% 200'
fi
cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
*)
if test -z "$stripcmd"; then
u_plus_rw=
else
u_plus_rw=,u+rw
fi
cp_umask=$mode$u_plus_rw;;
esac
fi
for src
do
# Protect names problematic for 'test' and other utilities.
case $src in
-* | [=\(\)!]) src=./$src;;
esac
if test -n "$dir_arg"; then
dst=$src
dstdir=$dst
test -d "$dstdir"
dstdir_status=$?
else
# Waiting for this to be detected by the "$cpprog $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if test ! -f "$src" && test ! -d "$src"; then
echo "$0: $src does not exist." >&2
exit 1
fi
if test -z "$dst_arg"; then
echo "$0: no destination specified." >&2
exit 1
fi
dst=$dst_arg
# If destination is a directory, append the input filename; won't work
# if double slashes aren't ignored.
if test -d "$dst"; then
if test -n "$no_target_directory"; then
echo "$0: $dst_arg: Is a directory" >&2
exit 1
fi
dstdir=$dst
dst=$dstdir/`basename "$src"`
dstdir_status=0
else
# Prefer dirname, but fall back on a substitute if dirname fails.
dstdir=`
(dirname "$dst") 2>/dev/null ||
expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
X"$dst" : 'X\(//\)[^/]' \| \
X"$dst" : 'X\(//\)$' \| \
X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
echo X"$dst" |
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
s//\1/
q
}
/^X\(\/\/\)[^/].*/{
s//\1/
q
}
/^X\(\/\/\)$/{
s//\1/
q
}
/^X\(\/\).*/{
s//\1/
q
}
s/.*/./; q'
`
test -d "$dstdir"
dstdir_status=$?
fi
fi
obsolete_mkdir_used=false
if test $dstdir_status != 0; then
case $posix_mkdir in
'')
# Create intermediate dirs using mode 755 as modified by the umask.
# This is like FreeBSD 'install' as of 1997-10-28.
umask=`umask`
case $stripcmd.$umask in
# Optimize common cases.
*[2367][2367]) mkdir_umask=$umask;;
.*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
*[0-7])
mkdir_umask=`expr $umask + 22 \
- $umask % 100 % 40 + $umask % 20 \
- $umask % 10 % 4 + $umask % 2
`;;
*) mkdir_umask=$umask,go-w;;
esac
# With -d, create the new directory with the user-specified mode.
# Otherwise, rely on $mkdir_umask.
if test -n "$dir_arg"; then
mkdir_mode=-m$mode
else
mkdir_mode=
fi
posix_mkdir=false
case $umask in
*[123567][0-7][0-7])
# POSIX mkdir -p sets u+wx bits regardless of umask, which
# is incompatible with FreeBSD 'install' when (umask & 300) != 0.
;;
*)
tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
if (umask $mkdir_umask &&
exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
then
if test -z "$dir_arg" || {
# Check for POSIX incompatibilities with -m.
# HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
# other-writable bit of parent directory when it shouldn't.
# FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
ls_ld_tmpdir=`ls -ld "$tmpdir"`
case $ls_ld_tmpdir in
d????-?r-*) different_mode=700;;
d????-?--*) different_mode=755;;
*) false;;
esac &&
$mkdirprog -m$different_mode -p -- "$tmpdir" && {
ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
}
}
then posix_mkdir=:
fi
rmdir "$tmpdir/d" "$tmpdir"
else
# Remove any dirs left behind by ancient mkdir implementations.
rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
fi
trap '' 0;;
esac;;
esac
if
$posix_mkdir && (
umask $mkdir_umask &&
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
)
then :
else
# The umask is ridiculous, or mkdir does not conform to POSIX,
# or it failed possibly due to a race condition. Create the
# directory the slow way, step by step, checking for races as we go.
case $dstdir in
/*) prefix='/';;
[-=\(\)!]*) prefix='./';;
*) prefix='';;
esac
eval "$initialize_posix_glob"
oIFS=$IFS
IFS=/
$posix_glob set -f
set fnord $dstdir
shift
$posix_glob set +f
IFS=$oIFS
prefixes=
for d
do
test X"$d" = X && continue
prefix=$prefix$d
if test -d "$prefix"; then
prefixes=
else
if $posix_mkdir; then
(umask=$mkdir_umask &&
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
# Don't fail if two instances are running concurrently.
test -d "$prefix" || exit 1
else
case $prefix in
*\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
*) qprefix=$prefix;;
esac
prefixes="$prefixes '$qprefix'"
fi
fi
prefix=$prefix/
done
if test -n "$prefixes"; then
# Don't fail if two instances are running concurrently.
(umask $mkdir_umask &&
eval "\$doit_exec \$mkdirprog $prefixes") ||
test -d "$dstdir" || exit 1
obsolete_mkdir_used=true
fi
fi
fi
if test -n "$dir_arg"; then
{ test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
{ test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
else
# Make a couple of temp file names in the proper directory.
dsttmp=$dstdir/_inst.$$_
rmtmp=$dstdir/_rm.$$_
# Trap to clean up those temp files at exit.
trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
# Copy the file name to the temp name.
(umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
# and set any options; do chmod last to preserve setuid bits.
#
# If any of these fail, we abort the whole thing. If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $cpprog $src $dsttmp" command.
#
{ test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
{ test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
{ test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
# If -C, don't bother to copy if it wouldn't change the file.
if $copy_on_change &&
old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
eval "$initialize_posix_glob" &&
$posix_glob set -f &&
set X $old && old=:$2:$4:$5:$6 &&
set X $new && new=:$2:$4:$5:$6 &&
$posix_glob set +f &&
test "$old" = "$new" &&
$cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
then
rm -f "$dsttmp"
else
# Rename the file to the real destination.
$doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
# The rename failed, perhaps because mv can't rename something else
# to itself, or perhaps because mv is so ancient that it does not
# support -f.
{
# Now remove or move aside any old file at destination location.
# We try this two ways since rm can't unlink itself on some
# systems and the destination file might be busy for other
# reasons. In this case, the final cleanup might fail but the new
# file should still install successfully.
{
test ! -f "$dst" ||
$doit $rmcmd -f "$dst" 2>/dev/null ||
{ $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
{ $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
} ||
{ echo "$0: cannot unlink or rename $dst" >&2
(exit 1); exit 1
}
} &&
# Now rename the file to the real destination.
$doit $mvcmd "$dsttmp" "$dst"
}
fi || exit 1
trap '' 0
fi
done
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC"
# time-stamp-end: "; # UTC"
# End:
vnstat-2.13/depcomp 0000755 0000000 0000000 00000056016 13037475074 013053 0 ustar root root #! /bin/sh
# depcomp - compile a program generating dependencies as side-effects
scriptversion=2013-05-30.07; # UTC
# Copyright (C) 1999-2013 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# Originally written by Alexandre Oliva .
case $1 in
'')
echo "$0: No command. Try '$0 --help' for more information." 1>&2
exit 1;
;;
-h | --h*)
cat <<\EOF
Usage: depcomp [--help] [--version] PROGRAM [ARGS]
Run PROGRAMS ARGS to compile a file, generating dependencies
as side-effects.
Environment variables:
depmode Dependency tracking mode.
source Source file read by 'PROGRAMS ARGS'.
object Object file output by 'PROGRAMS ARGS'.
DEPDIR directory where to store dependencies.
depfile Dependency file to output.
tmpdepfile Temporary file to use when outputting dependencies.
libtool Whether libtool is used (yes/no).
Report bugs to .
EOF
exit $?
;;
-v | --v*)
echo "depcomp $scriptversion"
exit $?
;;
esac
# Get the directory component of the given path, and save it in the
# global variables '$dir'. Note that this directory component will
# be either empty or ending with a '/' character. This is deliberate.
set_dir_from ()
{
case $1 in
*/*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;;
*) dir=;;
esac
}
# Get the suffix-stripped basename of the given path, and save it the
# global variable '$base'.
set_base_from ()
{
base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'`
}
# If no dependency file was actually created by the compiler invocation,
# we still have to create a dummy depfile, to avoid errors with the
# Makefile "include basename.Plo" scheme.
make_dummy_depfile ()
{
echo "#dummy" > "$depfile"
}
# Factor out some common post-processing of the generated depfile.
# Requires the auxiliary global variable '$tmpdepfile' to be set.
aix_post_process_depfile ()
{
# If the compiler actually managed to produce a dependency file,
# post-process it.
if test -f "$tmpdepfile"; then
# Each line is of the form 'foo.o: dependency.h'.
# Do two passes, one to just change these to
# $object: dependency.h
# and one to simply output
# dependency.h:
# which is needed to avoid the deleted-header problem.
{ sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile"
sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile"
} > "$depfile"
rm -f "$tmpdepfile"
else
make_dummy_depfile
fi
}
# A tabulation character.
tab=' '
# A newline character.
nl='
'
# Character ranges might be problematic outside the C locale.
# These definitions help.
upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ
lower=abcdefghijklmnopqrstuvwxyz
digits=0123456789
alpha=${upper}${lower}
if test -z "$depmode" || test -z "$source" || test -z "$object"; then
echo "depcomp: Variables source, object and depmode must be set" 1>&2
exit 1
fi
# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
depfile=${depfile-`echo "$object" |
sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
rm -f "$tmpdepfile"
# Avoid interferences from the environment.
gccflag= dashmflag=
# Some modes work just like other modes, but use different flags. We
# parameterize here, but still list the modes in the big case below,
# to make depend.m4 easier to write. Note that we *cannot* use a case
# here, because this file can only contain one case statement.
if test "$depmode" = hp; then
# HP compiler uses -M and no extra arg.
gccflag=-M
depmode=gcc
fi
if test "$depmode" = dashXmstdout; then
# This is just like dashmstdout with a different argument.
dashmflag=-xM
depmode=dashmstdout
fi
cygpath_u="cygpath -u -f -"
if test "$depmode" = msvcmsys; then
# This is just like msvisualcpp but w/o cygpath translation.
# Just convert the backslash-escaped backslashes to single forward
# slashes to satisfy depend.m4
cygpath_u='sed s,\\\\,/,g'
depmode=msvisualcpp
fi
if test "$depmode" = msvc7msys; then
# This is just like msvc7 but w/o cygpath translation.
# Just convert the backslash-escaped backslashes to single forward
# slashes to satisfy depend.m4
cygpath_u='sed s,\\\\,/,g'
depmode=msvc7
fi
if test "$depmode" = xlc; then
# IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information.
gccflag=-qmakedep=gcc,-MF
depmode=gcc
fi
case "$depmode" in
gcc3)
## gcc 3 implements dependency tracking that does exactly what
## we want. Yay! Note: for some reason libtool 1.4 doesn't like
## it if -MD -MP comes after the -MF stuff. Hmm.
## Unfortunately, FreeBSD c89 acceptance of flags depends upon
## the command line argument order; so add the flags where they
## appear in depend2.am. Note that the slowdown incurred here
## affects only configure: in makefiles, %FASTDEP% shortcuts this.
for arg
do
case $arg in
-c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
*) set fnord "$@" "$arg" ;;
esac
shift # fnord
shift # $arg
done
"$@"
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
mv "$tmpdepfile" "$depfile"
;;
gcc)
## Note that this doesn't just cater to obsosete pre-3.x GCC compilers.
## but also to in-use compilers like IMB xlc/xlC and the HP C compiler.
## (see the conditional assignment to $gccflag above).
## There are various ways to get dependency output from gcc. Here's
## why we pick this rather obscure method:
## - Don't want to use -MD because we'd like the dependencies to end
## up in a subdir. Having to rename by hand is ugly.
## (We might end up doing this anyway to support other compilers.)
## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
## -MM, not -M (despite what the docs say). Also, it might not be
## supported by the other compilers which use the 'gcc' depmode.
## - Using -M directly means running the compiler twice (even worse
## than renaming).
if test -z "$gccflag"; then
gccflag=-MD,
fi
"$@" -Wp,"$gccflag$tmpdepfile"
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
echo "$object : \\" > "$depfile"
# The second -e expression handles DOS-style file names with drive
# letters.
sed -e 's/^[^:]*: / /' \
-e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
## This next piece of magic avoids the "deleted header file" problem.
## The problem is that when a header file which appears in a .P file
## is deleted, the dependency causes make to die (because there is
## typically no way to rebuild the header). We avoid this by adding
## dummy dependencies for each header file. Too bad gcc doesn't do
## this for us directly.
## Some versions of gcc put a space before the ':'. On the theory
## that the space means something, we add a space to the output as
## well. hp depmode also adds that space, but also prefixes the VPATH
## to the object. Take care to not repeat it in the output.
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
| sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
hp)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
sgi)
if test "$libtool" = yes; then
"$@" "-Wp,-MDupdate,$tmpdepfile"
else
"$@" -MDupdate "$tmpdepfile"
fi
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
echo "$object : \\" > "$depfile"
# Clip off the initial element (the dependent). Don't try to be
# clever and replace this with sed code, as IRIX sed won't handle
# lines with more than a fixed number of characters (4096 in
# IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
# the IRIX cc adds comments like '#:fec' to the end of the
# dependency line.
tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \
| tr "$nl" ' ' >> "$depfile"
echo >> "$depfile"
# The second pass generates a dummy entry for each header file.
tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
>> "$depfile"
else
make_dummy_depfile
fi
rm -f "$tmpdepfile"
;;
xlc)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
aix)
# The C for AIX Compiler uses -M and outputs the dependencies
# in a .u file. In older versions, this file always lives in the
# current directory. Also, the AIX compiler puts '$object:' at the
# start of each line; $object doesn't have directory information.
# Version 6 uses the directory in both cases.
set_dir_from "$object"
set_base_from "$object"
if test "$libtool" = yes; then
tmpdepfile1=$dir$base.u
tmpdepfile2=$base.u
tmpdepfile3=$dir.libs/$base.u
"$@" -Wc,-M
else
tmpdepfile1=$dir$base.u
tmpdepfile2=$dir$base.u
tmpdepfile3=$dir$base.u
"$@" -M
fi
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
exit $stat
fi
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
do
test -f "$tmpdepfile" && break
done
aix_post_process_depfile
;;
tcc)
# tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26
# FIXME: That version still under development at the moment of writing.
# Make that this statement remains true also for stable, released
# versions.
# It will wrap lines (doesn't matter whether long or short) with a
# trailing '\', as in:
#
# foo.o : \
# foo.c \
# foo.h \
#
# It will put a trailing '\' even on the last line, and will use leading
# spaces rather than leading tabs (at least since its commit 0394caf7
# "Emit spaces for -MD").
"$@" -MD -MF "$tmpdepfile"
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
# Each non-empty line is of the form 'foo.o : \' or ' dep.h \'.
# We have to change lines of the first kind to '$object: \'.
sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile"
# And for each line of the second kind, we have to emit a 'dep.h:'
# dummy dependency, to avoid the deleted-header problem.
sed -n -e 's|^ *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile"
rm -f "$tmpdepfile"
;;
## The order of this option in the case statement is important, since the
## shell code in configure will try each of these formats in the order
## listed in this file. A plain '-MD' option would be understood by many
## compilers, so we must ensure this comes after the gcc and icc options.
pgcc)
# Portland's C compiler understands '-MD'.
# Will always output deps to 'file.d' where file is the root name of the
# source file under compilation, even if file resides in a subdirectory.
# The object file name does not affect the name of the '.d' file.
# pgcc 10.2 will output
# foo.o: sub/foo.c sub/foo.h
# and will wrap long lines using '\' :
# foo.o: sub/foo.c ... \
# sub/foo.h ... \
# ...
set_dir_from "$object"
# Use the source, not the object, to determine the base name, since
# that's sadly what pgcc will do too.
set_base_from "$source"
tmpdepfile=$base.d
# For projects that build the same source file twice into different object
# files, the pgcc approach of using the *source* file root name can cause
# problems in parallel builds. Use a locking strategy to avoid stomping on
# the same $tmpdepfile.
lockdir=$base.d-lock
trap "
echo '$0: caught signal, cleaning up...' >&2
rmdir '$lockdir'
exit 1
" 1 2 13 15
numtries=100
i=$numtries
while test $i -gt 0; do
# mkdir is a portable test-and-set.
if mkdir "$lockdir" 2>/dev/null; then
# This process acquired the lock.
"$@" -MD
stat=$?
# Release the lock.
rmdir "$lockdir"
break
else
# If the lock is being held by a different process, wait
# until the winning process is done or we timeout.
while test -d "$lockdir" && test $i -gt 0; do
sleep 1
i=`expr $i - 1`
done
fi
i=`expr $i - 1`
done
trap - 1 2 13 15
if test $i -le 0; then
echo "$0: failed to acquire lock after $numtries attempts" >&2
echo "$0: check lockdir '$lockdir'" >&2
exit 1
fi
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
# Each line is of the form `foo.o: dependent.h',
# or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
# Do two passes, one to just change these to
# `$object: dependent.h' and one to simply `dependent.h:'.
sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
# Some versions of the HPUX 10.20 sed can't process this invocation
# correctly. Breaking it into two sed invocations is a workaround.
sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \
| sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
hp2)
# The "hp" stanza above does not work with aCC (C++) and HP's ia64
# compilers, which have integrated preprocessors. The correct option
# to use with these is +Maked; it writes dependencies to a file named
# 'foo.d', which lands next to the object file, wherever that
# happens to be.
# Much of this is similar to the tru64 case; see comments there.
set_dir_from "$object"
set_base_from "$object"
if test "$libtool" = yes; then
tmpdepfile1=$dir$base.d
tmpdepfile2=$dir.libs/$base.d
"$@" -Wc,+Maked
else
tmpdepfile1=$dir$base.d
tmpdepfile2=$dir$base.d
"$@" +Maked
fi
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile1" "$tmpdepfile2"
exit $stat
fi
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
do
test -f "$tmpdepfile" && break
done
if test -f "$tmpdepfile"; then
sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile"
# Add 'dependent.h:' lines.
sed -ne '2,${
s/^ *//
s/ \\*$//
s/$/:/
p
}' "$tmpdepfile" >> "$depfile"
else
make_dummy_depfile
fi
rm -f "$tmpdepfile" "$tmpdepfile2"
;;
tru64)
# The Tru64 compiler uses -MD to generate dependencies as a side
# effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'.
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
# dependencies in 'foo.d' instead, so we check for that too.
# Subdirectories are respected.
set_dir_from "$object"
set_base_from "$object"
if test "$libtool" = yes; then
# Libtool generates 2 separate objects for the 2 libraries. These
# two compilations output dependencies in $dir.libs/$base.o.d and
# in $dir$base.o.d. We have to check for both files, because
# one of the two compilations can be disabled. We should prefer
# $dir$base.o.d over $dir.libs/$base.o.d because the latter is
# automatically cleaned when .libs/ is deleted, while ignoring
# the former would cause a distcleancheck panic.
tmpdepfile1=$dir$base.o.d # libtool 1.5
tmpdepfile2=$dir.libs/$base.o.d # Likewise.
tmpdepfile3=$dir.libs/$base.d # Compaq CCC V6.2-504
"$@" -Wc,-MD
else
tmpdepfile1=$dir$base.d
tmpdepfile2=$dir$base.d
tmpdepfile3=$dir$base.d
"$@" -MD
fi
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
exit $stat
fi
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
do
test -f "$tmpdepfile" && break
done
# Same post-processing that is required for AIX mode.
aix_post_process_depfile
;;
msvc7)
if test "$libtool" = yes; then
showIncludes=-Wc,-showIncludes
else
showIncludes=-showIncludes
fi
"$@" $showIncludes > "$tmpdepfile"
stat=$?
grep -v '^Note: including file: ' "$tmpdepfile"
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
echo "$object : \\" > "$depfile"
# The first sed program below extracts the file names and escapes
# backslashes for cygpath. The second sed program outputs the file
# name when reading, but also accumulates all include files in the
# hold buffer in order to output them again at the end. This only
# works with sed implementations that can handle large buffers.
sed < "$tmpdepfile" -n '
/^Note: including file: *\(.*\)/ {
s//\1/
s/\\/\\\\/g
p
}' | $cygpath_u | sort -u | sed -n '
s/ /\\ /g
s/\(.*\)/'"$tab"'\1 \\/p
s/.\(.*\) \\/\1:/
H
$ {
s/.*/'"$tab"'/
G
p
}' >> "$depfile"
echo >> "$depfile" # make sure the fragment doesn't end with a backslash
rm -f "$tmpdepfile"
;;
msvc7msys)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
#nosideeffect)
# This comment above is used by automake to tell side-effect
# dependency tracking mechanisms from slower ones.
dashmstdout)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout, regardless of -o.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test "X$1" != 'X--mode=compile'; do
shift
done
shift
fi
# Remove '-o $object'.
IFS=" "
for arg
do
case $arg in
-o)
shift
;;
$object)
shift
;;
*)
set fnord "$@" "$arg"
shift # fnord
shift # $arg
;;
esac
done
test -z "$dashmflag" && dashmflag=-M
# Require at least two characters before searching for ':'
# in the target name. This is to cope with DOS-style filenames:
# a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise.
"$@" $dashmflag |
sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile"
rm -f "$depfile"
cat < "$tmpdepfile" > "$depfile"
# Some versions of the HPUX 10.20 sed can't process this sed invocation
# correctly. Breaking it into two sed invocations is a workaround.
tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
| sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
dashXmstdout)
# This case only exists to satisfy depend.m4. It is never actually
# run, as this mode is specially recognized in the preamble.
exit 1
;;
makedepend)
"$@" || exit $?
# Remove any Libtool call
if test "$libtool" = yes; then
while test "X$1" != 'X--mode=compile'; do
shift
done
shift
fi
# X makedepend
shift
cleared=no eat=no
for arg
do
case $cleared in
no)
set ""; shift
cleared=yes ;;
esac
if test $eat = yes; then
eat=no
continue
fi
case "$arg" in
-D*|-I*)
set fnord "$@" "$arg"; shift ;;
# Strip any option that makedepend may not understand. Remove
# the object too, otherwise makedepend will parse it as a source file.
-arch)
eat=yes ;;
-*|$object)
;;
*)
set fnord "$@" "$arg"; shift ;;
esac
done
obj_suffix=`echo "$object" | sed 's/^.*\././'`
touch "$tmpdepfile"
${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
rm -f "$depfile"
# makedepend may prepend the VPATH from the source file name to the object.
# No need to regex-escape $object, excess matching of '.' is harmless.
sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile"
# Some versions of the HPUX 10.20 sed can't process the last invocation
# correctly. Breaking it into two sed invocations is a workaround.
sed '1,2d' "$tmpdepfile" \
| tr ' ' "$nl" \
| sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
| sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile" "$tmpdepfile".bak
;;
cpp)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test "X$1" != 'X--mode=compile'; do
shift
done
shift
fi
# Remove '-o $object'.
IFS=" "
for arg
do
case $arg in
-o)
shift
;;
$object)
shift
;;
*)
set fnord "$@" "$arg"
shift # fnord
shift # $arg
;;
esac
done
"$@" -E \
| sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
-e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
| sed '$ s: \\$::' > "$tmpdepfile"
rm -f "$depfile"
echo "$object : \\" > "$depfile"
cat < "$tmpdepfile" >> "$depfile"
sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
msvisualcpp)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test "X$1" != 'X--mode=compile'; do
shift
done
shift
fi
IFS=" "
for arg
do
case "$arg" in
-o)
shift
;;
$object)
shift
;;
"-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
set fnord "$@"
shift
shift
;;
*)
set fnord "$@" "$arg"
shift
shift
;;
esac
done
"$@" -E 2>/dev/null |
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
rm -f "$depfile"
echo "$object : \\" > "$depfile"
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile"
echo "$tab" >> "$depfile"
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
rm -f "$tmpdepfile"
;;
msvcmsys)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
none)
exec "$@"
;;
*)
echo "Unknown depmode $depmode" 1>&2
exit 1
;;
esac
exit 0
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC"
# time-stamp-end: "; # UTC"
# End:
vnstat-2.13/man/ 0000755 0000000 0000000 00000000000 14751712735 012243 5 ustar root root vnstat-2.13/man/vnstat.conf.5 0000644 0000000 0000000 00000046453 14751654012 014601 0 ustar root root .TH VNSTAT.CONF 5 "FEBRUARY 2025" "version 2.13" "User Manuals"
.SH NAME
vnstat.conf \- vnStat configuration file
.SH SYNOPSIS
.B /etc/vnstat.conf
.SH DESCRIPTION
.BR vnstat (1),
.BR vnstati (1)
and
.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
lines starting with '#' or ';' are interpreted as comments and not processed.
Arguments may optionally be enclosed in double quotes (") in order
to represent arguments containing spaces. Arguments can be padded
with spaces or tabulator characters. A hardcoded default value
will be used if a keyword can't be found from the configuration file or
if the configured value cannot be parsed or is outside supported value range.
.PP
The configuration file is divided into three sections based on the
usage of each keyword. The first section contains keywords that are
considered common for all commands, the second section is for
daemon related keywords and the last section is for image output.
.SH COMMON KEYWORDS
.TP
.B DatabaseDir
Specifies the directory where the database is to be stored.
A full path must be given and a leading '/' isn't required.
.TP
.B "DayFormat, MonthFormat, TopFormat"
Formatting of date in available outputs. Uses the same format as
.BR date (1).
(vnstat and vnstati only)
.TP
.B DefaultDecimals
Number of decimals to use in outputs. Value range: 0..2
(vnstat and vnstati only)
.TP
.B EstimateBarVisible
Show a visual representation of the traffic estimation if
.B OutputStyle
has been configured with a value of 1 or 2 to make the bar column visible.
1 = enabled, 0 = disabled.
(vnstat only, see
.B EstimateStyle
for vnstati)
.TP
.B EstimateText
Replace default "estimated" text on the estimate line with custom text.
Limited to 9 characters. (vnstat and vnstati only)
.TP
.B EstimateVisible
Show a line with traffic estimation for the selected time period or alert as the
last line of the output in output modes supporting it. Disabling estimate visibility
also disables estimate conditions in
.BR "--alert" "."
1 = enabled, 0 = disabled. (vnstat and vnstati only)
.TP
.B HourlyDecimals
Number of decimals to use in hourly graph output. Value range: 0..2
(vnstat only)
.TP
.B HourlySectionStyle
Select what kind of spacer is used for separating the numerical sections of the
hourly graph output. 0 = none, 1 = '|', 2 = '][', 3 = '[ ]'.
(vnstat only)
.TP
.B Interface
Default interface used when no other interface is specified on the command
line. Leave empty for automatic selection. The automatic selection will
prioritize the interface with most traffic for outputs doing database queries.
Queries not using the database will first check if the database is available
and select the interface with most traffic out those that are currently
visible in the system. If no database can be read then the first available
interface will be used. (vnstat and vnstati only)
.TP
.B InterfaceMatchMethod
Method for matching interface given for a query to an interface in the
database.
Method 0 requires the interface name to be a case sensitive exact
match. Method 1 extends the previous method by allowing a case sensitive
exact match of the interface alias. Method 2 extends the previous method
by allowing a case insensitive exact match of the interface alias. Method
3 extends the previous method by allowing a case insensitive match of the
beginning of the interface alias.
Methods will be evaluated in the order described above resulting in exact
interface matches always taking precedence. If any interface alias matching
method results in multiple matches then the interface with the highest total
traffic will be used. (vnstat and vnstati only)
.TP
.B InterfaceOrder
Interface order in outputs with multiple interfaces. 0 = alphabetical
by name, 1 = alphabetical by alias. If 1 is selected and multiple interfaces
don't have aliases then the interface name will be used for defining the order.
(vnstat only)
.TP
.B "List5Mins, ListHours, ListDays, ListMonths, ListYears, ListTop"
Number of entries to show in list outputs unless overridden from the command line.
Set to 0 to show all entries available in the database.
(vnstat and vnstati)
.TP
.B LiveSpinner
Show spinning animation at the beginning of
.BR "-l" " /"
.B "--live"
output line. 1 = enabled, 0 = disabled. (vnstat only)
.TP
.B Locale
Locale setting to be used for prints. This replaces the LC_ALL
environment variable. Set to "-" or leave empty in order to use the
system default value. (vnstat and vnstati only)
.TP
.B OutputStyle
Modify the content and style of text outputs. 0 = minimal and
narrow output for terminal with limited width, 1 = normal output with
bar column visible, 2 = same as 1 except rate is visible in summary
output, 3 = rate column is visible in all outputs where it is supported.
(vnstat and vnstati only)
.TP
.B QueryMode
Default query mode when no parameters are given. 0 = summary, 1 = days,
2 = months, 3 = top, 4 = single summary, 5 = short, 6 = years, 7 = hours graph,
8 = xml, 9 = one line, 10 = json, 11 = hours and 12 = 5 minute. (vnstat only)
.TP
.B RateUnit
Select which unit is used when traffic rate is visible. 0 = bytes, 1 = bits.
(vnstat and vnstati only)
.TP
.B RateUnitMode
Select used prefix when traffic rate is shown in bits per second.
IEC binary prefixes are calculated with powers of 1024. SI decimal
prefixes are calculated with powers of 1000.
0 = IEC binary prefixes (Kibit/s...), 1 = SI decimal prefixes (kbit/s...).
(vnstat and vnstati only)
.TP
.B "RXCharacter, TXCharacter"
Character used for representing the percentual share of received
and transmitted traffic in list mode outputs. (vnstat only)
.TP
.B "RXHourCharacter, TXHourCharacter"
Character used for representing the percentual share of received
and transmitted traffic in hourly graph output. (vnstat only)
.TP
.B Sampletime
Defines how many seconds the
.B "-tr"
option will sample traffic. Value range: 2..600 (vnstat only)
.TP
.B UnitMode
Select how units are prefixed. IEC and JEDEC binary prefixes are calculated
with powers of 1024. SI decimal prefixes are calculated with powers of 1000.
0 = IEC standard prefixes (B/KiB/MiB/GiB...), 1 = old style (JEDEC)
binary prefixes (B/KB/MB/GB...), 2 = SI decimals prefixes (B/kB/MB/GB...)
(vnstat and vnstati only)
.SH DAEMON RELATED KEYWORDS
.TP
.B 5MinuteHours
Data retention duration for the 5 minute resolution entries. The configuration
defines for how many past hours entries will be stored. Set to -1 for
unlimited entries or to 0 to disable the data collection of this
resolution.
.TP
.B 64bitInterfaceCounters
Select interface counter handling. Set to 1 for defining that all interfaces
use 64-bit counters on the kernel side and 0 for defining 32-bit counter. Set
to -1 for using the old style logic used in earlier versions where counter
values within 32-bits are assumed to be 32-bit and anything larger is assumed to
be a 64-bit counter. This may produce false results if a 64-bit counter is
reset within the 32-bits. Set to -2 for using automatic detection based on
available kernel datastructures.
.TP
.B AlwaysAddNewInterfaces
Enable or disable automatic creation of new database entries for interfaces not
currently in the database even if the database file already exists 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 always
excluded from getting added.
1 = enabled, 0 = disabled.
.TP
.B BandwidthDetection
Try to automatically detect
.B MaxBandwidth
value for each monitored interface. Mostly only ethernet interfaces support
this feature.
.B MaxBandwidth
will be used as fallback value if detection fails. Any interface specific
.B MaxBW
configuration will disable the detection for the specified interface.
In Linux, the detection is disabled for tun interfaces due to the
Linux kernel always reporting 10 Mbit regardless of the used real interface.
1 = enabled, 0 = disabled.
.TP
.B BandwidthDetectionInterval
How often in minutes interface specific detection of
.B MaxBandwidth
is done for detecting possible changes when
.B BandwidthDetection
is enabled. Can be disabled by setting to 0. Value range: 0..30
.TP
.B BootVariation
Time in seconds how much the boot time reported by system kernel can variate
between updates. Value range: 0..300
.TP
.B CheckDiskSpace
Enable or disable the availability check of at least some free disk space before
a database write. 1 = enabled, 0 = disabled.
.TP
.B CreateDirs
Enable or disable the creation of directories when a configured path doesn't
exist. This includes
.B DatabaseDir
,
.B LogFile
and
.B PidFile
directories. The
.B LogFile
directory will be created only when
.B UseLogging
has been set to 1. The
.B PidFile
directory will be created only if the daemon is started as a background process.
The daemon process will try to create the directory using permissions of the
user used to start the process.
.TP
.B DaemonGroup
Specify the group to which the daemon process should switch during startup.
The group can either be the name of the group or a numerical group id.
Leave empty to disable group switching. This option can only be used when
the process is started as root.
.TP
.B DaemonUser
Specify the user to which the daemon process should switch during startup.
The user can either be the login of the user or a numerical user id.
Leave empty to disable user switching. This option can only be used when
the process is started as root.
.TP
.B DailyDays
Data retention duration for the one day resolution entries. The configuration
defines for how many past days entries will be stored. Set to -1 for
unlimited entries or to 0 to disable the data collection of this
resolution.
.TP
.B DatabaseSynchronous
Change the setting of the SQLite "synchronous" flag which controls how much
care is taken to ensure disk writes have fully completed when writing data to
the database before continuing other actions. Higher values take extra steps
to ensure data safety at the cost of slower performance. A value of 0 will
result in all handling being left to the filesystem itself. Set to -1 to
select the default value according to database mode controlled by
.B DatabaseWriteAheadLogging
setting. See SQLite documentation for more details regarding values from 1
to 3. Value range: -1..3
.TP
.B DatabaseWriteAheadLogging
Enable or disable SQLite Write-Ahead Logging mode for the database. See SQLite
documentation for more details and note that support for read-only operations
isn't available in older SQLite versions. 1 = enabled, 0 = disabled.
.TP
.B HourlyDays
Data retention duration for the one hour resolution entries. The configuration
defines for how many past days entries will be stored. Set to -1 for
unlimited entries or to 0 to disable the data collection of this
resolution.
.TP
.B LogFile
Specify log file path and name to be used if UseLogging is set to 1.
.TP
.B MaxBandwidth
Maximum bandwidth for all interfaces. If the interface specific traffic
exceeds the given value then the data is assumed to be invalid and rejected.
Set to 0 in order to disable the feature. Value range: 0..50000
.TP
.B MaxBW
Same as
.B MaxBandwidth
but can be used for setting individual limits
for selected interfaces. The name of the interface is specified directly
after the MaxBW keyword without spaces. For example MaxBWeth0 for eth0
and MaxBWppp0 for ppp0.
.B BandwidthDetection
is disabled on an interface specific level for each
.B MaxBW
configuration. Value range: 0..50000
.TP
.B MonthlyMonths
Data retention duration for the one month resolution entries. The configuration
defines for how many past months entries will be stored. Set to -1 for
unlimited entries or to 0 to disable the data collection of this
resolution.
.TP
.B MonthRotate
Day of month that months are expected to change. Usually set to
1 but can be set to alternative values for example for tracking
monthly billed traffic where the billing period doesn't start on
the first day. For example, if set to 7, days of February up to and
including the 6th will count for January. Changing this option will
not cause existing data to be recalculated. Value range: 1..28
.TP
.B MonthRotateAffectsYears
Enable or disable
.B MonthRotate
also affecting yearly data. Applicable only when
.B MonthRotate
has a value greater than one. 1 = enabled, 0 = disabled.
.TP
.B OfflineSaveInterval
How often in minutes cached interface data is saved to file when all monitored
interfaces are offline. Value range:
.BR SaveInterval "..60"
.TP
.B PidFile
Specify pid file path and name to be used. The file is created only if the
daemon is started as a background process.
.TP
.B PollInterval
How often in seconds interfaces are checked for status changes.
Value range: 2..60
.TP
.B RescanDatabaseOnSave
Automatically discover added interfaces from the database and start monitoring.
The rescan is done every
.B SaveInterval
or
.B OfflineSaveInterval
minutes depending on the current activity state.
1 = enabled, 0 = disabled.
.TP
.B SaveInterval
How often in minutes cached interface data is saved to file.
Value range: (
.BR UpdateInterval " / 60 )..60"
.TP
.B SaveOnStatusChange
Enable or disable the additional saving to file of cached interface data
when the availability of an interface changes, i.e., when an interface goes
offline or comes online. 1 = enabled, 0 = disabled.
.TP
.B TimeSyncWait
How many minutes to wait during daemon startup for system clock to sync if
most recent database update appears to be in the future. This may be needed
in systems without a real-time clock (RTC) which require some time after boot
to query and set the correct time. 0 = wait disabled.
Value range: 0..60
.TP
.B TopDayEntries
Data retention duration for the top day entries. The configuration
defines how many of the past top day entries will be stored. Set to -1 for
unlimited entries or to 0 to disable the data collection of this
resolution.
.TP
.B TrafficlessEntries
Create database entries even when there is no traffic during the entry's time
period. 1 = enabled, 0 = disabled.
.TP
.B UpdateFileOwner
Enable or disable the update of file ownership during daemon process startup.
During daemon startup, only database, log and pid files will be modified if the
user or group change feature (
.B DaemonUser
or
.B DaemonGroup
) is enabled and the files don't match the requested user or group. During manual
database creation, this option will cause file ownership to be inherited from the
database directory if the directory already exists. This option only has effect
when the process is started as root or via sudo.
.TP
.B UpdateInterval
How often in seconds the interface data is updated. Value range:
.BR PollInterval "..300"
.TP
.B UseLogging
Enable or disable logging. This option is ignored when the daemon is started with
.B "-n, --nodaemon"
which results in all log output being shown in terminal the daemon process is using.
0 = disabled, 1 = logfile and 2 = syslog.
.TP
.B UseUTC
Enable or disable using UTC as timezone in the database for all entries. When
enabled, all entries added to the database will use UTC regardless of the
configured system timezone. When disabled, the configured system timezone
will be used. Changing this setting will not result in already existing
data to be modified. 1 = enabled, 0 = disabled.
.TP
.B VacuumOnHUPSignal
Enable or disable the execution of SQLite VACUUM command after the daemon has received
a HUP signal. When enabled, the database file is rebuilt and repacked into a minimal amount
of disk space. The difference in size can be notable especially if data retention
durations have been reduced or previously monitored interfaces removed from the database.
1 = enabled, 0 = disabled.
.TP
.B VacuumOnStartup
Enable or disable the execution of SQLite VACUUM command during daemon startup.
When enabled, the database file is rebuilt and repacked into a minimal amount
of disk space. The difference in size can be notable especially if data retention
durations have been reduced or previously monitored interfaces removed from the database.
1 = enabled, 0 = disabled.
.TP
.B YearlyYears
Data retention duration for the one year resolution entries. The configuration
defines for how many past years entries will be stored. Set to -1 for
unlimited entries or to 0 to disable the data collection of this
resolution.
.SH IMAGE OUTPUT RELATED KEYWORDS
.TP
.B 5MinuteGraphResultCount
Number of 5 minute periods to be included in the 5 minute resolution graph.
The value affects the width of the graph. Value range: 288..2000
.TP
.B 5MinuteGraphHeight
Height of 5 minute resolution graph in pixels. Value range: 150..2000
.TP
.B BarColumnShowsRate
The bar column represents traffic rate in list outputs when enabled. Requires
also that
.B OutputStyle
has been configured to show the traffic rate column by using the value 3.
Enabling this option will automatically cause
.B EstimateStyle
to have the value 0. Visually this option affects only the color legend text and
the last line on the list if that line represents the currently ongoing time
period. 1 = enabled, 0 = disabled.
.TP
.B CBackground
Background color.
.TP
.B CEdge
Edge color, if visible.
.TP
.B CHeader
Header background color.
.TP
.B CHeaderTitle
Header title text color.
.TP
.B CHeaderDate
Header date text color.
.TP
.B CLine
Line color.
.TP
.B CLineL
Lighter version of line color. Set to '-' in order to use a calculated
value based on
.BR CLine .
.TP
.B CPercentileLine
95th percentile line color. Used only in 95th percentile graph.
.TP
.B CRx
Color for received data.
.TP
.B CRxD
Darker version of received data color. Set to '-' in order to use
a calculated value based on
.BR CRx .
.TP
.B CText
Common text color.
.TP
.B CTotal
Color for total data, sum of received and transmitted data.
Used only in 95th percentile graph.
.TP
.B CTx
Color for transmitted data.
.TP
.B CTxD
Darker version of transmitted data color. Set to '-' in order to use
a calculated value based on
.BR CTx .
.TP
.B EstimateStyle
Show a visual representation of the traffic estimation.
0 = not shown, 1 = continuation of existing bar, 2 = separate bar.
.TP
.B HeaderFormat
Formatting of date in header. Uses the same format as
.BR date (1).
.TP
.B HourlyGraphMode
Select the output mode of the hourly graph. 0 = 24 hour sliding window,
1 = graph begins from midnight.
.TP
.B HourlyRate
Show hours with rate instead of transferred amount. 1 = enabled, 0 = disabled.
.TP
.B ImageScale
Scale output to given percent. Value range: 50..500
.TP
.B LargeFonts
Increase the size of used fonts. 1 = enabled, 0 = disabled.
.TP
.B LineSpacingAdjustment
Adjust line spacing in list format outputs. Positive values increase the
space between lines while negative values reduce it. Value range: -5..10
.TP
.B SummaryGraph
Select which graph style output is shown next to the summary data in the
horizontal and vertical summary outputs. 0 = hours, 1 = 5 minutes.
.TP
.B SummaryRate
Show rate in summary output if available. 1 = enabled, 0 = disabled.
.TP
.B TransparentBg
Set background color as transparent. 1 = enabled, 0 = disabled.
.SH FILES
.TP
.I /etc/vnstat.conf
Config file that will be used unless
.I $HOME/.vnstatrc
exists or alternative value is given as command line parameter.
.SH RESTRICTIONS
Using long date output formats may cause misalignment in shown columns if the
length of the date exceeds the fixed size allocation.
.SH AUTHOR
Teemu Toivola
.SH "SEE ALSO"
.BR vnstat (1),
.BR vnstati (1),
.BR vnstatd (8),
.BR units (7)
vnstat-2.13/man/vnstat.1 0000644 0000000 0000000 00000052675 14751653774 013672 0 ustar root root '\" t
.TH VNSTAT 1 "FEBRUARY 2025" "version 2.13" "User Manuals"
.SH NAME
vnstat \- a console-based network traffic monitor
.SH SYNOPSIS
.B vnstat
.RB [ \-5bDedhlmqstvy? ]
.RB [ \-\-95th ]
.RB [ \-\-add ]
.RB [ \-\-alert
.IR "output exit type condition limit unit" ]
.RB [ \-\-begin
.IR date ]
.RB [ \-\-config
.IR file ]
.RB [ \-\-days
.RI [ limit ]]
.RB [ \-\-db
.IR file ]
.RB [ \-\-dbdir
.IR directory ]
.RB [ \-\-dbiflist
.RI [ mode ]]
.RB [ \-\-debug ]
.RB [ \-\-end
.IR date ]
.RB [ \-\-fiveminutes
.RI [ limit ]]
.RB [ \-\-help ]
.RB [ \-hg ]
.RB [ \-\-hours
.RI [ limit ]]
.RB [ \-\-hoursgraph ]
.RB [ \-i
.IR interface ]
.RB [ \-\-iface
.IR interface ]
.RB [ \-\-iflist
.RI [ mode ]]
.RB [ \-\-json
.RI [ mode ]
.RI [ limit ]]
.RB [ \-\-limit
.IR limit ]
.RB [ \-\-live
.RI [ mode ]]
.RB [ \-\-locale
.IR locale ]
.RB [ \-\-longhelp ]
.RB [ \-\-merge
.IR "source destination" ]
.RB [ \-\-months
.RI [ limit ]]
.RB [ \-\-oneline
.RI [ mode ]]
.RB [ \-\-query
.RI [ mode ]]
.RB [ \-\-rateunit
.RI [ mode ]]
.RB [ \-\-remove ]
.RB [ \-\-rename
.IR name ]
.RB [ \-ru
.RI [ mode ]]
.RB [ \-\-setalias
.IR alias ]
.RB [ \-\-short ]
.RB [ \-\-showconfig ]
.RB [ \-\-style
.IR number ]
.RB [ \-\-top
.RI [ limit ]]
.RB [ \-tr
.RI [ time ]]
.RB [ \-\-traffic
.RI [ time ]]
.RB [ \-\-version ]
.RB [ \-\-xml
.RI [ mode ]
.RI [ limit ]]
.RB [ \-\-years
.RI [ limit ]]
.RI [ interface ]
.SH DESCRIPTION
.B vnStat
is a console-based network traffic monitor. It keeps a log of 5 minute interval,
hourly, daily, monthly and yearly network traffic for the selected interface(s).
However, it isn't a packet sniffer. The traffic information is read from the
.BR proc (5)
or
.B sys
filesystems depending on availability resulting in light use of system resources
regardless of network traffic rate. That way vnStat can be used even
without root permissions on most systems.
.PP
Functionality is divided into two commands. The purpose of the
.B vnstat
command is to provide an interface for querying the traffic information stored
in the database whereas the daemon
.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.
.SH OPTIONS
.TP
.B "--95th"
Show 95th percentile output for the ongoing month. This output uses the 5 minute resolution
data of the ongoing month to calculate the 95th percentile traffic rate for received, transmitted
and total. In addition, the minimum, average and maximum traffic rates for received, transmitted
and total are also shown. This output requires the
.B 5MinuteHours
configuration option to have a value of at least 744 for storing all the necessary data, otherwise 100% coverage
isn't possible.
.TP
.B "--add"
Create database entry for interface specified with
.B \-i
or
.B \-\-iface
option. The daemon can be running during this operation and will automatically
start monitoring the interface without a restart within
.B SaveInterval
minutes if configuration option
.B RescanDatabaseOnSave
is enabled. Otherwise the daemon needs to be restarted in order for the
added interface to be monitored.
.TP
.BI "--alert " "output exit type condition limit unit"
Depending on values of given parameters, show alert, use different exit
status or a combination of both when configured situation is met.
.IP
.I output
parameter takes a number from 0 to 3 and controls when, if at all, the command
will result in output. '0' never produces output, '1' always produces output, '2'
shows output only when usage estimate exceeds
.I limit
and '3' shows output only when
.I limit
is exceeded.
.IP
.I exit
parameter takes a number from 0 to 5 and controls the exit status of the
command. '0' always uses exit status 0, '1' always uses exit status 1, '2'
uses exit status 1 if usage estimate exceeds
.I limit
but otherwise exit status 0 and '3' uses exit status 1 if
.I limit
is exceeded but otherwise exit status 0. '4' and '5' are equivalents of '2'
and '3' with the difference that exit status 2 is used instead of exit
status 1 when the condition is met. This can help differentiate alerts from
errors as errors will always use exit status 1.
.IP
.I type
parameter defines to which time range type usage the
.I limit
is compared against. Available options: 'h', 'hour', 'hourly', 'd', 'day', 'daily', 'm', 'month', 'monthly', 'y', 'year', 'yearly', 'p', '95', '95%'.
.IP
.I condition
parameter defines if
.I limit
is compared to received (rx), transmitted (tx), total or estimated usage of these three.
Available options: 'rx', 'tx', 'total', 'rx_estimate', 'tx_estimate', 'total_estimate'.
Estimate options aren't available for 95th percentile
.IR type .
.IP
.I limit
is a greater than zero integer without decimals which defines the traffic usage
limit using the unit defined with the
.I unit
parameter.
.I unit
accepts the following options: 'B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB'.
For 95th percentile
.I type
the following options are available: 'B/s', 'KiB/s', 'MiB/s', 'GiB/s', 'TiB/s', 'PiB/s', 'EiB/s', 'kB/s', 'MB/s', 'GB/s', 'TB/s', 'PB/s', 'EB/s', 'bit/s', 'Kibit/s', 'Mibit/s', 'Gibit/s', 'Tibit/s', 'Pibit/s', 'Eibit/s', 'kbit/s', 'Mbit/s', 'Gbit/s', 'Tbit/s', 'Pbit/s', 'Ebit/s'.
Usage must exceed
.I limit
in order for the alarm to activate. Exactly the same usage as
.I limit
does not raise the alarm.
.IP
Estimate calculation isn't limited to the estimate options
in
.I condition
parameter but can also be achieved by using the estimate option in
.I output
or
.I exit
parameters. Missing or invalid parameters or parameter combination will result in
.B "--alert"
specific help output being shown.
.TP
.BI "-b, --begin " date
Begin the list output with a specific date / time defined by
.I date
instead of the begin being selected based on the number of entries to be shown.
If
.I date
isn't available in the database then the closest later date will be used.
.I date
supports the following formats: YYYY-MM-DD HH:MM, YYYY-MM-DD and "today".
This option can only be used with
.B "--json"
,
.B "--xml"
and list outputs.
.TP
.BI "--config " file
Use
.I file
as configuration file instead of using automatic configuration file search
functionality. If
.B "--config"
is used multiple times, the configuration settings from files later on the command line
will override configuration settings loaded from earlier files if the settings defined
in the files overlap.
.TP
.BI "-d, --days " [limit]
Show traffic statistics on a daily basis for the last days. The length of the list
will be limited to 30 entries unless configured otherwise or unless the optional
.I limit
parameter is used. All entries stored in the database will be shown if
.I limit
is set to 0.
.TP
.BI "--db " file
Use
.I file
as database file instead of searching for a database from the directory specified in
the configuration file or the hardcoded default if no configuration file is available.
This option overrides
.BR "--dbdir" .
.TP
.BI "--dbdir " directory
Use
.I directory
as database directory instead of using the directory specified in the configuration
file or the hardcoded default if no configuration file is available. This option is
ignored if
.B "--db"
is also defined.
.TP
.BI "--dbiflist " [mode]
List interfaces currently in the database. If
.I mode
is not defined or is set to 0 then the output will use a one line verbose format. If
.I mode
is set to 1 then the output will contain one interface per line and if
.I mode
is set to 2 then only the interface count will be shown as a single number. See also
.BR "--iflist" .
.TP
.B "-D, --debug"
Show additional debug output.
.TP
.BI "-e, --end " date
End the list output with a specific date / time defined by
.I date
instead of the latest date / time in the database. If
.I date
isn't available in the database then the closest earlier date will be used.
.I date
supports the following formats: YYYY-MM-DD HH:MM and YYYY-MM-DD.
This option can only be used with
.B "--json"
,
.B "--xml"
and list outputs. In list outputs the estimate line is replaced with
a sum line with values representing the sums of each column. The sum line is
shown only if the output consists of more than one data line. This is applicable
even if the defined
.I date
is the same as the current date. The top list also requires
.B "--begin"
to be used at the same time with this option.
.TP
.BI "-5, --fiveminutes " [limit]
Show traffic statistics with a 5 minute resolution for the last hours. The length of the list
will be limited to 24 entries unless configured otherwise or unless the optional
.I limit
parameter is used. All entries stored in the database will be shown if
.I limit
is set to 0.
.TP
.BI "-h, --hours " [limit]
Show traffic statistics on a hourly basis. The length of the list will be limited
to 24 entries unless configured otherwise or unless the optional
.I limit
parameter is used. All entries store in the database will be shown if the
.I limit
is set to 0.
.TP
.B "-hg, --hoursgraph"
Show traffic statistics on a hourly basis for the last 24 hours using a bar graph
followed by a table representing the numerical data.
.TP
.BI "-i, --iface " interface
Select one specific
.I interface
and apply actions to only it. For database queries, it is possible to merge the
information of two or more interfaces using the
.I interface1+interface2+...
syntax. All provided interfaces must be unique and must exist in the database
when the merge syntax is used. Optionally, depending on the
.B InterfaceMatchMethod
configuration setting,
.I interface
can be replaced with
.I alias
previously set using
.BR "--setalias" .
Merge syntax isn't supported when
.I alias
is used. The
.B "-i, --iface"
option is optional and
.I interface
can be used as parameter on the command line for selecting the used interface
even without the option being explicitly used.
.TP
.BI "--iflist " [mode]
List currently available interfaces. If
.I mode
is not defined or is set to 0 then the output will use a one line verbose format. If
.I mode
is set to 1 then the output will contain one interface per line and if
.I mode
is set to 2 then only the interface count will be shown as a single number. See also
.BR "--dbiflist" .
.TP
.BI "--json " "[mode] [limit]"
Show database content for selected interface or all interfaces in json format. All
traffic values in the output are in bytes unless otherwise indicated by the name of the key. An optional
.I mode
parameter can be used for limiting the output to only selected information.
Everything except the 95th percentile output is shown by default. Setting
.I mode
to 's' will output a summary containing the last 2 entries of 5 minute, hourly,
daily, monthly and yearly resolution data, 'f' will output only 5 minute
resolution entries, 'h' hours, 'd' days, 'm' months, 'y' years, 't' the top
days and 'p' the 95th percentile. Alternatively or in combination with
.I mode
an optional
.I limit
parameter can be used to limit the number of entries in the output. The
.BI "--json"
option can be used in combination with
.B "-l, --live"
and
.B "-tr"
options without
.I mode
or
.I limit
having any effect to the output. The
.B "jsonversion"
field in the output contains the API version information. It will be changed only when the
names or structures of previously existing content gets changed. In comparison, the
.B "vnstatversion"
field exists only as extra information.
.TP
.BI "--limit " limit
Set the maximum number of shown entries in list outputs to
.IR limit .
Usage of
.B "--limit"
overrides the default list entry limit values and the optional
.I limit
parameter given directly for a list query. All entries stored in the database will be shown if
.I limit
is set to 0.
.B "--limit"
can also be used to control the length of
.B "--json"
and
.B "--xml"
outputs.
.TP
.BI "-l, --live " [mode]
Display current transfer rate for the selected interface in real time
until interrupted. Statistics will be shown after interruption if the runtime
was more than 10 seconds. An optional
.I mode
parameter can be used to select between the displaying of packets per
second (mode 0) and transfer counters (mode 1) during execution.
.B "--style"
can also be used to affect the layout of the output. The output will be in json
format if used in combination with
.B "--json"
option.
.TP
.BI "--locale " locale
Use
.I locale
instead of using the locale setting specified in the configuration file or the system
default if no configuration file is available.
.TP
.B "--longhelp"
Show complete options list.
.TP
.BI "--merge " "source destination"
Merge interface data from
.I source
database to
.I destination
database. Unless interfaces are specified, all interfaces from
.I source
will be merged to
.IR destination .
A new database will be created if
.I destination
doesn't exist. If an interface of the same name doesn't exist in
.I destination
then a direct copy action for the data from
.I source
will be executed. If an interface of the same name already exists in
.I destination
then an additive merge action will be executed. The
.I source
database is always accessed as read-only and will never be modified by the merge actions. Changes
to the
.I destination
database cannot be reversed as subtraction actions aren't supported. Execution of the merge needs
to be acknowledged with an additional parameter. If this additional parameter isn't provided then
a preview of the actions with additional guidance will be shown.
.IP
Both
.I source
and
.I destination
can either refer directly to database files or use an alternative
.I file:interface
syntax where the database file is suffixed with
.I ":"
followed with an interface name. When used as
.IR source ,
the alternative syntax allows specifying one interface to be merged from
.I source
to
.I destination
instead of all interfaces being merged. Additionally, it's possible to use
the alternative syntax in
.I destination
for specifying to which interface the data will be merged to.
.TP
.BI "-m, --months " [limit]
Show traffic statistics on a monthly basis for the last months. The length of the list
will be limited to 12 entries unless configured otherwise or unless the optional
.I limit
parameter is used. All entries stored in the database will be shown if
.I limit
is set to 0.
.TP
.BI "--oneline " [mode]
Show traffic summary for selected interface using one line with a parsable
format. The output contains 15 fields with ; used as field delimiter. The 1st
field contains the API version information of the output that will only be changed
in future versions if the field content or structure changes. The following
fields in order 2) interface name, 3) timestamp for today, 4) rx for today,
5) tx for today, 6) total for today, 7) average traffic rate for today,
8) timestamp for current month, 9) rx for current month, 10) tx for current
month, 11) total for current month, 12) average traffic rate for current month,
13) all time total rx, 14) all time total tx, 15) all time total traffic.
An optional
.I mode
parameter can be used to force all fields to output in bytes without the
unit itself shown.
.TP
.BI "-q, --query " [mode]
Force database query mode. An optional
.I mode
parameter can be used to override the default query mode. 'a' results in
short summary output being used when there are more than one interface in the
database, otherwise regular summary output is used. 's' results in regular
summary output being shown for one interface regardless of the number of interfaces
in the database. When the optional
.I mode
parameter isn't defined, the configured
.I QueryMode
will be used instead.
.TP
.B "--remove"
Delete the database entry for the interface specified with
.B \-i
or
.B \-\-iface
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]
Swap the configured rate unit. If rate has been configured to be shown in
bytes then rate will be shown in bits if this option is present. In the same
way, if rate has been configured to be shown in bits then rate will be shown
in bytes when this option is present. Alternatively,
.I mode
with either 0 or 1 can be used as parameter for this option in order to
select between bytes (0) and bits (1) regardless of the configuration file setting.
.TP
.BI "--setalias " alias
Set
.I alias
as an alias for the selected interface to be shown in queries. The set
alias can be removed by specifying an empty string for
.IR alias .
The daemon can be running during this operation.
.TP
.B "-s, --short"
Use short output mode. This mode is also used when more than one interface is
available in the database and no specific interface is selected.
.TP
.B "--showconfig"
Show current configuration using the same format as the configuration file
itself uses.
.TP
.BI "--style " number
Modify the content and style of outputs. Set
.I number
to 0 for a narrower output, 1 for enabling bar column, 2
for same as previous but with average traffic rate visible in summary
output and 3 for enabling average traffic rate in all outputs where it is
supported. 4 disables the use of terminal control characters in
.B "-l, --live"
and
.B "-tr, --traffic"
modes.
.TP
.BI "-t, --top " [limit]
Show all time top traffic days. The length of the list will be limited to 10
entries unless configured otherwise or unless the optional
.I limit
parameter is used. All entries stored in the database will be shown if
.I limit
is set to 0. When used with
.B "--begin"
and optionally with
.BR "--end" ,
the list will be generated using the daily data instead of separate top entries.
The availability of daily data defines the boundaries the date specific query
can access.
.TP
.BI "-tr, --traffic " [time]
Calculate how much traffic goes through the selected interface during
the given
.I time
seconds. The
.I time
will be 5 seconds if a number parameter isn't specified. The output will
be in json format if used in combination with
.B "--json"
option. However, in that case, the countdown before results isn't shown.
.B "--style"
can also be used to affect the layout of the output.
.TP
.B "-v, --version"
Show current version.
.TP
.BI "--xml " "[mode] [limit]"
Show database content for selected interface or all interfaces in xml format. All
traffic values in the output are in bytes unless otherwise indicated by the name of the key. An optional
.I mode
parameter can be used for limiting the output to only selected information.
Everything except the 95th percentile output is shown by default. Setting
.I mode
to 's' will output a summary containing the last 2 entries of 5 minute, hourly,
daily, monthly and yearly resolution data, 'f' will output only 5 minute
resolution entries, 'h' hours, 'd' days, 'm' months, 'y' years, 't' the top
days and 'p' the 95th percentile. Alternatively or in combination with
.I mode
an optional
.I limit
parameter can be used to limit the number of entries in the output. The
.B "xmlversion"
field in the output contains the API version information. It will be changed only when the
names or structures of previously existing content gets changed. In comparison, the
.B "vnstatversion"
field exists only as extra information.
.TP
.BI "-y, --years " [limit]
Show traffic statistics on a yearly basis for the last years. The list will show all
entries by default unless configured otherwise or unless the optional
.I limit
parameter is used. All entries stored in the database will also be shown if
.I limit
is set to 0.
.TP
.B "-?, --help"
Show a command option summary.
.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
.BR vnstat.conf (5)
for more information.
.SH EXAMPLES
.TP
.B "vnstat"
Display traffic summary for the default interface or multiple interfaces
when more than one is monitored.
.TP
.B "vnstat -i eth0+eth1+eth3"
Display traffic summary for a merge of interfaces eth0, eth1 and eth3.
.TP
.B "vnstat -i eth2 --xml"
Output all information about interface eth2 in xml format.
.TP
.B "vnstat --json"
Output all information of all monitored interfaces in json format.
.TP
.B "vnstat -i eth0 --setalias local"
Give interface eth0 the alias "local". That information will be
later visible as a label when eth0 is queried.
.TP
.B "vnstat -i eth2 --remove"
Delete database entries for interface eth2 and stop monitoring it.
.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 interface traffic counters,
the maximum time between two updates depends on how fast the interface can transfer 4 GiB.
Note that there is no guarantee that a 64-bit kernel has 64-bit interface traffic counters
for all interfaces. Calculated theoretical times are:
.RS
.TS
l l.
10 Mbit: 54 minutes
100 Mbit: 5 minutes
1000 Mbit: 30 seconds
.TE
.RE
.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.
.PP
Using long date output formats may cause misalignment in shown columns if the
length of the date exceeds the fixed size allocation.
.SH AUTHOR
Teemu Toivola
.SH "SEE ALSO"
.BR vnstatd (8),
.BR vnstati (1),
.BR vnstat.conf (5),
.BR proc (5),
.BR ifconfig (8),
.BR units (7)
vnstat-2.13/man/vnstati.1 0000644 0000000 0000000 00000034214 14751654032 014014 0 ustar root root .TH VNSTATI 1 "FEBRUARY 2025" "version 2.13" "User Manuals"
.SH NAME
vnstati \- image output support for vnStat
.SH SYNOPSIS
.B vnstati
.RB [ \-5bcdDehiLmosStvy? ]
.RB [ \-\-95th
.IR mode ]
.RB [ \-5g
.RI [ limit ]
.RI [ height ]]
.RB [ \-\-altdate ]
.RB [ \-\-begin
.IR date ]
.RB [ \-\-cache
.IR time ]
.RB [ \-\-config
.IR file ]
.RB [ \-\-days
.RI [ limit ]]
.RB [ \-\-db
.IR file ]
.RB [ \-\-dbdir
.IR directory ]
.RB [ \-\-dbiflist
.RI [ mode ]]
.RB [ \-\-debug ]
.RB [ \-\-end
.IR date ]
.RB [ \-\-fivegraph
.RI [ limit ]
.RI [ height ]]
.RB [ \-\-fiveminutes
.RI [ limit ]]
.RB [ \-\-headertext
.IR text ]
.RB [ \-\-help ]
.RB [ \-hg
.RI [ mode ]]
.RB [ \-\-hours
.RI [ limit ]]
.RB [ \-\-hoursgraph
.RI [ mode ]]
.RB [ \-hs
.RI [ graph ]]
.RB [ \-\-hsummary
.RI [ graph ]]
.RB [ \-i
.IR interface ]
.RB [ \-\-iface
.IR interface ]
.RB [ \-ic
.RI [ mode ]]
.RB [ \-\-invert\-colors
.RI [ mode ]]
.RB [ \-\-large ]
.RB [ \-\-limit
.IR limit ]
.RB [ \-\-locale
.IR locale ]
.RB [ \-\-months
.RI [ limit ]]
.RB [ \-ne ]
.RB [ \-nh ]
.RB [ \-nl ]
.RB [ \-\-noedge ]
.RB [ \-\-noheader ]
.RB [ \-\-nolegend ]
.RB [ \-\-output
.IR file ]
.RB [ \-ru
.RI [ mode ]]
.RB [ \-\-rateunit
.RI [ mode ]]
.RB [ \-\-scale
.IR percent ]
.RB [ \-\-small ]
.RB [ \-\-style
.IR number ]
.RB [ \-\-summary ]
.RB [ \-\-top
.RI [ limit ]]
.RB [ \-\-transparent
.RI [ enabled ]]
.RB [ \-\-version ]
.RB [ \-vs
.RI [ graph ]]
.RB [ \-\-vsummary
.RI [ graph ]]
.RB [ \-\-months
.RI [ limit ]]
.RI [ interface ]
.SH DESCRIPTION
The purpose of
.B vnstati
is to provide image output support for statistics collected using
.BR vnstat (1).
The available image file formats depend on what is supported by the used GD
library. All basic outputs of vnStat are supported excluding live traffic
features. The image can be outputted either to a file or to standard output,
with the later being limited to png image format.
.SH OPTIONS
.TP
.BI "--95th " mode
Show 95th percentile output graph for the ongoing month. This output uses the 5 minute resolution
data of the ongoing month to calculate the 95th percentile traffic rate for received, transmitted
or total as selected using the mandatory
.I mode
parameter. The 95th percentile will be shown as a horizontal line in the graph with the exact 95th
percentile traffic rate visible in the legend section of the image. In addition, a one hour
resolution traffic rate bar graph averaged from the 5 minute resolution data of the selected
.I mode
is presented. This output requires the
.B 5MinuteHours
configuration option to have a value of at least 744 for storing all the necessary data, otherwise 100% coverage
isn't possible. Available modes: 0 = received, 1 = transmitted, 2 = total.
.TP
.B "--altdate"
Use alternative date and time text location. The date and time text will be moved
from the upper right header section to the lower left corner. This option
will have no effect if
.B "-nh, --noheader"
has been selected.
.TP
.BI "-b, --begin " date
Begin the list output with a specific date / time defined by
.I date
instead of the begin being selected based on the number of entries to be shown.
If
.I date
isn't available in the database then the closest later date will be used.
.I date
supports the following formats: YYYY-MM-DD HH:MM, YYYY-MM-DD and "today".
This option can only be used with list outputs.
.TP
.BI "-c, --cache " time
Update output file only if at least
.I time
minutes have passed since the previous file update. This option is ignored if
stdout is used as output.
.TP
.BI "--config " file
Use
.I file
as configuration file instead of using automatic configuration file search
functionality. If
.B "--config"
is used multiple times, the configuration settings from files later on the command line
will override configuration settings loaded from earlier files if the settings defined
in the files overlap.
.TP
.BI "-d, --days " [limit]
Output traffic statistics on a daily basis for the last days. The length of the list
will be limited to 30 entries unless configured otherwise or unless the optional
.I limit
parameter is used. All entries stored in the database will be shown if
.I limit
is set to 0.
.TP
.BI "--db " file
Use
.I file
as database file instead of searching for a database from the directory specified in
the configuration file or the hardcoded default if no configuration file is available.
This option overrides
.BR "--dbdir" .
.TP
.BI "--dbdir " directory
Use
.I directory
as database directory instead of using the directory specified in the configuration
file or the hardcoded default if no configuration file is available. This option is
ignored if
.B "--db"
is also defined.
.TP
.BI "--dbiflist " [mode]
List interfaces currently in the database. If
.I mode
is not defined or is set to 0 then the output will use a one line verbose format. If
.I mode
is set to 1 then the output will contain one interface per line and if
.I mode
is set to 2 then only the interface count will be shown as a single number. See also
.BR "--iflist" .
.TP
.B "-D, --debug"
Show additional debug output.
.TP
.BI "-e, --end " date
End the list output with a specific date / time defined by
.I date
instead of the latest date / time in the database. If
.I date
isn't available in the database then the closest earlier date will be used.
.I date
supports the following formats: YYYY-MM-DD HH:MM and YYYY-MM-DD.
This option can only be used with list outputs. The top list also requires
.B "--begin"
to be used at the same time with this option.
.TP
.BI "-5g, --fivegraph " "[limit] [height]"
Output traffic statistics with a 5 minute resolution for the last 48 hours
using a bar graph. The width of the graph can be modified using the optional
.I limit
parameter which represents the number of 5 minute entries with 12 entries for
each hour. The smallest supported value is 288 (last 24 hours). Additionally,
the height of the graph can be modified using the optional
.I height
parameter. The smallest supported height is 150 pixels.
.TP
.BI "-5, --fiveminutes " [limit]
Output traffic statistics with a 5 minute resolution for the last hours. The length of the list
will be limited to 24 entries unless configured otherwise or unless the optional
.I limit
parameter is used. All entries stored in the database will be shown if
.I limit
is set to 0.
.TP
.BI "--headertext " text
Show
.I text
in image header section instead of automatically generated interface identification.
.I text
is limited to 64 characters and may not get completely shown if longer than the width of
the image. Use with
.B "--altdate"
if maximal space is needed. This option will have no effect if
.B "-nh, --noheader"
has been selected.
.TP
.BI "-h, --hours " [limit]
Output traffic statistics on a hourly basis. The length of the list will be limited
to 24 entries unless configured otherwise or unless the optional
.I limit
parameter is used. All entries store in the database will be shown if the
.I limit
is set to 0.
.TP
.BI "-hg, --hoursgraph " [mode]
Output traffic statistics on a hourly basis for the last 24 hours using a bar graph.
The optional
.I mode
parameter can be used to override the configuration file setting. Available modes:
0 = 24 hour sliding window, 1 = graph begins from midnight.
.TP
.BI "-hs, --hsummary " [graph]
Output traffic summary with the graph selected using the
.B SummaryGraph
setting in the configuration file next to it using a horizontal layout. The optional
.I graph
parameter can be used to override the configuration file setting. Available graphs:
0 = hours, 1 = 5 minutes.
.TP
.BI "-i, --iface " interface
Use
.I interface
instead of default or configured interface. It is also possible to merge the
information of two or more interfaces using the
.I interface1+interface2+...
syntax. All provided interfaces must be unique and must exist in the database
when the merge syntax is used. Optionally, depending on the
.B InterfaceMatchMethod
configuration setting,
.I interface
can be replaced with
.I alias
previously set using
.BR "vnstat --setalias" .
Merge syntax isn't supported when
.I alias
is used. The
.B "-i, --iface"
option is optional and
.I interface
can be used as parameter on the command line for selecting the used interface
even without the option being explicitly used.
.TP
.BI "-ic, --invert-colors " [mode]
Invert image colors. Results in black becoming white, dark colors becoming light,
light colors becoming dark and white becoming black. The optional
.I mode
parameter can be used to change the color inversion behaviour. Available modes:
0 = no color inversion, 1 = invert all colors except those used for rx and tx,
2 = invert all colors. When
.I mode
isn't specific, mode 1 will be used.
.TP
.B "-L, --large"
Use large fonts in output.
.TP
.BI "--limit " limit
Set the maximum number of shown entries in list outputs to
.IR limit .
Usage of
.B "--limit"
overrides the default list entry limit values and the optional
.I limit
parameter given directly for a list query. All entries stored in the database will be shown if
.I limit
is set to 0.
.TP
.BI "--locale " locale
Use
.I locale
instead of using the locale setting specified in the configuration file or the system
default if no configuration file is available.
.TP
.BI "-m, --months " [limit]
Output traffic statistics on a monthly basis for the last months. The length of the list
will be limited to 12 entries unless configured otherwise or unless the optional
.I limit
parameter is used. All entries stored in the database will be shown if
.I limit
is set to 0.
.TP
.B "-ne, --noedge"
Remove darker edges from around the image.
.TP
.B "-nh, --noheader"
Remove header containing title and update time. Time of the previous update
will still be visible in the lower right corner using a less visible color.
.TP
.B "-nl, --nolegend"
Remove legend containing rx and tx color mapping information from the image.
.TP
.BI "-o, --output " file
Write image to
.I file
and exit. The used image format is selected by the given file extension of
.IR file .
For example, "image.png" results in the file getting written using the png
image format due to the ".png" extension having been used. Usage of png image
format usually results in the smallest file size without loss of detail or
introduction of compression artifacts. Alternatively, output can be directed
to stdout by giving "-" as
.I file
in which case png image format is used.
.TP
.BI "-ru, --rateunit " [mode]
Swap the configured rate unit. If rate has been configured to be shown in
bytes then rate will be shown in bits if this option is present. In the same
way, if rate has been configured to be shown in bits then rate will be shown
in bytes when this option is present. Alternatively,
.I mode
with either 0 or 1 can be used as parameter for this option in order to
select between bytes (0) and bits (1) regardless of the configuration file setting.
.TP
.BI "--scale " percent
Scale output to given
.I percent
resulting in the image being either smaller or larger than the default size.
.TP
.B "-S, --small"
Use small fonts in output.
.TP
.BI "--style " number
Modify the content and style of outputs. Setting
.I number
to 3 will show average traffic rate in all outputs where it is supported.
Other values will show bar graphics instead.
.TP
.B "-s, --summary"
Output traffic statistics summary.
.TP
.BI "-t, --top " [limit]
Output all time top traffic days. The length of the list
will be limited to 10 entries unless configured otherwise or unless the optional
.I limit
parameter is used. All entries stored in the database will be shown if
.I limit
is set to 0. When used with
.B "--begin"
and optionally with
.BR "--end" ,
the list will be generated using the daily data instead of separate top entries.
The availability of daily data defines the boundaries the date specific query
can access.
.TP
.BI "--transparent " [enabled]
Toggle background color transparency depending of the
.B TransparentBg
setting in the configuration file. Alternatively, 0 or 1 can be given as parameter
.I enabled
for this option in order to either disable (0) or enable (1) transparency
regardless of the configuration file setting.
.TP
.B "-v, --version"
Show current version.
.TP
.BI "-vs, --vsummary " [graph]
Output traffic summary with the graph selected using the
.B SummaryGraph
setting in the configuration file below it using a vertical layout. The optional
.I graph
parameter can be used to override the configuration file setting. Available graphs:
0 = hours, 1 = 5 minutes.
.TP
.BI "-y, --years " [limit]
Output traffic statistics on a yearly basis for the last years. The list will show all
entries by default unless configured otherwise or unless the optional
.I limit
parameter is used. All entries stored in the database will also be shown if
.I limit
is set to 0.
.TP
.B "-?, --help"
Show a command option summary.
.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
.BR vnstat.conf (5)
for more information.
.SH EXAMPLES
.TP
.B "vnstati -s -i eth0 -o /tmp/vnstat.png"
Output traffic summary for interface eth0 to file /tmp/vnstat.png.
.TP
.B "vnstati -vs -i eth0+eth1+eth2 -o /tmp/vnstat.png"
Output traffic summary with hourly data under the normal summary for a merge of
interfaces eth0, eth1 and eth2 to file /tmp/vnstat.png.
.TP
.B "vnstati -h -c 15 -o /tmp/vnstat_h.png"
Output hourly traffic statistics for default interface to file /tmp/vnstat_h.png
if the file has not been updated within the last 15 minutes.
.TP
.B "vnstati -d -ne -nh -o -"
Output daily traffic statistics without displaying the header section and edges
for default interface to standard output (stdout).
.TP
.B "vnstati -m --config /home/me/vnstat.cfg -i -o -"
Output monthly traffic statistics for default interface specified in configuration
file /home/me/vnstat.cfg to standard output (stdout).
.SH RESTRICTIONS
Depending on the built-in fonts provided by the GD library, not all characters
may end up shown correctly when a UTF-8 locale is used.
.PP
Using long date output formats may cause misalignment in shown columns if the
length of the date exceeds the fixed size allocation.
.PP
Scaling an image when background transparency is enabled may not result in
transparency being retained.
.SH AUTHOR
Teemu Toivola
.SH "SEE ALSO"
.BR vnstat (1),
.BR vnstatd (8),
.BR vnstat.conf (5),
.BR units (7)
vnstat-2.13/man/vnstatd.8 0000644 0000000 0000000 00000025316 14751654024 014022 0 ustar root root '\" t
.TH VNSTATD 8 "FEBRUARY 2025" "version 2.13" "User Manuals"
.SH NAME
vnstatd \- daemon based database updating for vnStat
.SH SYNOPSIS
.B vnstatd
.RB [ \-Ddnpstv? ]
.RB [ \-\-alwaysadd
.RI [ mode ]]
.RB [ \-\-config
.IR file ]
.RB [ \-\-daemon ]
.RB [ \-\-debug ]
.RB [ \-g
.IR group ]
.RB [ \-\-group
.IR group ]
.RB [ \-\-help ]
.RB [ \-\-initdb ]
.RB [ \-\-noadd ]
.RB [ \-\-nodaemon ]
.RB [ \-\-noremove ]
.RB [ \-\-pidfile
.IR file ]
.RB [ \-\-startempty ]
.RB [ \-\-sync ]
.RB [ \-\-timestamp ]
.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 gathering data to 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 directly to terminal, 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, the
.B --alwaysadd
option can be used to instruct the daemon to create new database entries whenever
interfaces not currently in the databases become visible. By default, unless the
.B --startempty
option is used, the daemon will not stay running if no interfaces are discovered
during startup and the database contains no interfaces.
.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. New interfaces added to the database will be
automatically picked up for monitoring without the daemon needing to be notified.
.PP
When the
.B UseUTC
configuration option isn't enabled, data is stored in the database using local
time based on the daemon's execution environment when the configuration option
isn't enabled. Any changes in the system clock or the system timezone
configuration will result in data being inserted according to the new local
time without any recalculation being done for already stored data. The daemon
and the database in essence aren't aware of the used timezone or possible
daylight saving time and cannot be configured to offset the timestamps to any
direction. If a system clock or system timezone change or daylight saving time
observation ending results in an already seen time period to repeat then the
existing database values get incremented with the new data.
.SH OPTIONS
.TP
.BI "--alwaysadd " [mode]
Enable automatic creation of new database entries for interfaces not currently in
the database even if the database file already exists 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 always excluded from getting added.
Using the option without
.I mode
defined or with
.I mode
set to 1 will enable the feature. Setting
.I mode
to 0 will disable the feature. This command line option overrides the
.B AlwaysAddNewInterfaces
configuration option when used.
.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 "--initdb"
Create a new database, import data from found legacy databases if
.B "--noadd"
option isn't used and exit without creating database entries for
available interfaces if no legacy data was imported. If the database already
exists then access to it is only verified. The daemon will not stay running
when this option is used. This option cannot be used in combination with
.BR "-d, --daemon" ,
.B "-n, --nodaemon"
or
.BR "--startempty" .
.TP
.B "--noadd"
When used in combination with
.B "-d, --daemon"
or
.BR "-n, --nodaemon" ,
disable the automatic creation of new database entries for all currently available
interfaces when the daemon is started with no existing database or with a database
containing zero interfaces. The daemon will still create an empty database if one doesn't
already exist. Pseudo interfaces lo, lo0 and sit0 are always excluded from getting
added regardless of this option.
.IP
When used in combination with
.BR "--initdb" ,
create only an empty database if one doesn't already exist without importing data
from possible legacy databases and exit.
.TP
.B "-n, --nodaemon"
Stay in foreground attached to the current terminal and start the update
process.
.TP
.B "--noremove"
Disable automatic removal of interfaces from database that aren't currently visible
and haven't seen any traffic.
.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. This option has no effect if used in combination with
.BR "-n, --nodaemon" .
.TP
.B "--startempty"
Start even when no interfaces were discovered and the database is empty. Results in
the daemon staying running and waiting for interfaces to be added to the database or
found if
.B "--alwaysadd"
option has also been used. This option cannot be used in combination with
.BR "--initdb" .
.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
.B "-t, --timestamp"
Add a timestamp to the beginning of every print from the daemon when
the process is running in the foreground attached to a terminal after having
been started with the
.B "-n, --nodaemon"
option.
.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/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/vnstat.pid
File used for storing the process id when running as a background process and
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 interface traffic counters,
the maximum time between two updates depends on how fast the interface can transfer 4 GiB.
Note that there is no guarantee that a 64-bit kernel has 64-bit interface traffic counters
for all interfaces. Calculated theoretical times are:
.RS
.TS
l l.
10 Mbit: 54 minutes
100 Mbit: 5 minutes
1000 Mbit: 30 seconds
.TE
.RE
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
.SH "SEE ALSO"
.BR vnstat (1),
.BR vnstati (1),
.BR vnstat.conf (5),
.BR signal (7)
vnstat-2.13/UNINSTALL 0000644 0000000 0000000 00000000532 14114516557 012761 0 ustar root root # Uninstall
1. Stop the daemon (`vnstatd`) if it is still running
2. Remove any manually installed service files or file entries
used to start the daemon
3. Run `make uninstall` and follow the instructions
4. Remove the database directory if it is no longer needed, the
command of the previous step will not touch any collected data
vnstat-2.13/src/ 0000755 0000000 0000000 00000000000 14751712735 012257 5 ustar root root vnstat-2.13/src/fs.h 0000644 0000000 0000000 00000001074 14462555347 013045 0 ustar root root #ifndef FS_H
#define FS_H
/* O_CLOEXEC is specified starting POSIX.1-2008 / glibc 2.12 / Linux 2.6.23 */
#if HAVE_DECL_O_CLOEXEC
#define FS_OPEN_RO_FLAGS O_RDONLY | O_CLOEXEC
#else
#define FS_OPEN_RO_FLAGS O_RDONLY
#endif
int direxists(const char *dir);
int fileexists(const char *file);
int mkpath(const char *dir, const mode_t mode);
void preparevnstatdir(const char *dir, const char *user, const char *group);
void updatedirowner(const char *dir, const char *user, const char *group);
void updatedirownerid(const char *dir, const uid_t uid, const gid_t gid);
#endif
vnstat-2.13/src/datacache.c 0000644 0000000 0000000 00000006165 14462555347 014333 0 ustar root root #include "common.h"
#include "datacache.h"
int datacache_add(datacache **dc, const char *interface, const short sync)
{
datacache *newdc;
newdc = malloc(sizeof(datacache));
if (newdc == NULL) {
return 0;
}
newdc->next = *dc;
*dc = newdc;
strncpy_nt((*dc)->interface, interface, 32);
(*dc)->active = 1;
(*dc)->filled = 0;
(*dc)->syncneeded = sync;
(*dc)->currx = 0;
(*dc)->curtx = 0;
(*dc)->updated = time(NULL);
(*dc)->log = NULL;
return 1;
}
int datacache_remove(datacache **dc, const char *interface)
{
int ret = 0;
datacache *dc_prev, *dc_head;
dc_head = *dc;
dc_prev = *dc;
if (*dc == NULL) {
return ret;
}
/* handle list head remove */
if (strcmp((*dc)->interface, interface) == 0) {
*dc = (*dc)->next;
xferlog_clear(&dc_prev->log);
free(dc_prev);
return 1;
}
*dc = (*dc)->next;
/* handle other locations */
while (*dc != NULL) {
if (strcmp((*dc)->interface, interface) == 0) {
dc_prev->next = (*dc)->next;
xferlog_clear(&(*dc)->log);
free(*dc);
ret = 1;
break;
}
dc_prev = *dc;
*dc = (*dc)->next;
}
*dc = dc_head;
return ret;
}
void datacache_clear(datacache **dc)
{
datacache *dc_prev;
while (*dc != NULL) {
dc_prev = *dc;
*dc = (*dc)->next;
xferlog_clear(&dc_prev->log);
free(dc_prev);
}
}
int datacache_count(datacache **dc)
{
int count = 0;
datacache *cacheiterator = *dc;
while (cacheiterator != NULL) {
count++;
cacheiterator = cacheiterator->next;
}
return count;
}
int datacache_activecount(datacache **dc)
{
int count = 0;
datacache *cacheiterator = *dc;
while (cacheiterator != NULL) {
if (cacheiterator->active) {
count++;
}
cacheiterator = cacheiterator->next;
}
return count;
}
void datacache_debug(datacache **dc)
{
int i = 1;
datacache *cacheiterator = *dc;
if (cacheiterator == NULL) {
printf("cache: empty\n");
return;
}
printf("cache: ");
while (cacheiterator != NULL) {
printf(" %d: \"%s\" (", i, cacheiterator->interface);
xferlog_debug(&cacheiterator->log, 0);
printf(") ");
cacheiterator = cacheiterator->next;
i++;
}
printf("\n");
}
int xferlog_add(xferlog **log, const time_t timestamp, const uint64_t rx, const uint64_t tx)
{
xferlog *newlog;
if (*log == NULL || (*log)->timestamp != timestamp) {
newlog = malloc(sizeof(xferlog));
if (newlog == NULL) {
return 0;
}
newlog->next = *log;
*log = newlog;
newlog->timestamp = timestamp;
newlog->rx = 0;
newlog->tx = 0;
}
(*log)->rx += rx;
(*log)->tx += tx;
return 1;
}
void xferlog_clear(xferlog **log)
{
xferlog *log_prev;
while (*log != NULL) {
log_prev = *log;
*log = (*log)->next;
free(log_prev);
}
}
void xferlog_debug(xferlog **log, const int newline)
{
int i = 1;
xferlog *logiterator = *log;
if (newline && logiterator == NULL) {
printf(" xferlog: empty\n");
return;
}
if (newline) {
printf(" xferlog: ");
}
while (logiterator != NULL) {
printf("%d: %" PRIu64 " - %" PRIu64 " / %" PRIu64 "", i, (uint64_t)logiterator->timestamp, logiterator->rx, logiterator->tx);
if (logiterator->next != NULL) {
printf(", ");
}
logiterator = logiterator->next;
i++;
}
if (newline) {
printf("\n");
}
}
vnstat-2.13/src/image_support.c 0000644 0000000 0000000 00000044752 14736027316 015312 0 ustar root root #include "common.h"
#include "dbsql.h"
#include "misc.h"
#include "image.h"
#include "image_support.h"
#include "vnstati.h"
void imageinit(IMAGECONTENT *ic, const int width, const int height)
{
int rgb[3], invert = 1;
ic->im = gdImageCreate(width, height);
if (ic->invert > 0) {
invert = -1;
}
/* text, edge and header colors */
hextorgb(cfg.ctext, rgb);
if (ic->invert > 0) { invertcolor(rgb); }
ic->ctext = gdImageColorAllocate(ic->im, rgb[0], rgb[1], rgb[2]);
colorinitcheck("ctext", ic->ctext, cfg.ctext, rgb);
hextorgb(cfg.cedge, rgb);
if (ic->invert > 0) { invertcolor(rgb); }
ic->cedge = gdImageColorAllocate(ic->im, rgb[0], rgb[1], rgb[2]);
colorinitcheck("cedge", ic->cedge, cfg.cedge, rgb);
hextorgb(cfg.cheader, rgb);
if (ic->invert > 0) { invertcolor(rgb); }
ic->cheader = gdImageColorAllocate(ic->im, rgb[0], rgb[1], rgb[2]);
colorinitcheck("cheader", ic->cheader, cfg.cheader, rgb);
hextorgb(cfg.cheadertitle, rgb);
if (ic->invert > 0) { invertcolor(rgb); }
ic->cheadertitle = gdImageColorAllocate(ic->im, rgb[0], rgb[1], rgb[2]);
colorinitcheck("cheadertitle", ic->cheadertitle, cfg.cheadertitle, rgb);
hextorgb(cfg.cheaderdate, rgb);
if (ic->invert > 0) { invertcolor(rgb); }
ic->cheaderdate = gdImageColorAllocate(ic->im, rgb[0], rgb[1], rgb[2]);
colorinitcheck("cheaderdate", ic->cheaderdate, cfg.cheaderdate, rgb);
/* lines */
hextorgb(cfg.cline, rgb);
if (ic->invert > 0) { invertcolor(rgb); }
ic->cline = gdImageColorAllocate(ic->im, rgb[0], rgb[1], rgb[2]);
colorinitcheck("cline", ic->cline, cfg.cline, rgb);
if (cfg.clinel[0] == '-') {
modcolor(rgb, 50 * invert, 1);
} else {
hextorgb(cfg.clinel, rgb);
if (ic->invert > 0) { invertcolor(rgb); }
}
ic->clinel = gdImageColorAllocate(ic->im, rgb[0], rgb[1], rgb[2]);
colorinitcheck("clinel", ic->clinel, cfg.clinel, rgb);
hextorgb(cfg.cpercentileline, rgb);
if (ic->invert > 0) { invertcolor(rgb); }
ic->cpercentileline = gdImageColorAllocate(ic->im, rgb[0], rgb[1], rgb[2]);
colorinitcheck("cpercentileline", ic->cpercentileline, cfg.cpercentileline, rgb);
/* background */
hextorgb(cfg.cbg, rgb);
if (ic->invert > 0) { invertcolor(rgb); }
ic->cbackground = gdImageColorAllocate(ic->im, rgb[0], rgb[1], rgb[2]);
colorinitcheck("cbackground", ic->cbackground, cfg.cbg, rgb);
modcolor(rgb, -35 * invert, 0);
ic->cvnstat = gdImageColorAllocate(ic->im, rgb[0], rgb[1], rgb[2]);
colorinitcheck("cvnstat", ic->cvnstat, cfg.cbg, rgb);
hextorgb(cfg.cbg, rgb);
if (ic->invert > 0) { invertcolor(rgb); }
modcolor(rgb, -15 * invert, 0);
ic->cbgoffset = gdImageColorAllocate(ic->im, rgb[0], rgb[1], rgb[2]);
colorinitcheck("cbgoffset", ic->cbgoffset, cfg.cbg, rgb);
hextorgb(cfg.cbg, rgb);
if (ic->invert > 0) { invertcolor(rgb); }
modcolor(rgb, -40 * invert, 0);
ic->cbgoffsetmore = gdImageColorAllocate(ic->im, rgb[0], rgb[1], rgb[2]);
colorinitcheck("cbgoffsetmore", ic->cbgoffsetmore, cfg.cbg, rgb);
/* rx */
hextorgb(cfg.crx, rgb);
if (ic->invert > 1) { invertcolor(rgb); }
ic->crx = gdImageColorAllocate(ic->im, rgb[0], rgb[1], rgb[2]);
colorinitcheck("crx", ic->crx, cfg.crx, rgb);
if (cfg.crxd[0] == '-') {
modcolor(rgb, -50 * invert, 1);
} else {
hextorgb(cfg.crxd, rgb);
if (ic->invert > 1) { invertcolor(rgb); }
}
ic->crxd = gdImageColorAllocate(ic->im, rgb[0], rgb[1], rgb[2]);
colorinitcheck("crxd", ic->crxd, cfg.crxd, rgb);
/* tx */
hextorgb(cfg.ctx, rgb);
if (ic->invert > 1) { invertcolor(rgb); }
ic->ctx = gdImageColorAllocate(ic->im, rgb[0], rgb[1], rgb[2]);
colorinitcheck("ctx", ic->ctx, cfg.ctx, rgb);
if (cfg.ctxd[0] == '-') {
modcolor(rgb, -50 * invert, 1);
} else {
hextorgb(cfg.ctxd, rgb);
if (ic->invert > 1) { invertcolor(rgb); }
}
ic->ctxd = gdImageColorAllocate(ic->im, rgb[0], rgb[1], rgb[2]);
colorinitcheck("ctxd", ic->ctxd, cfg.ctxd, rgb);
/* total */
hextorgb(cfg.ctotal, rgb);
if (ic->invert > 1) { invertcolor(rgb); }
ic->ctotal = gdImageColorAllocate(ic->im, rgb[0], rgb[1], rgb[2]);
colorinitcheck("ctotal", ic->ctotal, cfg.ctotal, rgb);
}
void colorinitcheck(const char *color, const int value, const char *cfgtext, const int *rgb)
{
if (value == -1) {
printf("Error: ImageColorAllocate failed.\n");
printf(" C: \"%s\" T: \"%s\" RGB: %d/%d/%d\n", color, cfgtext, rgb[0], rgb[1], rgb[2]);
exit(EXIT_FAILURE);
}
}
void layoutinit(IMAGECONTENT *ic, const char *title, const int width, const int height)
{
const struct tm *d;
char datestring[64], buffer[512];
gdFontPtr datefont;
if (ic->large) {
datefont = gdFontGetSmall();
} else {
datefont = gdFontGetTiny();
}
/* get time in given format */
d = localtime(&ic->interface.updated);
strftime(datestring, 64, cfg.hformat, d);
/* background, edges */
gdImageFill(ic->im, 0, 0, ic->cbackground);
if (ic->showedge) {
gdImageRectangle(ic->im, 0, 0, width - 1, height - 1, ic->cedge);
}
/* titlebox with title */
if (ic->showheader) {
if (strlen(ic->headertext)) {
strncpy_nt(buffer, ic->headertext, 65);
} else {
if (strcmp(ic->interface.name, ic->interface.alias) == 0 || strlen(ic->interface.alias) == 0) {
snprintf(buffer, 512, "%s%s", ic->interface.name, title);
} else {
snprintf(buffer, 512, "%s (%s)%s", ic->interface.alias, ic->interface.name, title);
}
}
gdImageFilledRectangle(ic->im, 2 + ic->showedge, 2 + ic->showedge, width - 3 - ic->showedge, 24, ic->cheader);
gdImageString(ic->im, gdFontGetGiant(), 12, 5 + ic->showedge, (unsigned char *)buffer, ic->cheadertitle);
}
/* date */
if (!ic->showheader || ic->altdate) {
gdImageString(ic->im, datefont, 5 + ic->showedge, height - 12 - ic->showedge - (ic->large * 3), (unsigned char *)datestring, ic->cvnstat);
} else {
gdImageString(ic->im, datefont, width - (((int)strlen(datestring)) * datefont->w + 12), 9 + ic->showedge - (ic->large * 3), (unsigned char *)datestring, ic->cheaderdate);
}
/* generator */
gdImageString(ic->im, gdFontGetTiny(), width - 114 - ic->showedge, height - 12 - ic->showedge, (unsigned char *)"vnStat / Teemu Toivola", ic->cvnstat);
}
void drawlegend(IMAGECONTENT *ic, const int x, const int y, const short israte)
{
if (!ic->showlegend) {
return;
}
if (!israte) {
gdImageString(ic->im, ic->font, x, y, (unsigned char *)"rx tx", ic->ctext);
gdImageFilledRectangle(ic->im, x - 12 - (ic->large * 2), y + 4, x - 12 + ic->font->w - (ic->large * 2), y + 4 + ic->font->w, ic->crx);
gdImageRectangle(ic->im, x - 12 - (ic->large * 2), y + 4, x - 12 + ic->font->w - (ic->large * 2), y + 4 + ic->font->w, ic->ctext);
gdImageFilledRectangle(ic->im, x + 30 + (ic->large * 12), y + 4, x + 30 + ic->font->w + (ic->large * 12), y + 4 + ic->font->w, ic->ctx);
gdImageRectangle(ic->im, x + 30 + (ic->large * 12), y + 4, x + 30 + ic->font->w + (ic->large * 12), y + 4 + ic->font->w, ic->ctext);
} else {
gdImageString(ic->im, ic->font, x - 12, y, (unsigned char *)"rx tx rate", ic->ctext);
gdImageFilledRectangle(ic->im, x - 22 - (ic->large * 3), y + 4, x - 22 + ic->font->w - (ic->large * 3), y + 4 + ic->font->w, ic->crx);
gdImageRectangle(ic->im, x - 22 - (ic->large * 3), y + 4, x - 22 + ic->font->w - (ic->large * 3), y + 4 + ic->font->w, ic->ctext);
gdImageFilledRectangle(ic->im, x + 8 + (ic->large * 7), y + 4, x + 8 + ic->font->w + (ic->large * 7), y + 4 + ic->font->w, ic->ctx);
gdImageRectangle(ic->im, x + 8 + (ic->large * 7), y + 4, x + 8 + ic->font->w + (ic->large * 7), y + 4 + ic->font->w, ic->ctext);
}
}
void drawpercentilelegend(IMAGECONTENT *ic, const int x, const int y, const int mode, const uint64_t percentile)
{
int color, xoffset = 0;
char modetext[6], percentiletext[64];
if (mode == 0) {
snprintf(modetext, 6, "rx");
color = ic->crx;
} else if (mode == 1) {
snprintf(modetext, 6, "tx");
color = ic->ctx;
} else {
snprintf(modetext, 6, "total");
color = ic->ctotal;
xoffset = 18 + (ic->large * 6);
}
snprintf(percentiletext, 64, "%s 95th percentile: %s", modetext, gettrafficrate(percentile, 300, 0));
gdImageString(ic->im, ic->font, x, y, (unsigned char *)percentiletext, ic->ctext);
gdImageFilledRectangle(ic->im, x - 12 - (ic->large * 2), y + 4, x - 12 + ic->font->w - (ic->large * 2), y + 4 + ic->font->w, color);
gdImageRectangle(ic->im, x - 12 - (ic->large * 2), y + 4, x - 12 + ic->font->w - (ic->large * 2), y + 4 + ic->font->w, ic->ctext);
gdImageFilledRectangle(ic->im, x + 30 + (ic->large * 12) + xoffset, y + 4, x + 30 + ic->font->w + (ic->large * 12) + xoffset, y + 4 + ic->font->w, ic->cpercentileline);
gdImageRectangle(ic->im, x + 30 + (ic->large * 12) + xoffset, y + 4, x + 30 + ic->font->w + (ic->large * 12) + xoffset, y + 4 + ic->font->w, ic->ctext);
}
void drawbar(IMAGECONTENT *ic, const int x, const int y, const int len, const uint64_t rx, const uint64_t tx, const uint64_t max, const short isestimate)
{
int rxl, txl, width = len, overlap = 0;
int crx = ic->crx, ctx = ic->ctx, crxd = ic->crxd, ctxd = ic->ctxd;
int ybeginoffset = YBEGINOFFSET, yendoffset = YBEGINOFFSET + ic->font->h - 6 - ic->large;
if (isestimate) {
switch (cfg.estimatestyle) {
case 0:
return;
case 1:
crx = ic->cbgoffsetmore;
ctx = ic->cbgoffsetmore;
crxd = ic->cbgoffsetmore;
ctxd = ic->cbgoffsetmore;
break;
case 2:
ybeginoffset += 19;
yendoffset += 19;
crxd = ic->crx;
ctxd = ic->ctx;
crx = ic->cbgoffset;
ctx = ic->cbgoffset;
break;
default:
return;
}
}
if ((rx + tx) < max) {
width = (int)lrint(((double)(rx + tx) / (double)max) * len);
} else if ((rx + tx) > max || max == 0) {
if (debug && (rx + tx) > max) {
printf("Warning: Bar rx + tx sum exceeds given maximum, no bar shown\n");
}
return;
}
if (width <= 0) {
return;
}
if (tx > rx) {
rxl = (int)lrint(((double)rx / (double)(rx + tx) * width));
txl = width - rxl;
} else {
txl = (int)lrint(((double)tx / (double)(rx + tx) * width));
rxl = width - txl;
}
if (rxl) {
if (txl > 0) {
overlap = 1;
}
gdImageFilledRectangle(ic->im, x, y + ybeginoffset, x + rxl - 1 + overlap, y + yendoffset, crx);
gdImageRectangle(ic->im, x, y + ybeginoffset, x + rxl - 1 + overlap, y + yendoffset, crxd);
}
if (txl) {
gdImageFilledRectangle(ic->im, x + rxl, y + ybeginoffset, x + rxl + txl - 1, y + yendoffset, ctx);
gdImageRectangle(ic->im, x + rxl, y + ybeginoffset, x + rxl + txl - 1, y + yendoffset, ctxd);
}
}
void drawpoles(IMAGECONTENT *ic, const int x, const int y, const int len, const uint64_t rx, const uint64_t tx, const uint64_t max)
{
int l;
if (rx > 0) {
l = (int)lrint(((double)rx / (double)max) * len);
if (l > 0) {
gdImageFilledRectangle(ic->im, x - (ic->large * 2), y + (len - l), x + 7 + (ic->large * 0), y + len, ic->crx);
}
}
if (tx > 0) {
l = (int)lrint(((double)tx / (double)max) * len);
if (l > 0) {
gdImageFilledRectangle(ic->im, x + 5 - (ic->large * 0), y + (len - l), x + 12 + (ic->large * 2), y + len, ic->ctx);
}
}
}
void drawdonut(IMAGECONTENT *ic, const int x, const int y, const float rxp, const float txp, const int size, const int holesize)
{
// libgd versions 2.2.3 - 2.2.5 have bug in gdImageFilledArc() https://github.com/libgd/libgd/issues/351
// so workaround needs to be used, 2.2 version series ends with 2.2.5 and the bug is fixed starting from 2.3.0
if (GD_MAJOR_VERSION == 2 && GD_MINOR_VERSION == 2 && GD_RELEASE_VERSION >= 3) {
drawdonut_libgd_bug_workaround(ic, x, y, rxp, txp, size, holesize);
} else {
drawdonut_libgd_native(ic, x, y, rxp, txp, size, holesize);
}
}
void drawdonut_libgd_bug_workaround(IMAGECONTENT *ic, const int x, const int y, const float rxp, const float txp, const int size, const int holesize)
{
int rxarc = 0, txarc = 0;
if ((int)(rxp + txp) > 0) {
rxarc = (int)lrintf(360 * (rxp / (float)100));
if ((int)(rxp + txp) == 100) {
txarc = 360 - rxarc;
} else {
txarc = (int)lrintf(360 * (txp / (float)100));
}
}
// background filled circle
gdImageFilledArc(ic->im, x, y, size, size, 0, 360, ic->cbgoffset, 0);
if (txarc) {
gdImageFilledArc(ic->im, x, y, size, size, 270, 270 + txarc, ic->ctxd, gdEdged | gdNoFill);
if (txarc >= 5) {
gdImageFill(ic->im, x + 1, y - (size / 2 - 3), ic->ctx);
}
gdImageFilledArc(ic->im, x, y, holesize, holesize, 270, 270 + txarc, ic->ctxd, gdEdged | gdNoFill);
}
if (rxarc) {
gdImageFilledArc(ic->im, x, y, size, size, 270 + txarc, 270 + txarc + rxarc, ic->crxd, gdEdged | gdNoFill);
if (rxarc >= 5) {
gdImageFill(ic->im, (int)(x + (size / 2 - 3) * cos((int)((270 * 2 + 2 * txarc + rxarc) / 2) * M_PI / 180)), (int)(y + (size / 2 - 3) * sin((int)((270 * 2 + 2 * txarc + rxarc) / 2) * M_PI / 180)), ic->crx);
}
gdImageFilledArc(ic->im, x, y, holesize, holesize, 270 + txarc, 270 + txarc + rxarc, ic->crxd, gdEdged | gdNoFill);
}
// remove center from background filled circle, making it a donut
gdImageFilledArc(ic->im, x, y, holesize - 2, holesize - 2, 0, 360, ic->cbackground, 0);
}
void drawdonut_libgd_native(IMAGECONTENT *ic, const int x, const int y, const float rxp, const float txp, const int size, const int holesize)
{
int rxarc = 0, txarc = 0;
if ((int)(rxp + txp) > 0) {
rxarc = (int)(360 * (rxp / (float)100));
if ((int)(rxp + txp) == 100) {
txarc = 360 - rxarc;
} else {
txarc = (int)(360 * (txp / (float)100));
}
}
// background filled circle
gdImageFilledArc(ic->im, x, y, size, size, 0, 360, ic->cbgoffset, 0);
if (txarc) {
gdImageFilledArc(ic->im, x, y, size, size, 270, 270 + txarc, ic->ctx, 0);
gdImageFilledArc(ic->im, x, y, size, size, 270, 270 + txarc, ic->ctxd, gdEdged | gdNoFill);
gdImageFilledArc(ic->im, x, y, holesize, holesize, 270, 270 + txarc, ic->ctxd, gdEdged | gdNoFill);
}
if (rxarc) {
gdImageFilledArc(ic->im, x, y, size, size, 270 + txarc, 270 + txarc + rxarc, ic->crx, 0);
gdImageFilledArc(ic->im, x, y, size, size, 270 + txarc, 270 + txarc + rxarc, ic->crxd, gdEdged | gdNoFill);
gdImageFilledArc(ic->im, x, y, holesize, holesize, 270 + txarc, 270 + txarc + rxarc, ic->crxd, gdEdged | gdNoFill);
}
// remove center from background filled circle, making it a donut
gdImageFilledArc(ic->im, x, y, holesize - 2, holesize - 2, 0, 360, ic->cbackground, 0);
}
void drawpole(IMAGECONTENT *ic, const int x, const int y, const int length, const int direction, const int color)
{
int len = length - 1;
if (length > 0) {
switch (direction) {
case 1:
gdImageLine(ic->im, x, y, x, y - len, color);
break;
case 2:
gdImageLine(ic->im, x, y, x, y + len, color);
break;
default:
break;
}
}
}
void drawarrowup(IMAGECONTENT *ic, const int x, const int y)
{
gdImageLine(ic->im, x, y, x + 2, y + 3, ic->ctext);
gdImageLine(ic->im, x, y, x - 2, y + 3, ic->ctext);
gdImageLine(ic->im, x - 2, y + 3, x + 2, y + 3, ic->ctext);
gdImageLine(ic->im, x, y + 1, x, y - 1, ic->ctext);
gdImageLine(ic->im, x, y, x, y + 2, ic->ctext);
}
void drawarrowright(IMAGECONTENT *ic, const int x, const int y)
{
gdImageLine(ic->im, x, y, x - 3, y - 2, ic->ctext);
gdImageLine(ic->im, x, y, x - 3, y + 2, ic->ctext);
gdImageLine(ic->im, x - 3, y - 2, x - 3, y + 2, ic->ctext);
gdImageLine(ic->im, x + 1, y, x - 1, y, ic->ctext);
}
void hextorgb(const char *input, int *rgb)
{
int offset;
char hex[3], dec[4];
if (input[0] == '#') {
offset = 1;
} else {
offset = 0;
}
snprintf(hex, 3, "%c%c", input[(0 + offset)], input[(1 + offset)]);
snprintf(dec, 4, "%d", (int)strtol(hex, NULL, 16));
rgb[0] = atoi(dec);
snprintf(hex, 3, "%c%c", input[(2 + offset)], input[(3 + offset)]);
snprintf(dec, 4, "%d", (int)strtol(hex, NULL, 16));
rgb[1] = atoi(dec);
snprintf(hex, 3, "%c%c", input[(4 + offset)], input[(5 + offset)]);
snprintf(dec, 4, "%d", (int)strtol(hex, NULL, 16));
rgb[2] = atoi(dec);
if (debug) {
printf("%s -> %d, %d, %d\n", input, rgb[0], rgb[1], rgb[2]);
}
}
void modcolor(int *rgb, const int offset, const int force)
{
int i, overflow = 0;
if (debug) {
printf("m%d (%d): %d, %d, %d -> ", offset, force, rgb[0], rgb[1], rgb[2]);
}
for (i = 0; i < 3; i++) {
if ((rgb[i] + offset) > 255 || (rgb[i] + offset) < 0) {
overflow++;
}
}
/* positive offset gives lighter color, negative darker if forced */
/* otherwise the direction is changed depending on possible overflows */
for (i = 0; i < 3; i++) {
if (overflow < 2 || force) {
if ((rgb[i] + offset) > 255) {
rgb[i] = 255;
} else if ((rgb[i] + offset) < 0) {
rgb[i] = 0;
} else {
rgb[i] += offset;
}
} else {
if ((rgb[i] - offset) < 0) {
rgb[i] = 0;
} else if ((rgb[i] - offset) > 255) {
rgb[i] = 255;
} else {
rgb[i] -= offset;
}
}
}
if (debug) {
printf("%d, %d, %d\n", rgb[0], rgb[1], rgb[2]);
}
}
void invertcolor(int *rgb)
{
int i;
if (debug) {
printf("invert: %d, %d, %d -> ", rgb[0], rgb[1], rgb[2]);
}
for (i = 0; i < 3; i++) {
rgb[i] = 255 - rgb[i];
}
if (debug) {
printf("%d, %d, %d\n", rgb[0], rgb[1], rgb[2]);
}
}
char *getimagevalue(const uint64_t b, const int len, const int israte)
{
static char buffer[64];
int i, declen = 0, unit = 0, p = 1024;
uint64_t limit;
if (b == 0) {
snprintf(buffer, 64, "%*s", len, "--");
} else {
if (israte && (getunit() == 2 || getunit() == 4)) {
p = 1000;
unit = getunit();
}
for (i = UNITPREFIXCOUNT - 1; i > 0; i--) {
limit = (uint64_t)(pow(p, i - 1)) * 1000;
if (b >= limit) {
snprintf(buffer, 64, "%*.*f", len, declen, (double)b / (double)(getunitdivisor(unit, i + 1)));
return buffer;
}
}
snprintf(buffer, 64, "%*" PRIu64 "", len, b);
}
return buffer;
}
char *getimagescale(const uint64_t b, const int israte)
{
static char buffer[8];
int unit, div = 1, p = 1024;
unit = getunit();
if (b == 0) {
snprintf(buffer, 8, "--");
} else {
if (israte) {
if (unit == 2 || unit == 4) {
p = 1000;
}
while (div < UNITPREFIXCOUNT && (double)b >= (pow(p, div - 1) * 1000)) {
div++;
}
snprintf(buffer, 8, "%s", getrateunitprefix(unit, div));
} else {
while (div < UNITPREFIXCOUNT && (double)b >= (pow(p, div - 1) * 1000)) {
div++;
}
snprintf(buffer, 8, "%s", getunitprefix(div));
}
}
return buffer;
}
uint64_t getscale(const uint64_t input, const int israte)
{
int i, unit;
unsigned int div = 1024;
uint64_t result = input;
unit = getunit();
if (israte && (unit == 2 || unit == 4)) {
div = 1000;
}
/* get unit */
for (i = 0; result >= div; i++) {
result = result / div;
}
/* round result depending of scale */
if (result >= 300) {
result = result / 4 + (100 - ((result / 4) % 100));
} else if (result > 20) {
result = result / 4 + (10 - ((result / 4) % 10));
} else {
result = result / 4;
}
/* put unit back */
if (i) {
result = result * (uint64_t)(pow(div, i));
}
/* make sure result isn't zero */
if (!result) {
if (i) {
result = (uint64_t)(pow(div, i));
} else {
result = 1;
}
}
return result;
}
vnstat-2.13/src/image_support.h 0000644 0000000 0000000 00000003406 14543255063 015304 0 ustar root root #ifndef IMAGE_SUPPORT_H
#define IMAGE_SUPPORT_H
#include "image.h"
void imageinit(IMAGECONTENT *ic, const int width, const int height);
void colorinitcheck(const char *color, const int value, const char *cfgtext, const int *rgb);
void layoutinit(IMAGECONTENT *ic, const char *title, const int width, const int height);
void drawlegend(IMAGECONTENT *ic, const int x, const int y, const short israte);
void drawpercentilelegend(IMAGECONTENT *ic, const int x, const int y, const int mode, const uint64_t percentile);
void drawbar(IMAGECONTENT *ic, const int x, const int y, const int len, const uint64_t rx, const uint64_t tx, const uint64_t max, const short isestimate);
void drawpoles(IMAGECONTENT *ic, const int x, const int y, const int len, const uint64_t rx, const uint64_t tx, const uint64_t max);
void drawdonut(IMAGECONTENT *ic, const int x, const int y, const float rxp, const float txp, const int size, const int holesize);
void drawdonut_libgd_bug_workaround(IMAGECONTENT *ic, const int x, const int y, const float rxp, const float txp, const int size, const int holesize);
void drawdonut_libgd_native(IMAGECONTENT *ic, const int x, const int y, const float rxp, const float txp, const int size, const int holesize);
void drawpole(IMAGECONTENT *ic, const int x, const int y, const int length, const int direction, const int color);
void drawarrowup(IMAGECONTENT *ic, const int x, const int y);
void drawarrowright(IMAGECONTENT *ic, const int x, const int y);
void hextorgb(const char *input, int *rgb);
void modcolor(int *rgb, const int offset, const int force);
void invertcolor(int *rgb);
char *getimagevalue(const uint64_t b, const int len, const int israte);
char *getimagescale(const uint64_t b, const int israte);
uint64_t getscale(const uint64_t input, const int israte);
#endif
vnstat-2.13/src/ibw.h 0000644 0000000 0000000 00000000432 14462555347 013213 0 ustar root root #ifndef IBW_H
#define IBW_H
int ibwloadcfg(const char *cfgfile);
int ibwadd(const char *iface, const uint32_t limit);
void ibwlist(void);
int ibwget(const char *iface, uint32_t *limit);
ibwnode *ibwgetnode(const char *iface);
void ibwflush(void);
int ibwcfgread(FILE *fd);
#endif
vnstat-2.13/src/cfg.h 0000644 0000000 0000000 00000001503 14462555347 013171 0 ustar root root #ifndef CFG_H
#define CFG_H
struct cfgsetting {
const char *name;
char *locc;
int32_t *loci;
short namelen;
short found;
};
typedef enum ConfigType {
CT_All = 0,
CT_CLI,
CT_Daemon,
CT_Image
} ConfigType;
int loadcfg(const char *cfgfile, const ConfigType type);
void validatebool(const char *cfgname, int32_t *cfgptr, const int32_t defaultvalue);
void validateint(const char *cfgname, int32_t *cfgptr, const int32_t defaultvalue, const int32_t minvalue, const int32_t maxvalue);
void validatecfg(const ConfigType type);
void defaultcfg(void);
int opencfgfile(const char *cfgfile, FILE **fd);
int extractcfgvalue(char *value, const unsigned int valuelen, const char *cfgline, const unsigned int cfglen);
int setcfgvalue(const struct cfgsetting *cset, const char *value, const char *cfgline);
void configlocale(void);
#endif
vnstat-2.13/src/common.h 0000644 0000000 0000000 00000025115 14737565732 013733 0 ustar root root #ifndef COMMON_H
#define COMMON_H
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__APPLE__) || defined(__FreeBSD_kernel__)
#include
#include
#include
#include
#include
#include
#define BSD_VNSTAT
#endif
/* OpenBSD and NetBSD don't support the ' character (decimal conversion) in printf formatting */
#if !defined(__OpenBSD__) && !defined(__NetBSD__)
#define DECCONV "'"
#else
#define DECCONV
#endif
/* used in debug to get function name */
#if __STDC_VERSION__ < 199901L
#if __GNUC__ >= 2
#define __func__ __FUNCTION__
#else
#define __func__ "function"
#endif
#endif
/*
Note! These are only the default values for settings
and most can be changed later from the config file.
*/
/* location of the database directory */
#ifndef DATABASEDIR
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__APPLE__)
#define DATABASEDIR "/var/db/vnstat"
#else
#define DATABASEDIR "/var/lib/vnstat"
#endif
#endif
/* database file name */
#define DATABASEFILE "vnstat.db"
/* modifier used for sqlite date and time functions */
#define DATABASELOCALTIMEMODIFIER ", 'localtime'"
/* on which day should months change */
#define MONTHROTATE 1
#define MONTHROTATEYEARS 0
/* date output formats for -d, -m, -t and image header*/
/* see 'man date' for control codes 1.x values <1.8 values */
#define DFORMAT "%Y-%m-%d" /* "%x" "%d.%m." */
#define MFORMAT "%Y-%m" /* "%b '%y" "%b '%y" */
#define TFORMAT "%Y-%m-%d" /* "%x" "%d.%m.%y" */
#define HFORMAT "%Y-%m-%d %H:%M" /* "%x %H:%M" "%d.%m.%Y %H:%M" */
#ifndef DATETIMEFORMAT
#define DATETIMEFORMAT "%Y-%m-%d %H:%M:%S"
#endif
#ifndef DATETIMEFORMATWITHOUTSECS
#define DATETIMEFORMATWITHOUTSECS "%Y-%m-%d %H:%M"
#endif
/* characters used for visuals */
#define RXCHAR "%"
#define TXCHAR ":"
#define RXHOURCHAR "r"
#define TXHOURCHAR "t"
/* unit mode */
/* 0 = KiB/MiB/GiB/TiB, 1 = KB/MB/GB/TB */
#define UNITMODE 0
/* rate unit mode */
/* 0 = Kibit/s..., 1 = kbit/s... */
#define RATEUNITMODE 1
/* output style */
/* 0 = minimal/narrow, 1 = bars everywhere */
/* 2 = same as 1 + rate in summary */
/* 3 = rate everywhere */
#define OSTYLE 3
#define ESTIMATEBARVISIBLE 1
/* interface order */
/* 0 = alphabetical by name, 1 = alphabetical by alias */
#define INTERFACEORDER 0
/* rate in vnstati summary output */
#define SUMMARYRATE 1
/* rate in vnstati hourly output */
#define HOURLYRATE 1
/* rate unit */
/* 0 = bytes, 1 = bits */
#define RATEUNIT 1
/* number of decimals */
#define DEFAULTDECIMALS 2
#define HOURLYDECIMALS 1
/* hourly section style */
#define HOURLYSTYLE 2
/* default interface */
#ifndef DEFIFACE
#define DEFIFACE ""
#endif
/* default locale */
#define LOCALE "-"
/* bandwidth detection, 0 = feature disabled */
#define BWDETECT 1
#define BWDETECTINTERVAL 5
/* default maximum bandwidth (Mbit) for all interfaces */
/* 0 = feature disabled */
#define DEFMAXBW 1000
/* animation visibility in -l / --live */
#define LIVESPINNER 1
/* maximum allowed config value for bandwidth */
#define BWMAX 50000
/* how many seconds should sampling take by default */
#define DEFSAMPTIME 5
/* default query mode */
/* 0 = normal, 1 = days, 2 = months, 3 = top, 5 = short */
/* 7 = hours, 8 = xml, 9 = one line, 10 = json */
#define DEFQMODE 0
/* interface match method */
/* 0 = interface name exact case sensitive, 1 = 0 + case sensitive exact alias */
/* 2 = 1 + case insensitive exact alias, 3 = 2 + case insensitive beginning of alias */
#define IFACEMATCHMETHOD 3
/* estimate line visibility and text */
#define ESTIMATEVISIBLE 1
#define ESTIMATETEXT "estimated"
/* how much the boot time can variate between updates (seconds) */
#define BVAR 15
/* check disk space by default */
#define USESPACECHECK 1
/* create trafficless entries by default */
#define TRAFFICLESSENTRIES 1
/* list outputs */
#define LISTFIVEMINS 24
#define LISTHOURS 24
#define LISTDAYS 30
#define LISTMONTHS 12
#define LISTYEARS 0
#define LISTTOP 10
#define LISTJSONXML 0
/* data retention defaults */
#define FIVEMINUTEHOURS 48
#define HOURLYDAYS 4
#define DAILYDAYS 62
#define MONTHLYMONTHS 25
#define YEARLYYEARS -1
#define TOPDAYENTRIES 20
/* assume that locale can be UTF-n when enabled */
#define UTFLOCALE 1
/* 1 = 2.0 */
#define SQLDBVERSION "1"
/* xml format version */
/* 1 = 1.7-1.16, 2 = 2.0 */
#define XMLVERSION 2
/* json format version */
/* 1 = 1.13-1.16, 2 = 2.0 */
#define JSONVERSION "2"
/* json format version, -tr */
/* 1 = 1.18- */
#define JSONVERSION_TR 1
/* json format version, --live */
/* 1 = 1.18- */
#define JSONVERSION_LIVE 1
/*json format version, --alert */
/* 1 = 2.12- */
#define JSONALERT "1"
/* --oneline format version */
#define ONELINEVERSION 1
/* integer limits */
#define MAX32 4294967295ULL
#define MAX64 18446744073709551615ULL
/* sampletime in seconds for live traffic */
/* don't use values below 2 */
#define LIVETIME 2
/* /proc/net/dev */
#ifndef PROCNETDEV
#define PROCNETDEV "/proc/net/dev"
#endif
/* /sys/class/net */
#ifndef SYSCLASSNET
#define SYSCLASSNET "/sys/class/net"
#endif
/* daemon defaults */
#define UPDATEINTERVAL 20
#define TIMESYNCWAIT 5
#define POLLINTERVAL 5
#define SAVEINTERVAL 5
#define OFFSAVEINTERVAL 30
#define RESCANONSAVE 1
#define ALWAYSADD 0
#define SAVESTATUS 1
#define USELOGGING 2
#define CREATEDIRS 1
#define UPDATEFILEOWNER 1
#define LOGFILE "/var/log/vnstat/vnstat.log"
#define PIDFILE "/var/run/vnstat/vnstat.pid"
#define IS64BIT -2
#define WALDB 0
#define WALDBCHECKPOINTINTERVALMINS 240
#define SLOWDBWARNLIMIT 4.0 // needs to be less than DBREADTIMEOUTSECS
#define DBSYNCHRONOUS -1
#define USEUTC 0
#define VACUUMONSTARTUP 1
#define VACUUMONHUPSIGNAL 1
/* database read timeout */
#define DBREADTIMEOUTSECS 5
/* no transparency by default */
#define TRANSBG 0
/* small fonts by default */
#define LARGEFONTS 0
/* no extra space between lines by default */
#define LINESPACEADJUST 0
/* no image scaling by default */
#define IMAGESCALE 100
/* image output estimate bar style */
/* 0 = not shown, 1 = continuation of existing bar, 2 = separate bar */
#define ESTIMATESTYLE 1
/* bar column in list outputs shows rate when rate column is visible */
#define BARSHOWSRATE 0
/* 5 minute graph size */
#define FIVEGRESULTCOUNT 576
#define FIVEGHEIGHT 300
#define FIVEGMINRESULTCOUNT 288
#define FIVEGMINHEIGHT 150
/* hourly graph mode (0 = 24 hour sliding window, 1 = begins from midnight) */
#define HOURLYGMODE 0
/* graph used in extended summary, 0 = hours, 1 = 5 minutes*/
#define SUMMARYGRAPH 0
/* default colors */
#define CBACKGROUND "FFFFFF"
#define CEDGE "AEAEAE"
#define CHEADER "606060"
#define CHEADERTITLE "FFFFFF"
#define CHEADERDATE "FFFFFF"
#define CTEXT "000000"
#define CLINE "B0B0B0"
#define CLINEL "-"
#define CPERCENTILELINE "CF0045"
#define CRX "92CF00"
#define CRXD "-"
#define CTX "606060"
#define CTXD "-"
#define CTOTAL "0098CF"
/* percentile month entry count */
#define PERCENTILEENTRYCOUNT 744
/* interface name length limit */
#define MAXIFLEN 32
#define MAXIFPARAMLEN 256
/* 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
/* buffer sizes */
#define DATEBUFFLEN 64
/* internal config structure */
typedef struct {
char dformat[64], mformat[64], tformat[64], hformat[64];
char iface[MAXIFPARAMLEN];
char locale[32];
char dbfile[530], dbdir[512], dbtzmodifier[14];
char rxchar[2], txchar[2], rxhourchar[2], txhourchar[2], estimatetext[10];
char cbg[8], cedge[8], cheader[8], cheadertitle[8], cheaderdate[8], ctext[8];
char cline[8], clinel[8], cpercentileline[8], cvnstat[8], crx[8], crxd[8], ctx[8], ctxd[8], ctotal[8];
int32_t unitmode, rateunitmode, rateunit, bvar, qmode, ifacematchmethod, sampletime, hourlyrate, summaryrate;
int32_t monthrotate, monthrotateyears, maxbw, spacecheck, trafficlessentries, transbg, ostyle;
int32_t defaultdecimals, hourlydecimals, hourlystyle, is64bit, waldb, dbsynchronous, useutc, imagescale;
int32_t largefonts, linespaceadjust, estimatebarvisible, estimatestyle, estimatevisible, barshowsrate, fivegresultcount;
int32_t fivegheight, summarygraph, hourlygmode, alwaysadd, livespinner;
char cfgfile[512], logfile[512], pidfile[512];
char daemonuser[33], daemongroup[33];
int32_t timesyncwait, updateinterval, pollinterval, saveinterval, offsaveinterval, rescanonsave, savestatus;
int32_t uselogging, createdirs, updatefileowner, bwdetection, bwdetectioninterval, utflocale;
int32_t fiveminutehours, hourlydays, dailydays, monthlymonths, yearlyyears, topdayentries;
int32_t listfivemins, listhours, listdays, listmonths, listyears, listtop, listjsonxml;
int32_t timestampprints, interfaceorder, vacuumonstartup, vacuumonhupsignal, experimental;
} CFG;
/* internal interface information structure */
typedef struct {
char name[MAXIFLEN];
short filled;
short is64bit;
uint64_t rx;
uint64_t tx;
uint64_t rxp;
uint64_t txp;
time_t timestamp;
} IFINFO;
typedef struct ibwnode {
char interface[MAXIFLEN];
uint32_t limit;
uint32_t fallback;
short retries;
time_t detected;
struct ibwnode *next;
} ibwnode;
typedef enum PrintType {
PT_Info = 0,
PT_Infoless,
PT_Warning,
PT_Error,
PT_Config,
PT_Multiline,
PT_ShortMultiline
} PrintType;
/* common functions */
int printe(const PrintType type);
int logprint(const PrintType type);
int verifylogaccess(void);
int dmonth(const int month);
int isleapyear(const int year);
time_t mosecs(time_t month, time_t updated);
uint64_t countercalc(const uint64_t *a, const uint64_t *b, const short is64bit);
char *strncpy_nt(char *dest, const char *src, size_t n);
int isnumeric(const char *s);
void panicexit(const char *sourcefile, const int sourceline) __attribute__((noreturn));
char *getversion(void);
double timeused(const char *func, const int reset);
void timeused_debug(const char *func, const int reset);
/* global variables */
extern CFG cfg;
extern IFINFO ifinfo;
extern char errorstring[1024];
extern ibwnode *ifacebw;
extern int debug;
extern int noexit; /* = running as daemon if 2 */
extern int intsignal;
extern int pidfile;
extern int disableprinte;
extern int stderrprinte;
#endif
vnstat-2.13/src/vnstat_func.c 0000644 0000000 0000000 00000140032 14750226572 014753 0 ustar root root #include "common.h"
#include "ifinfo.h"
#include "iflist.h"
#include "traffic.h"
#include "dbsql.h"
#include "dbxml.h"
#include "dbjson.h"
#include "dbshow.h"
#include "dbmerge.h"
#include "misc.h"
#include "cfg.h"
#include "cfgoutput.h"
#include "clicommon.h"
#include "fs.h"
#include "vnstat_func.h"
void initparams(PARAMS *p)
{
db = NULL;
noexit = 0; /* allow functions to exit in case of error */
debug = 0; /* debug disabled by default */
disableprinte = 0; /* let printe() output be visible */
stderrprinte = 0; /* use stdout for printe() output */
p->addiface = 0;
p->query = 1;
p->setalias = 0;
p->dbifcount = 0;
p->force = 0;
p->traffic = 0;
p->livetraffic = 0;
p->defaultiface = 1;
p->removeiface = 0;
p->renameiface = 0;
p->livemode = 0;
p->limit = -1;
p->ifacelist = NULL;
p->interface[0] = '\0';
p->alias[0] = '\0';
p->newifname[0] = '\0';
p->definterface[0] = '\0';
p->cfgfile[0] = '\0';
p->jsonmode = 'a';
p->xmlmode = 'a';
p->databegin[0] = '\0';
p->dataend[0] = '\0';
p->alert = 0;
p->alertoutput = 0;
p->alertexit = 0;
p->alerttype = 0;
p->alertcondition = 0;
p->alertlimit = 0;
p->alertrateunit = -1;
p->alertrateunitmode = -1;
p->merge = 0;
p->mergesrc[0] = '\0';
p->mergedst[0] = '\0';
/* load default config */
defaultcfg();
}
void showhelp(const PARAMS *p)
{
printf("vnStat %s by Teemu Toivola \n\n", getversion());
printf(" -5, --fiveminutes [limit] show 5 minutes\n");
printf(" -h, --hours [limit] show hours\n");
printf(" -hg, --hoursgraph show hours graph\n");
printf(" -d, --days [limit] show days\n");
printf(" -m, --months [limit] show months\n");
printf(" -y, --years [limit] show years\n");
printf(" -t, --top [limit] show top days\n\n");
printf(" -b, --begin set list begin date\n");
printf(" -e, --end set list end date\n\n");
printf(" --95th show 95th percentile\n");
printf(" --oneline [mode] show simple parsable format\n");
printf(" --json [mode] [limit] show database in json format\n");
printf(" --xml [mode] [limit] show database in xml format\n");
printf(" --alert