# How to monitor the number of the opened kernel objects of a process?



## ecnux (Jul 28, 2011)

We often use kernel objects in our programming, including threads, signals, sockets, files...

In win32 system, it can be monitored in task manager and the kernel objects listed as "handles", "threads", "user objects"...

How can we get these information in BSD system? (may be use a command in bash)


----------



## SirDice (Jul 28, 2011)

Have a look at truss(1) and dtrace(1).


----------



## expl (Jul 28, 2011)

`top` is easiest way to get number of threads belonging to PIDs (THR field tells thread number).
`fstat -p PID` will show open file handles (files, sockets, devices, etc, ..) for the PID.


----------



## poh-poh (Jul 29, 2011)

procstat(1) can show things like memory mappings, open files/sockets, user/kernel threads, etc. Combine with sysutils/topless and you get them close to real-time. Also, some of the hot paths can be viewed with hwpmc(4), e.g.
`$ pmcstat -S instructions -T`


----------

