packages/net/vnstat2/files/vnstat.hotplug
Jan Hoffmann f9ea814260 vnstat2: add hotplug script for adding interfaces
If an interface doesn't exist yet when vnStat is started, it won't be
monitored, as only existing interfaces can be added to the database via
the vnstat command.

This adds a hotplug script which adds any configured interfaces to the
vnStat database when it goes up.

Signed-off-by: Jan Hoffmann <jan@3e8.eu>
2021-10-28 01:31:18 -07:00

23 lines
363 B
Text

/etc/init.d/vnstat running || exit 0
[ "$ACTION" = "ifup" ] || exit 0
. /lib/functions.sh
check_iface() {
local iface="$1"
[ "$iface" = "$DEVICE" ] || return
/usr/bin/vnstat --add -i "$iface" >/dev/null
exit 0
}
check_ifaces() {
local cfg="$1"
config_list_foreach "$cfg" interface check_iface
}
config_load vnstat
config_foreach check_ifaces vnstat