Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!dali.cs.montana.edu!caen!malgudi!uoft02.utoledo.edu!grx0736 From: grx0736@uoft02.utoledo.edu Newsgroups: comp.unix.questions Subject: getting %CPU from proc structure Message-ID: <1991May31.141309.3868@uoft02.utoledo.edu> Date: 31 May 91 19:13:09 GMT Lines: 29 i am writing my own version of remote "ps" to monitor processes on various Sun machines on a network using RPC. Well, the problem is not exactly in network programming but in getting ps -ux style info from the "proc" and "user" structures. Specifically, how can i get %CPU as output by ps -ux ? proc structure provides two relevant (in my opinion) fields: proc->p_pctcpu /* %CPU ? */ proc->p_cputicks /* seemingly used in calculating %CPU */ user structure provides the user and system times, as also the start time of the process. (i doubt if this is required for %CPU) Question: how can i use the above to calculate %CPU ? Or am i off the track in asuming that the above are the only parameters used to calculate %CPU ? I do not think proc->p_pctcpu provides direct value to be listed as %CPU because the values proc->p_pctcpu bears are many a times more than 100. Any info is highly appreciated. Sunil