#!/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 "

\"vnstat:

" } #main echo "
" netif=$(cgi_param netif) #count ifs ifcnt=0 for ifname in $VNSTAT_INTERFACES; do let ifcnt++ done [ $ifcnt -eq 1 ] && netif=$VNSTAT_INTERFACES #show pix if [ -n "$netif" ]; then #subpages 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 "
" fi else #mainpage 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 "
"