Quote Originally Posted by Sector11 View Post
OH YEA!!!!!!!!!! You just answered a question I was going to have to worry about in 6 months .... what to do when the database has more than a years worth of info. That's for you and 'Kudos' too!

Code:
 26 Oct 12 | 17:50:08 ~
         $ vnstat -m |mawk -v last=12 '/[A-Z][a-z][a-z].+12/ {test[++i]=$0} END{i=0; while (test[++i]); --i; for (j=i-last; j<=i; j++) {$0=test[j]; print $1, $2 ":  "$3 $4"  "$6 $7"  "$9 $10}}'
 :      
 :      
 :      
 :      
 :      
 :      
 :      
May 12:  107.65MB  5.99MB  113.64MB
Jun 12:  13.95GB  863.18MB  14.79GB
Jul 12:  16.41GB  876.48MB  17.26GB
Aug 12:  24.46GB  1.21GB  25.67GB
Sep 12:  27.95GB  1.69GB  29.64GB
Oct 12:  39.82GB  1.58GB  41.39GB

 26 Oct 12 | 17:50:33 ~
         $
I'll get it into conky with 5 months and at the first every month add a month until I get to 11. It starts at 0
It'll do?
Code:
${execpi 300 vnstat -m |mawk -v last=12 '/[A-Z][a-z][a-z].+12/ {test[++i]=$0} END{i=0; while (test[++i]); if (last>i) last=i-1; else if (last<1) last=1; for (j=i-last; j<i; j++) {$0=test[j]; c1="${color green}"; if ($9>100) c1="${color red}"; print "${color6}"$1, $2 ":${color}${goto 75}" $3, $4 "${goto 175}" $6, $7 "${goto 275}" c1 $9 "${color}", $10}}'}
this shows last 12 months, but only those with actual data. You can change number of months with "-v last=12" and still, it will show as much as vnstat gives:
Code:
:~$ vnstat -m -i wlan0 |mawk -v last=12 '/[A-Z][a-z][a-z].+12/ {test[++i]=$0} END{i=0; while (test[++i]); if (last>i) last=i-1; else if (last<1) last=1; for (j=i-last; j<i; j++) {$0=test[j]; print $1, $2":\t" $3$4, "\t" $6$7, "\t" $9$10}}'
May '12:	62.58GiB 	8.92GiB 	71.49GiB
Jun '12:	120.64GiB 	8.83GiB 	129.47GiB
Jul '12:	78.36GiB 	10.38GiB 	88.74GiB
Aug '12:	80.44GiB 	6.36GiB 	86.80GiB
Sep '12:	258.00GiB 	17.10GiB 	275.10GiB
Oct '12:	147.50GiB 	10.70GiB 	158.20GiB
:~$