Topic: vnstat-icon

someone on the irc channel had mentioned making a graphical interface to vnstat, heres a beginning of one http://www.crunchbanglinux.org/pastebin/133 . So far it allows you to set the display daily, weekly, or monthly. If you have more than one interface tracked it adds the stats together for them. It doesn't remember what you select for interval (daily,weekly,monthly) between runs now, and doesn't set which interfaces to monitor, but if people show an interest in it I can add more features. To use download the script and save as vnstat-icon.py, then chmod +x it and type vnstat-icon.py to run it. (it hasn't been tested with more than one interface but it should work)

I say never be complete, I say stop being perfect, I say lets evolve, let the chips fall where they may.

Re: vnstat-icon

Interesting, thanks for that.

Might chime in a few patches/additions once i've got oblogout 0.2 out the door.

Re: vnstat-icon

I use vnstat to record usage of my 3G modem, I will have to give this a try tonight when I get to work. Thank you iggykoopa smile

Re: vnstat-icon

Nice to see my long standing idea put into action. Nice work iggykoopa big_smile

Re: vnstat-icon

thanks the code is pretty rough right now so I'll try to improve it, just wanted to get a test version working big_smile

I say never be complete, I say stop being perfect, I say lets evolve, let the chips fall where they may.

Re: vnstat-icon

I think I have followed the instructions but keep getting "bash: vnstat-icon.py: command not found"

I would have thought , with the big increase in mobile broadband useage, that more people would be looking to try this script out. Nice work Iggy

Re: vnstat-icon

try ./vnstat-icon.py if your in the same directory as a script in linux you need the ./

I say never be complete, I say stop being perfect, I say lets evolve, let the chips fall where they may.

Re: vnstat-icon

Interesting response to that command!! Terminal just hangs:|

Re: vnstat-icon

there shouldn't be any response in the terminal...but an icon should show up in your tray area...if you right-click you can set wether you want your daily,weekly,or monthly stats. If you left click it will pop up with your network usage. You have to manually setup vnstat beforehand though.

I say never be complete, I say stop being perfect, I say lets evolve, let the chips fall where they may.

Re: vnstat-icon

Hey!! it works.:) However I don't know which NIC its monitoring. I tend to use my eeepc with all manner of media ( wired/wifi and mobile broadband ppp0)

I'm really looking to use this this app to see how much of the 1G I bought from Vodafone has been used.

Re: vnstat-icon

it monitors whatever nic you have setup with vnstat... I believe if you set up multiple nics it does the total for all of them

I say never be complete, I say stop being perfect, I say lets evolve, let the chips fall where they may.

Re: vnstat-icon

That makes sense. Unfortunately I'm having problems setting up vnstat. I keep getting the following error message

chris@bravo:~$ vnstat -u -i ppp0
Error:
Unable to read database "/var/lib/vnstat/ppp0".
Error:
Unable to get interface statistics.
chris@bravo:~$

Re: vnstat-icon

having done some further research i think the problem is that no config file is being created. This post suggests changing permissions on /etc and I'm not too sure how to do that.:(

Update- I have now got it to work with eth0. Not too sure now how to change the (missing) config file to monitor ppp0.

Iggy- tried your script again and got the following output

chris@bravo:~$ ./vnstat-icon.py
Traceback (most recent call last):
  File "./vnstat-icon.py", line 178, in on_left_click
    check(interval)
  File "./vnstat-icon.py", line 33, in check
    elif sizes.index(rx_size) > sizes.index(stats[2]):
ValueError: list.index(x): x not in list
Traceback (most recent call last):
  File "./vnstat-icon.py", line 178, in on_left_click
    check(interval)
  File "./vnstat-icon.py", line 97, in check
    elif sizes.index(rx_size) > sizes.index(stats[3]):
ValueError: list.index(x): x not in list
Traceback (most recent call last):
  File "./vnstat-icon.py", line 178, in on_left_click
    check(interval)
  File "./vnstat-icon.py", line 97, in check
    elif sizes.index(rx_size) > sizes.index(stats[3]):
ValueError: list.index(x): x not in list

Last edited by lemmy999 (2009-04-25 09:19:16)

Re: vnstat-icon

whats your output from:
vnstat -d
sounds like it's not getting the response my script is looking for, sorry I haven't really put any error checking into it yet so if the output isn't right it just fails.

I say never be complete, I say stop being perfect, I say lets evolve, let the chips fall where they may.

Re: vnstat-icon

Output of vnstat -d

chris@bravo:~$ vnstat -d

 eth0  /  daily

    day         rx      |     tx      |  total
------------------------+-------------+----------------------------------------
   25.04.     13.70 MB  |       0 kB  |   13.70 MB   %%%%%%%%%%%%%%%%%%%%%%%%%
   26.04.      1.57 MB  |       0 kB  |    1.57 MB   %%
------------------------+-------------+----------------------------------------
 estimated       --     |      --     |      --   
chris@bravo:~$ 

Re: vnstat-icon

ok it should be fixed here http://www.crunchbanglinux.org/pastebin/233 . For some reason MB is capital but kB is mixed in vnstat.

Last edited by iggykoopa (2009-04-26 07:55:08)

I say never be complete, I say stop being perfect, I say lets evolve, let the chips fall where they may.

Re: vnstat-icon

Hmm!! Now I'm getting "bash: vnstat-icon.py: command not found" ????

Added to that I still haven't found the config file to  change the default interface to ppp0

Last edited by lemmy999 (2009-04-26 13:57:36)

Re: vnstat-icon

the bash error is the same as the first one you posted you need the ./vnstat-icon.py . Also there is no config file, when you set up vnstat you need to set it to monitor the correct interface.

here are the examples fromthe man pages:
vnstat -u -i interface forces a database update for interface or creates the database if it doesn't exist. This is usually the first command used after a fresh install.

vnstat -u -i interface --nick nick gives interface the nickname nick and that information will be later included with queries.

vnstat -u -r --disable -i interface resets the internal counters of interface and disables it from being updated before enabled again with the --enable parameter. This feature is especially useful for interfaces like ppp0 that aren't always active.

I say never be complete, I say stop being perfect, I say lets evolve, let the chips fall where they may.

Re: vnstat-icon

OK. I'll have another look at vnstat tomorrow and see if I can figure where I'm going wrong.

Re: vnstat-icon

Success!! All works fine once I engage brain. Just deleted all the irrelevant files out of /var/lib/vnstat and left ppp0.

Many thanks Iggy for your assistance