#!/bin/sh - # # openfiles # # Copyright (C) 2005 by # Oliver Fromme # All rights reserved. # Standard 2-clause BSD license and disclaimer applies. # # This script lists processes sorted by the number of # open file descriptors. Works on FreeBSD 4 and 5. # fstat | awk '($3!="PID"){print $3, $2}' | sort | uniq -c | sort -n | awk ' function pr (c1, c2, c3) { printf "%s\t%s\t%s\n", c1, c2, c3 } BEGIN { pr("#DESCR", "PID", "CMD") } { pr($1, $2, $3) s += $1 } ' prsys() { SC=$1 shift printf '%s\t%s\n' `sysctl -n $SC` "$*" } prsys kern.openfiles "Total number of descriptors in use" prsys kern.maxfilesperproc "Maximum number of descriptors per process" prsys kern.maxfiles "Maximum number of descriptors system-wide" #--