#!/bin/sh #by cuma . /mod/etc/conf/vnstat.cfg _NICE=$(which nice) NOCACHE="?nocache=$(date -Iseconds | sed 's/T/_/g;s/+.*$//g;s/:/-/g')" TEMPDIR=/tmp/vnstat mkdir -p $TEMPDIR gen_pic() { $_NICE vnstati -i $1 --$2 -o $TEMPDIR/$1-$2.png --config /tmp/flash/vnstat/vnstat.conf echo "
" } #main echo "vnstat: $netif
" for period in summary hours days months top10; do [ $ifcnt -ne 1 ] && echo "" gen_pic $netif $period [ $ifcnt -ne 1 ] && echo "" done if [ $ifcnt -ne 1 ]; then [ -n "$HTTP_REFERER" ] && backdest="history.go(-1)" || backdest="window.location.href='$SCRIPT_NAME'" echo "vnstat
" [ -z "$VNSTAT_INTERFACES" ] && VNSTAT_INTERFACES=$(ls /var/lib/vnstat/ 2>/dev/null) for dbfile in $VNSTAT_INTERFACES; do echo "" gen_pic $dbfile summary echo "" done fi echo "