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
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