# Trying to get kernel thread processor time



## raVen (Jul 30, 2014)

I have been trying to get kernel thread processor times for graphical monitoring, but the output of `ps -AHo comm,time` is cutting thread names: 
	
	



```
kernel/zio_write_issue_     0:31,38
kernel/zio_write_issue_     0:31,23
kernel/zio_write_issue_     0:31,19
kernel/zio_write_issue_     0:31,39
kernel/zio_write_issue_     0:00,52
kernel/zio_write_issue_     0:00,53
kernel/zio_write_issue_     0:00,55
kernel/zio_write_issue_     0:00,54
kernel/zio_write_issue_     0:00,52
```
How can I get these names with processor times with ps() or with something else from the command line? I would like to get the full thread name and the processor time in seconds that was used by this thread.


----------



## worldi (Jul 30, 2014)

The problem seems to be that the threads names returned by kvm_getprocs (which is called by both ps and top) are limited to 16 characters:

```
# ps wwaxHo comm | awk -F/ '/^kernel/{print length($2)}' | sort -n | tail -1
16
#

% grep "thread name" /sys/sys/user.h
#define TDNAMLEN        16              /* size of returned thread name */
        char    ki_tdname[TDNAMLEN+1];  /* thread name */
%
```


----------



## SirDice (Jul 30, 2014)

I'm no kernel programmer but looking at the things you want to know you probably have more luck using specialized debug tools like ktrace(1) and dtrace(1).


----------

