• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: CPU load and by id
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CPU load and by id


  • Subject: Re: CPU load and by id
  • From: Takaaki Naganoya <email@hidden>
  • Date: Fri, 24 Mar 2006 12:08:34 +0900
  • Thread-topic: CPU load and by id

How about this code?

<AppleScript>
set aPID to 1089 --example
set b to getLoadAVGofProcess(aPID) of me

--Get CPU Load of a Process indicated by Process ID
on getLoadAVGofProcess(aPID)
    set aShellText to "ps -auxc  -p " & aPID & " | awk '{print $3}' "
    try
        set a to do shell script aShellText
        set b to item 2 of (paragraphs of a)
        set b to b as number
    on error
        set b to 0
    end try

    return b
end getLoadAVGofProcess
</AppleScript>

--
Takaaki Naganoya
Piyomaru Software
http://www.appleco.jp/piyomarusoft/

On 06.3.24 3:44 AM, "Jeremy Matthews" <email@hidden> wrote:

> Anyone know the "best" way to find how much load a process is producing on a
> system...if so, by name?
>
> I use this to find a process' ID...and works (mostly)
>
> do shell script "my_command &> /dev/null & echo $!"
> -- result: 621
> set pid to the result
>
> But, I'm not sure how to find this process' current load...any ideas?
>
> Thanks,
> jeremy
>  _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Applescript-users mailing list      (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
>


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >CPU load and by id (From: Jeremy Matthews <email@hidden>)

  • Prev by Date: Re: Return or No Return
  • Next by Date: Re: Return or No Return
  • Previous by thread: CPU load and by id
  • Next by thread: Return or No Return
  • Index(es):
    • Date
    • Thread