Posts

Showing posts from January, 2017

One-liner for count of lsof apache workers

ps h --ppid $(cat /var/run/apache2/apache2.pid) | awk '{printf("%s,",$1)}' | sed 's/,\s*$//' | xargs lsof -p | wc -l This gets the child process thread information by accessing the root pid for apache2, passes it off to awk to return csv output (sed just removes the last comma) and passes it to lsof as an csv list of pid's as an arg so wc can count lines... Not particularly safe but does the job I need to monitor file descriptors for zombie apache2 child processes.