I need a command that I can run that returns the current utilization of wlan0
.
Does such a tool exist? I would prefer something that doesn't require root privileges.
ifstat
doesnt require root. Run it with -S
to update the current line instead of printing a new line for each measurement.
egil@mutter:~$ ifstat -S
eth0
KB/s in KB/s out
0.13 0.26
bmon runs without root:
If you give it the right parameters it returns only one line
bmon -o 'ascii:noheader;quitafter=1' -p wlan0
wlan0 0.00B 0.0 0.00B 0.0
maybe this helps
Here is a shell script that prints a short line with realtime data:
#!/bin/bash
ifstat -q -i wlan0 -S 0.1 1 | perl -n -e '/(\d+\.\d+).*(\d+\.\d+)/ && print "Down: $1 KBps - Up: $2 KBps\n"'
Sample Output:
Down: 4.25 KBps - Up: 0.00 KBps
Special thanks to Egil for his answer which pointed me to ifstat
.
A php soulution similar to the BASH example
#!/usr/bin/php -q
<?php
define('IFSTAT', '/usr/bin/ifstat');
define('LINK', 'wlan0');
$output = exec(IFSTAT . ' -q -i ' . LINK . ' 0.1 1');
$output = preg_replace('/\s+/', ' ', $output);
echo 'DOWN: ' . str_replace(' ', 'Kbps, UP:', trim($output)) . 'Kbps' . PHP_EOL;
vnstat provides daily and monthly RX and TX. No root required.
Install vnstat via synaptic. Then open a terminal and enter 'vnstat'
Don't be surprised if you don't get any results for the first day or two. It takes 2-3 days to get results which look like:
rx: 41.61 GiB tx: 1.84 GiB total: 43.46 GiB
monthly rx | tx | total | avg. rate ------------------------+-------------+-------------+--------------- Jun '11 3.55 GiB | 167.75 MiB | 3.71 GiB | 12.02 kbit/s Jul '11 38.07 GiB | 1.68 GiB | 39.74 GiB | 161.42 kbit/s ------------------------+-------------+-------------+--------------- estimated 49.36 GiB | 2.17 GiB | 51.54 GiB |
daily rx | tx | total | avg. rate ------------------------+-------------+-------------+--------------- yesterday 3.35 GiB | 138.04 MiB | 3.48 GiB | 338.34 kbit/s today 1.63 GiB | 84.11 MiB | 1.71 GiB | 183.41 kbit/s ------------------------+-------------+-------------+--------------- estimated 1.80 GiB | 92 MiB | 1.89 GiB |
you can also check network usage/traffic monitor from nethogs.
you can install it by sudo apt-get install nethogs
.
then launch it as sudo nethogs <Connection_name>
.
Look at the image for example.