Although the procinfo module may be used to monitor specific processes on the system, at times it may be more desirable to learn of the processes using the most resources on the system. The three "top" modules report on the processes with the most number of instances, most CPU usage, and most memory usage. The actual number of processes to report is configurable.
On Linux, process information is collected through files in the "/proc" directory. Specifically, "/proc/meminfo", "/proc/uptime", "/proc/x/cmdline", and "/proc/x/stat" are used, where in the last two "x" represents the PIDs of processes on the machine.
On the Solaris OS, information is gathered through "/proc/x/psinfo" and "/proc/x/lwp", where "x" represents the PIDs of processes on the machine.
Windows 2000/XP/2003 uses the Performance Data Helper to gather all process information. Process information in Windows 9x/NT is gathered with the toolhelp functions.
Configuration of topmem is very simple. There is only one variable which may be set: top. This tells topmem how many processes to return. The number may be anywhere from 1 to 10, and if not specified a default value of 5 will be used. For example:
config { top = 3 } |
This tells topmem to report the top 3 memory users on the system.
One threshold may be set for topmem with the name "mem". This will take the process with the most amount of memory usage, and compare it against the value given in the threshold. Any of the basic logical operators are allowed (==, !=, <, >, <=, >=). For example:
# Example threshold for topmem thresh1.threshold = TopMem.mem > 20% |
So if any process uses more than 20% of memory, the preceeding threshold will become crossed.