Forums
New posts
Articles
Product Reviews
Policies
FAQ
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Menu
Log in
Register
Install the app
Install
Forums
Apple Computing Products:
macOS - Desktop Hardware
Advice needed about a script to report network throughput
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Davo64" data-source="post: 1547316" data-attributes="member: 314153"><p>Hi y'all.</p><p></p><p>I am using the following script through Geektool:</p><p></p><p>#!/bin/sh</p><p># Change this to en0 for an ethernet connection instead of airport</p><p>INTF=en0</p><p></p><p># get the current number of bytes in and bytes out</p><p>sample1=(`/usr/sbin/netstat -ib -I $INTF | /usr/bin/awk "/$INTF/"'{print $7" "$10; exit}'`)</p><p></p><p># wait one second</p><p>/bin/sleep 1</p><p></p><p># get the number of bytes in and out one second later</p><p>sample2=(`/usr/sbin/netstat -ib -I $INTF | /usr/bin/awk "/$INTF/"'{print $7" "$10; exit}'`)</p><p></p><p># find the difference between bytes in and out during that one second</p><p># and convert bytes to kilobytes</p><p>results=(`/bin/echo "2k ${sample2[0]} ${sample1[0]} - 1024 / p" "${sample2[1]} ${sample1[1]} - 1024 / p" | /usr/bin/dc`)</p><p></p><p># print the results</p><p>/usr/bin/printf "%.2f / %.2f \n" ${results[0]} ${results[1]}</p><p></p><p>Works well (I cannibalised someone else's code, so it isn't mine). The problem I have is that is stops working if I use a proxy server (using MacProxy), and I can't see why it should. I get zero output, bit when I disconnect from the proxy server, all is well again and it resumes. At this point I am out of my depth.</p><p></p><p>Any thoughts what changes I need to make to helpt it work through a proxy server?</p><p></p><p>Davo</p></blockquote><p></p>
[QUOTE="Davo64, post: 1547316, member: 314153"] Hi y'all. I am using the following script through Geektool: #!/bin/sh # Change this to en0 for an ethernet connection instead of airport INTF=en0 # get the current number of bytes in and bytes out sample1=(`/usr/sbin/netstat -ib -I $INTF | /usr/bin/awk "/$INTF/"'{print $7" "$10; exit}'`) # wait one second /bin/sleep 1 # get the number of bytes in and out one second later sample2=(`/usr/sbin/netstat -ib -I $INTF | /usr/bin/awk "/$INTF/"'{print $7" "$10; exit}'`) # find the difference between bytes in and out during that one second # and convert bytes to kilobytes results=(`/bin/echo "2k ${sample2[0]} ${sample1[0]} - 1024 / p" "${sample2[1]} ${sample1[1]} - 1024 / p" | /usr/bin/dc`) # print the results /usr/bin/printf "%.2f / %.2f \n" ${results[0]} ${results[1]} Works well (I cannibalised someone else's code, so it isn't mine). The problem I have is that is stops working if I use a proxy server (using MacProxy), and I can't see why it should. I get zero output, bit when I disconnect from the proxy server, all is well again and it resumes. At this point I am out of my depth. Any thoughts what changes I need to make to helpt it work through a proxy server? Davo [/QUOTE]
Verification
Name this item 🌈
Post reply
Forums
Apple Computing Products:
macOS - Desktop Hardware
Advice needed about a script to report network throughput
Top