- Joined
- Oct 18, 2009
- Messages
- 110
- Reaction score
- 8
- Points
- 18
Ok, this is a little involved so buckle up. I've recently started using GeekTool (3.0 RC5) Tynsoe projects.
I have successfully created a shell Geeklet that uses Top to display a user defined number of processes and their CPU and RAM usage. This is very good information to have, but I would also like to see a summary of the overall RAM and CPU usage in a separate Geeklet.
Nick Young at Keynote 2 Keynote has done this on his system as shown on his blog: Ultimate GeekTool Setup - Pimp Your Desktop Part 2 at Keynote 2 Keynote
He lists the following command (note that he included uptime in his summary):
uptime | awk '{print "UPTIME : " $3 " " $4 " " $5 " " }'; top -l 1 | awk '/PhysMem/ {print "RAM : " $8 " "}' ; top -l 2 | awk '/CPU usage/ && NR > 5 {print $6, $7=":", $8, $9="user ", $10, $11="sys ", $12, $13}'
When I run that command I get an error. A friend of mine noticed that & should just be & and > should be >. I made those changes as below:
uptime | awk '{print "UPTIME : " $3 " " $4 " " $5 " " }'; top -l 1 | awk '/PhysMem/ {print "RAM : " $8 " "}' ; top -l 2 | awk '/CPU usage/ && NR > 5 {print $6, $7=":", $8, $9="user ", $10, $11="sys ", $12, $13}'
I now get the following result:
UPTIME : 5 days, 23:40,
RAM : 1844M
sys, : idle user sys
A couple of observations. First, his screenshot (see his blog) shows his RAM as 1.47G whereas mine is shown as 1844M. I prefer the G notation, but I can live with M if no one has a solution. Second, I'm not sure if that refers to RAM used or RAM available. Third, and most disturbing is that my command shows labels for CPU usage, but no actual percentages. I have been unable to find a fix for this. Finally, you notice that his screen shot shows the final line labeled as "CPU :" just as the other two are labeled "UPTIME :" and "RAM :". I made a further change to my command to "fix" this, but I don't know if I have broken something else in the process.
So my final command is:
uptime | awk '{print "UPTIME: " $3 " " $4 " " $5 " " }'; top -l 1 | awk '/PhysMem/ {print "RAM: " $8 " "}' ; top -l 2 | awk '/CPU usage/ && NR > 5 {print "CPU: " $8, $9="user ", $10, $11="sys ", $12, $13}'
and gives me the following output:
UPTIME: 5 days, 23:44,
RAM: 1906M
CPU: idle user sys
Any and all help you can provide would be appreciated.
I have successfully created a shell Geeklet that uses Top to display a user defined number of processes and their CPU and RAM usage. This is very good information to have, but I would also like to see a summary of the overall RAM and CPU usage in a separate Geeklet.
Nick Young at Keynote 2 Keynote has done this on his system as shown on his blog: Ultimate GeekTool Setup - Pimp Your Desktop Part 2 at Keynote 2 Keynote
He lists the following command (note that he included uptime in his summary):
uptime | awk '{print "UPTIME : " $3 " " $4 " " $5 " " }'; top -l 1 | awk '/PhysMem/ {print "RAM : " $8 " "}' ; top -l 2 | awk '/CPU usage/ && NR > 5 {print $6, $7=":", $8, $9="user ", $10, $11="sys ", $12, $13}'
When I run that command I get an error. A friend of mine noticed that & should just be & and > should be >. I made those changes as below:
uptime | awk '{print "UPTIME : " $3 " " $4 " " $5 " " }'; top -l 1 | awk '/PhysMem/ {print "RAM : " $8 " "}' ; top -l 2 | awk '/CPU usage/ && NR > 5 {print $6, $7=":", $8, $9="user ", $10, $11="sys ", $12, $13}'
I now get the following result:
UPTIME : 5 days, 23:40,
RAM : 1844M
sys, : idle user sys
A couple of observations. First, his screenshot (see his blog) shows his RAM as 1.47G whereas mine is shown as 1844M. I prefer the G notation, but I can live with M if no one has a solution. Second, I'm not sure if that refers to RAM used or RAM available. Third, and most disturbing is that my command shows labels for CPU usage, but no actual percentages. I have been unable to find a fix for this. Finally, you notice that his screen shot shows the final line labeled as "CPU :" just as the other two are labeled "UPTIME :" and "RAM :". I made a further change to my command to "fix" this, but I don't know if I have broken something else in the process.
So my final command is:
uptime | awk '{print "UPTIME: " $3 " " $4 " " $5 " " }'; top -l 1 | awk '/PhysMem/ {print "RAM: " $8 " "}' ; top -l 2 | awk '/CPU usage/ && NR > 5 {print "CPU: " $8, $9="user ", $10, $11="sys ", $12, $13}'
and gives me the following output:
UPTIME: 5 days, 23:44,
RAM: 1906M
CPU: idle user sys
Any and all help you can provide would be appreciated.