[Ericsson Utvecklings AB]

cpu_sup

MODULE

cpu_sup

MODULE SUMMARY

A CPU Load Supervisor Process

DESCRIPTION

cpu_sup is part of the os_mon application and all configuration parameters are defined in the reference documentation for the os_mon application.

cpu_sup is a process which supervises the CPU load in the operating system. The load is obtained via the Solaris kernel statistics library, kstat. The same underlying mechanism is used by many other well known UNIX programs, such as rup, top and xload.

The Solaris kernel continuously maintains a large number of statistics, of which the current load values are just a few. Whenever an Erlang process requests a load measurement, cpu_sup just reads the latest statistical values.

The Solaris kernel load values are proportional to how long time a runnable UNIX process has to spend in the run queue before it is scheduled. Accordingly, higher values mean more system load. The returned value divided by 256 produces the figure displayed by rup and top. What is displayed as 2.00 in rup, is displayed as as load up to the second mark in xload.

For example, rup displays a load of 128 as 0.50, and 512 as 2.00.

If the user wants to view load values as percentages of machine capacity, then this way of measuring presents a problem, because the load values are not restricted to a fixed interval. In this case, the following simple mathematical transformation can produce the load value as a percentage:

PercentLoad = 100 * (1 - D/(D + Load))

D determines which load value should be associated with which percentage. Choosing D = 50 means that 128 is 60% load, 256 is 80%, 512 is 90%, and so on.

Another way of measuring system load is to divide the number of busy CPU cycles by the total number of CPU cycles. This method is used by some systems, including Windows NT for example, and it produces values in the 0-100 range immediately. However, this method hides the fact that a machine can be more or less saturated.

A server which receives just enough requests to never become idle would score 100% with this measurement method. If the server receives 50% more requests, it would still score 100%. With the measurement method used in this module, the load would increase from 80% to 87% when calculated with the percentage formula shown previously.

EXPORTS

nprocs() -> UnixProcesses

Types:

UnixProcesses = integer()

Returns the number of UNIX processes running on this machine. This is a crude way of measuring the system load, but it may be of interest in some cases.

avg1() -> SystemLoad

Types:

SystemLoad = integer()

Returns the average system load in the last 60 seconds, as described above. 0 represents no load, 256 represents the load reported as 1.00 by rup.

avg5() -> SystemLoad

Types:

SystemLoad = integer()

Returns the average system load from the last 300 seconds, as described above. 0 represents no load, 256 represents the load reported as 1.00 by rup.

avg15() -> SystemLoad

Types:

SystemLoad = integer()

Returns the average system load from the last 900 seconds, as described above. 0 represents no load, 256 represents the load reported as 1.00 by rup.

AUTHORS

Janne Lindblad - support@erlang.ericsson.se

os_mon 1.5.0
Copyright © 1991-2002 Ericsson Utvecklings AB