Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Monitor one task's CPU usage via top' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Monitor one task's CPU usage via top
Authored by: bimtob on Nov 17, '04 02:36:30PM
I prefer perl. Don't know awk regex :)
My geektools...

Uptime
uptime | perl -p -e 's/^(.+?up\s+?)(\d+.+?)(\,\s+\d+\s+user.+)(.*)$/Uptime: $2/'
Load
uptime | perl -p -e 's/^(.*?)(\d\.\d\d\s\d\.\d\d\s\d\.\d\d)$/Load Avgs: $2/'
I also wrote a calendar script that looks better than the default cal output, and use Geektool to put it on my desktop. OSX should have an option to show the date in the menu bar (without clicking), but until then I use this.

It prints:

   November 17 2004
  S  M Tu  W Th  F  S
     1  2  3  4  5  6
  7  8  9 10 11 12 13
 14 15 16[17]18 19 20
 21 22 23 24 25 26 27
 28 29 30
The script:

#!/usr/bin/perl

use POSIX qw/strftime/;
use integer;

$date = strftime "%e",localtime;
$date =~ s/\s//;
@cal = `cal`;
$cal[0] = (strftime "%B %e %Y", localtime)."\n";
$cal[0] =~ s/\s\s/ /;
$il = " " x ((length($cal[1]) - length($cal[0]))/2);
$cal[0] =~ s/^/ $il/; 
print $cal[0];
for ($i = 1; $i <=6; $i++) {
        $cal[$i] =~ s/^(.*)\n$/ $1/;
        $cal[$i] =~ s/(^|\s)$date(\s|$)/\[$date\]/;
        print $cal[$i]."\n";
}


[ Reply to This | # ]