On 03/04/2017 11:02 AM, Galen Seitz wrote:
> On 03/04/17 00:41, Richard Owlett wrote:
>> On 03/02/2017 01:48 PM, Keith Lofstrom wrote:
>>> On Wed, Mar 01, 2017 at 04:33:57PM -0600, Richard Owlett wrote:
>>>> Is there a tool which can be
>>>> "turned on" at time t0
>>>> "turned off" at time t1
>>>> which will report the number of
>>>> "uploaded" bytes
>>>> "downloaded" bytes
>>>> in that interval?
>>>
>>> For your purposes, perhaps you pipe a standard interface
>>> reporting tool into a text file that you can edit into
>>> .cvs format for a spreadsheet.
>>>
>>> However, sometimes the easiest way to do stuff is to learn
>>> a scripting language and automate a task. The good thing
>>> about scripting languages is that you can always look at
>>> the program to remind yourself how it works.
>>> [snip]
>>
>> For my needs I'll skip aiming at a spreadsheet and write some simple
>> bash scripts to gather data and do some basic formatting. For anything
>> more complex I'll use Tcl/Tk as I use it in another project. The more
>> practice the better.
>>
>> I someone asks "How much can be done in bash?", I suggest browsing
>> http://www.tldp.org/LDP/Bash-Beginners-Guide/html/Bash-Beginners-Guide.html
>> and
>> http://www.tldp.org/LDP/abs/html .
>
> If you want to use this as a learning exercise, go for it. If not, then
> I feel you are making this more complicated than necessary.
>
> First capture your data as Robert suggested. Change the 10 to whatever
> time interval is desired.
> cp /proc/net/dev /tmp/foo; sleep 10; cat /proc/net/dev >> /tmp/foo
>
> Now open the file using libreoffice. Under Separator options, select
> "Space" and "Merge delimiters". Click OK. Your task, as you have
> described it, is now about 95% complete.
>
> galen
>
How about 100% complete in less than 10 lines of Bash ;/
[left room for coding glitzy trim ;]
mystring=$(echo $(grep "usb0" /proc/net/dev))
read -r -a myarray <<<$mystring
owl1=${myarray[1]}
# insert process to be measured
mystring=$(echo $(grep "usb0" /proc/net/dev))
read -r -a myarray <<<$mystring
owl2=${myarray[1]}
bytes=$(dc -e "1k $owl2 $owl1 - p ")
echo "You have just downloaded " $bytes " bytes"
_______________________________________________
PLUG mailing list
[email protected]
http://lists.pdxlinux.org/mailman/listinfo/plug