Re: get accounting info for running process
Is it possible to find out how much a process have used CPU user time/system time/IO operations for now by it's pid? Like in sa, but for running process. Dan, Mel, thanks for your answers. I examined 'ps' sources and decided to use kvm_getprocs() and rusage structure. I am trying to create a daemon that would report system accounting stats for every X seconds, let's say 10. 'sa' reports about terminated processes only, but it would be nice to have more detailed system usage stats per user for a given time interval (i.e. last 10 seconds), including tasks that are not finished at the moment of querying. I can achieve this by querying list of processes each 10 seconds and producing diffs between previous and current list, saving these to some log and combining data with /var/account/acct file. The only thing I do not want to do is to invent a wheel ;-) I googled much for such solutions, but did not find any. May be someone knows existing products that has this functionality already? Thanks in advance. ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: get accounting info for running process
On Thu, 19 Nov 2009 20:01:02 +0300, cronfy cro...@sprinthost.ru wrote: Is it possible to find out how much a process have used CPU user time/system time/IO operations for now by it's pid? Like in sa, but for running process. Dan, Mel, thanks for your answers. I examined 'ps' sources and decided to use kvm_getprocs() and rusage structure. I am trying to create a daemon that would report system accounting stats for every X seconds, let's say 10. 'sa' reports about terminated processes only, but it would be nice to have more detailed system usage stats per user for a given time interval (i.e. last 10 seconds), including tasks that are not finished at the moment of querying. I can achieve this by querying list of processes each 10 seconds and producing diffs between previous and current list, saving these to some log and combining data with /var/account/acct file. The only thing I do not want to do is to invent a wheel ;-) I googled much for such solutions, but did not find any. May be someone knows existing products that has this functionality already? I don't know of anything like that, but ... there is of course radius. Depends what you want to do with the info. If usage restriction is your ultimate goal, then radius is your friend. -- Mel ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
get accounting info for running process
Hello. Is it possible to find out how much a process have used CPU user time/system time/IO operations for now by it's pid? Like in sa, but for running process. Thanks in advance. ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: get accounting info for running process
In the last episode (Nov 18), cronfy said: Is it possible to find out how much a process have used CPU user time/system time/IO operations for now by it's pid? Like in sa, but for running process. It's available to userland programs via the kern.proc.all syscall. it returns an array of struct kinfo_proc, one for each process. One of the elements is ki_rusage, which contains the data that the sa command uses. The ps command can easily be extended to print these fields. See this patch at http://lists.freebsd.org/pipermail/freebsd-hackers/2009-March/027918.html for an example. (I still need to file that PR...) -- Dan Nelson dnel...@allantgroup.com ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: get accounting info for running process
On Wed, 18 Nov 2009 20:18:08 +0300, cronfy cro...@sprinthost.ru wrote: Is it possible to find out how much a process have used CPU user time/system time/IO operations for now by it's pid? Like in sa, but for running process. Thanks in advance. man procfs(5), specifically, the status file. % cat /proc/2143/status Xorg ... 1255690702,469845 177507,790130 115403,436713 ... ^starttime^^^ ^usertime ^system time^ -- Mel ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org