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.

Comments

Popular posts from this blog

Alternatives to: "The quick brown fox jumps over the lazy dog."

Using keys like ALT+TAB in UltraVNC.

Command-line installation of OpenVPN