I would like to monitor the number of threads used by a specific process on Linux. Is there an easy way to get this information without impacting the performance of the proc
Here is one command that displays the number of threads of a given process :
ps -L -o pid= -p | wc -l
Unlike the other ps based answers, there is here no need to substract 1 from its output as there is no ps header line thanks to the -o pid=option.
ps
1
-o pid=