/proc/nzombies

From: Jos Visser (josv@osp.nl)
Date: Sat Feb 26 2000 - 04:50:20 EST


Running the risk to be deemed an irresponsible featurist I submit the
following:

SHORT:
-----

Let's extend the kernel with a /proc/nzombies feature that tells the
current number of zombies. This is handy for system and network
monitoring purposes. I did some homework and it is a quite trivial
extension to exit.c.

++Jos

LONG:

----

Many times I've been tasked with defining and implementing remote system and network monitoring. One of the items we always want to monitor is the number of zombies currently in the system, because, believe it or not, the wait*() series of system calls seems to be beyond a lot of application developers.

To count the number of zombies we usually run the process list (or, in Linux, the proc directory) and count the processes that are zombies. Although functional, it is quite a hassle and it is slow. When one of my students (I teach Linux Programming courses, amongst others) asked how to solve this I suggested that it should be a quite trivial extension to the kernel.

Once home I set about it and it proved to be a very small extension to exit.c. My currently running kernel contains the extension (see below). The feature adds a "nzombies++" to each exit(), and a "nzombies--" to each release.

++Jos

josv@jadzia:~ > ls -l /proc/nzombies -r--r--r-- 1 root root 0 Feb 26 10:43 /proc/nzombies josv@jadzia:~ > cat /proc/nzombies 0 josv@jadzia:~ > cursus/nortel/c/mkzombie & [1] 6555 josv@jadzia:~ > cat /proc/nzombies 1 josv@jadzia:~ > ps ajx | grep zombie 769 6555 6555 769 ? 6558 S 1001 0:00 cursus/nortel/c/mkzombie 6555 6556 6555 769 ? 6558 Z 1001 0:00 (mkzombie <zombie>) 769 6559 6558 769 ? 6558 S 1001 0:00 grep zombie josv@jadzia:~ > kill %1 [1]+ Terminated cursus/nortel/c/mkzombie josv@jadzia:~ > cat /proc/nzombies 0 josv@jadzia:~ >

-- All the rivers run into the sea; yet the sea is not full; unto the place from whence the rivers come, thither they return again.

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Tue Feb 29 2000 - 21:00:15 EST