GeekTool Commands

Posted by Tony Brizuela | Posted in Computers | Posted on 31-07-2009

Tagged Under : ,

Here are some of my favorite UNIX commands for GeekTool.

–CPU Utilization–


echo CPU

top -l 1| awk ‘/CPU usage/ {print $8, $9}’

top -l 1| awk ‘/CPU usage/ {print $10, $11}’

top -l 1| awk ‘/CPU usage/ {print $12, $13}’

CPU


–Top CPU–

top -FR -l2 -o cpu | grep -v 0.0% | cut -c 7-24| sed -n ’15, $p’

Top CPU

–Memory–

top -orsize -FR -l1 | grep % | grep -v Load | grep -v COMMAND | cut -c 7-19,64-69

Memory

–Top Memory–

echo Memory

top -l 1 | awk ‘/PhysMem/ {print “Used: ” $8}’

top -l 1 | awk ‘/PhysMem/ {print “Free:  ” $6+$10″M”}’

top -l 1 | awk ‘/PhysMem/ {print “Used: ” $8 ” Free: ” $10}’


Top Memory

–Bandwidth Monitor–

This requires you to have Perl on your computer.

Most OSX machines already have it.

You can download the Perl Script here

After downloading, open Terminal and type the following:

open /usr/bin

It should open up a new Finder window for you and you can just drag and drop
the “BandwidthMonitor.perl” file into the folder.
It may require some authentication so it’ll ask for your password.

Now all you need to do is go back to Geek Tool

Select: Shell
Type on Command:

perl /usr/bin/BandwidthMonitor.perl

Remember to set the refresh rate.

Network

To display your public IP Address use:

curl -s www.whatismyip.com/automation/n09230945.asp | awk {‘print “Public IP : ” $1′}

–Network Activity–

#!/bin/sh
# get the current number of bytes in and bytes out
myvar1=`netstat -ib | grep -e “en1″ -m 1 | awk ‘{print $7}’` #  bytes in
myvar3=`netstat -ib | grep -e “en1″ -m 1 | awk ‘{print $10}’` # bytes out
#wait one second
sleep 1
# get the number of bytes in and out one second later
myvar2=`netstat -ib | grep -e “en1″ -m 1 | awk ‘{print $7}’` # bytes in again
myvar4=`netstat -ib | grep -e “en1″ -m 1 | awk ‘{print $10}’` # bytes out again
# find the difference between bytes in and out during that one second
subin=$(($myvar2 – $myvar1))
subout=$(($myvar4 – $myvar3))
# convert bytes to kilobytes
kbin=`echo “scale=2; $subin/1024;” | bc`
kbout=`echo “scale=2; $subout/1024;” | bc`
# print the results
echo Network
echo “In: $kbin Kb/sec”
echo “Out: $kbout Kb/sec”

#!/bin/sh

# get the current number of bytes in and bytes out

myvar1=`netstat -ib | grep -e “en1″ -m 1 | awk ‘{print $7}’` #  bytes in

myvar3=`netstat -ib | grep -e “en1″ -m 1 | awk ‘{print $10}’` # bytes out

#wait one second

sleep 1

# get the number of bytes in and out one second later

myvar2=`netstat -ib | grep -e “en1″ -m 1 | awk ‘{print $7}’` # bytes in again

myvar4=`netstat -ib | grep -e “en1″ -m 1 | awk ‘{print $10}’` # bytes out again

# find the difference between bytes in and out during that one second

subin=$(($myvar2 – $myvar1))

subout=$(($myvar4 – $myvar3))

# convert bytes to kilobytes

kbin=`echo “scale=2; $subin/1024;” | bc`

kbout=`echo “scale=2; $subout/1024;” | bc`

# print the results

echo Network

echo “In: $kbin Kb/sec”

echo “Out: $kbout Kb/sec”

inout


Comments are closed.