Sophie

Sophie

distrib > Fedora > 17 > i386 > media > updates > by-pkgid > 675c8c8167236dfcf8d66da674f931e8 > files > 1130

erlang-doc-R15B-03.3.fc17.noarch.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html xmlns:fn="http://www.w3.org/2005/02/xpath-functions">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../../../../doc/otp_doc.css" type="text/css">
<title>Erlang -- cpu_sup</title>
</head>
<body bgcolor="white" text="#000000" link="#0000ff" vlink="#ff00ff" alink="#ff0000"><div id="container">
<script id="js" type="text/javascript" language="JavaScript" src="../../../../doc/js/flipmenu/flipmenu.js"></script><script id="js2" type="text/javascript" src="../../../../doc/js/erlresolvelinks.js"></script><script language="JavaScript" type="text/javascript">
            <!--
              function getWinHeight() {
                var myHeight = 0;
                if( typeof( window.innerHeight ) == 'number' ) {
                  //Non-IE
                  myHeight = window.innerHeight;
                } else if( document.documentElement && ( document.documentElement.clientWidth ||
                                                         document.documentElement.clientHeight ) ) {
                  //IE 6+ in 'standards compliant mode'
                  myHeight = document.documentElement.clientHeight;
                } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
                  //IE 4 compatible
                  myHeight = document.body.clientHeight;
                }
                return myHeight;
              }

              function setscrollpos() {
                var objf=document.getElementById('loadscrollpos');
                 document.getElementById("leftnav").scrollTop = objf.offsetTop - getWinHeight()/2;
              }

              function addEvent(obj, evType, fn){
                if (obj.addEventListener){
                obj.addEventListener(evType, fn, true);
                return true;
              } else if (obj.attachEvent){
                var r = obj.attachEvent("on"+evType, fn);
                return r;
              } else {
                return false;
              }
             }

             addEvent(window, 'load', setscrollpos);

             //--></script><div id="leftnav"><div class="innertube">
<img alt="Erlang logo" src="../../../../doc/erlang-logo.png"><br><small><a href="index.html">Reference Manual</a><br><a href="release_notes.html">Release Notes</a><br><a href="../pdf/os_mon-2.2.10.pdf">PDF</a><br><a href="../../../../doc/index.html">Top</a></small><p><strong>OS_Mon</strong><br><strong>Reference Manual</strong><br><small>Version 2.2.10</small></p>
<br><a href="javascript:openAllFlips()">Expand All</a><br><a href="javascript:closeAllFlips()">Contract All</a><p><small><strong>Table of Contents</strong></small></p>
<ul class="flipMenu">
<li title="os_mon (App)"><a href="os_mon_app.html">os_mon (App)
                </a></li>
<li id="loadscrollpos" title="cpu_sup " expanded="true">cpu_sup<ul>
<li><a href="cpu_sup.html">
                  Top of manual page
                </a></li>
<li title="nprocs-0"><a href="cpu_sup.html#nprocs-0">nprocs/0</a></li>
<li title="avg1-0"><a href="cpu_sup.html#avg1-0">avg1/0</a></li>
<li title="avg5-0"><a href="cpu_sup.html#avg5-0">avg5/0</a></li>
<li title="avg15-0"><a href="cpu_sup.html#avg15-0">avg15/0</a></li>
<li title="util-0"><a href="cpu_sup.html#util-0">util/0</a></li>
<li title="util-1"><a href="cpu_sup.html#util-1">util/1</a></li>
</ul>
</li>
<li id="no" title="disksup " expanded="false">disksup<ul>
<li><a href="disksup.html">
                  Top of manual page
                </a></li>
<li title="get_disk_data-0"><a href="disksup.html#get_disk_data-0">get_disk_data/0</a></li>
<li title="get_check_interval-0"><a href="disksup.html#get_check_interval-0">get_check_interval/0</a></li>
<li title="set_check_interval-1"><a href="disksup.html#set_check_interval-1">set_check_interval/1</a></li>
<li title="get_almost_full_threshold-0"><a href="disksup.html#get_almost_full_threshold-0">get_almost_full_threshold/0</a></li>
<li title="set_almost_full_threshold-1"><a href="disksup.html#set_almost_full_threshold-1">set_almost_full_threshold/1</a></li>
</ul>
</li>
<li id="no" title="memsup " expanded="false">memsup<ul>
<li><a href="memsup.html">
                  Top of manual page
                </a></li>
<li title="get_memory_data-0"><a href="memsup.html#get_memory_data-0">get_memory_data/0</a></li>
<li title="get_system_memory_data-0"><a href="memsup.html#get_system_memory_data-0">get_system_memory_data/0</a></li>
<li title="get_os_wordsize-0"><a href="memsup.html#get_os_wordsize-0">get_os_wordsize/0</a></li>
<li title="get_check_interval-0"><a href="memsup.html#get_check_interval-0">get_check_interval/0</a></li>
<li title="set_check_interval-1"><a href="memsup.html#set_check_interval-1">set_check_interval/1</a></li>
<li title="get_procmem_high_watermark-0"><a href="memsup.html#get_procmem_high_watermark-0">get_procmem_high_watermark/0</a></li>
<li title="set_procmem_high_watermark-1"><a href="memsup.html#set_procmem_high_watermark-1">set_procmem_high_watermark/1</a></li>
<li title="get_sysmem_high_watermark-0"><a href="memsup.html#get_sysmem_high_watermark-0">get_sysmem_high_watermark/0</a></li>
<li title="set_sysmem_high_watermark-1"><a href="memsup.html#set_sysmem_high_watermark-1">set_sysmem_high_watermark/1</a></li>
<li title="get_helper_timeout-0"><a href="memsup.html#get_helper_timeout-0">get_helper_timeout/0</a></li>
<li title="set_helper_timeout-1"><a href="memsup.html#set_helper_timeout-1">set_helper_timeout/1</a></li>
</ul>
</li>
<li id="no" title="os_mon_mib " expanded="false">os_mon_mib<ul>
<li><a href="os_mon_mib.html">
                  Top of manual page
                </a></li>
<li title="load-1"><a href="os_mon_mib.html#load-1">load/1</a></li>
<li title="unload-1"><a href="os_mon_mib.html#unload-1">unload/1</a></li>
</ul>
</li>
<li id="no" title="os_sup " expanded="false">os_sup<ul>
<li><a href="os_sup.html">
                  Top of manual page
                </a></li>
<li title="enable-0"><a href="os_sup.html#enable-0">enable/0</a></li>
<li title="enable-2"><a href="os_sup.html#enable-2">enable/2</a></li>
<li title="disable-0"><a href="os_sup.html#disable-0">disable/0</a></li>
<li title="disable-2"><a href="os_sup.html#disable-2">disable/2</a></li>
</ul>
</li>
<li id="no" title="nteventlog " expanded="false">nteventlog<ul>
<li><a href="nteventlog.html">
                  Top of manual page
                </a></li>
<li title="start-2"><a href="nteventlog.html#start-2">start/2</a></li>
<li title="start_link-2"><a href="nteventlog.html#start_link-2">start_link/2</a></li>
<li title="stop-0"><a href="nteventlog.html#stop-0">stop/0</a></li>
</ul>
</li>
</ul>
</div></div>
<div id="content">
<div class="innertube">
<!-- refpage --><center><h1>cpu_sup</h1></center>
  
  <h3>MODULE</h3>
<div class="REFBODY">cpu_sup</div>
  <h3>MODULE SUMMARY</h3>
<div class="REFBODY">A CPU Load and CPU Utilization Supervisor Process</div>
  <h3>DESCRIPTION</h3>
<div class="REFBODY"><p>
    <p><span class="code">cpu_sup</span> is a process which supervises the CPU load
      and CPU utilization. It is part of the OS_Mon application, see
      <span class="bold_code"><a href="os_mon_app.html">os_mon(6)</a></span>. Available for Unix,
      although CPU utilization values (<span class="code">util/0,1</span>) are only
      available for Solaris and Linux.</p>
    <p>The 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 <span class="code">rup</span>
      and <span class="code">top</span>. What is displayed as 2.00 in <span class="code">rup</span>, is
      displayed as load up to the second mark in <span class="code">xload</span>.</p>
    <p>For example, <span class="code">rup</span> displays a load of 128 as 0.50, and
      512 as 2.00.</p>
    <p>If the user wants to view load values as percentage 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:</p>
    <div class="example"><pre>
      PercentLoad = 100 * (1 - D/(D + Load))
    </pre></div>
    <p><span class="code">D</span> determines which load value should be associated with
      which percentage. Choosing <span class="code">D</span> = 50 means that 128 is 60% 
      load, 256 is 80%, 512 is 90%, and so on.</p>
    <p>Another way of measuring system load is to divide the number of
      busy CPU cycles by the total number of CPU cycles. This produces 
      values in the 0-100 range immediately. However, this method hides 
      the fact that a machine can be more or less saturated. CPU
      utilization is therefore a better name than system load for this
      measure.</p>
    <p>A server which receives just enough requests to never become
      idle will score a CPU utilization of 100%. If the server receives
      50% more requests, it will still scores 100%. When the system load
      is calculated with the percentage formula shown previously,
      the load will increase from 80% to 87%.</p>
    <p>The <span class="code">avg1/0</span>, <span class="code">avg5/0</span>, and <span class="code">avg15/0</span> functions
      can be used for retrieving system load values, and
      the <span class="code">util/0</span> and <span class="code">util/1</span> functions can be used for
      retrieving CPU utilization values.</p>
    <p>When run on Linux, <span class="code">cpu_sup</span> assumes that the <span class="code">/proc</span>
      file system is present and accessible by <span class="code">cpu_sup</span>. If it is
      not, <span class="code">cpu_sup</span> will terminate.</p>
  </p></div>
  <h3>EXPORTS</h3>
    <p><a name="nprocs-0"><span class="bold_code">nprocs() -&gt; UnixProcesses | {error, Reason}</span></a><br></p>
<div class="REFBODY">
<p>Types:</p>
        <div class="REFTYPES">
<span class="bold_code">UnixProcesses = int()</span><br>
</div>
        <div class="REFTYPES">
<span class="bold_code">Reason = term()</span><br>
</div>
      </div>
<div class="REFBODY"><p>
        <p>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.</p>
        <p>Returns 0 if <span class="code">cpu_sup</span> is not available.</p>
      </p></div>
    <p><a name="avg1-0"><span class="bold_code">avg1() -&gt; SystemLoad | {error, Reason}</span></a><br></p>
<div class="REFBODY">
<p>Types:</p>
        <div class="REFTYPES">
<span class="bold_code">SystemLoad = int()</span><br>
</div>
        <div class="REFTYPES">
<span class="bold_code">Reason = term()</span><br>
</div>
      </div>
<div class="REFBODY"><p>
        <p>Returns the average system load in the last minute, as
          described above. 0 represents no load, 256 represents the load
          reported as 1.00 by <span class="code">rup</span>.</p>
        <p>Returns 0 if <span class="code">cpu_sup</span> is not available.</p>
      </p></div>
    <p><a name="avg5-0"><span class="bold_code">avg5() -&gt; SystemLoad | {error, Reason}</span></a><br></p>
<div class="REFBODY">
<p>Types:</p>
        <div class="REFTYPES">
<span class="bold_code">SystemLoad = int()</span><br>
</div>
        <div class="REFTYPES">
<span class="bold_code">Reason = term()</span><br>
</div>
      </div>
<div class="REFBODY"><p>
        <p>Returns the average system load in the last five minutes, as
          described above. 0 represents no load, 256 represents the load
          reported as 1.00 by <span class="code">rup</span>.</p>
        <p>Returns 0 if <span class="code">cpu_sup</span> is not available.</p>
      </p></div>
    <p><a name="avg15-0"><span class="bold_code">avg15() -&gt; SystemLoad | {error, Reason}</span></a><br></p>
<div class="REFBODY">
<p>Types:</p>
        <div class="REFTYPES">
<span class="bold_code">SystemLoad = int()</span><br>
</div>
        <div class="REFTYPES">
<span class="bold_code">Reason = term()</span><br>
</div>
      </div>
<div class="REFBODY"><p>
        <p>Returns the average system load in the last 15 minutes, as
          described above. 0 represents no load, 256 represents the load
          reported as 1.00 by <span class="code">rup</span>.</p>
        <p>Returns 0 if <span class="code">cpu_sup</span> is not available.</p>
      </p></div>
    <p><a name="util-0"><span class="bold_code">util() -&gt; CpuUtil | {error, Reason}</span></a><br></p>
<div class="REFBODY">
<p>Types:</p>
        <div class="REFTYPES">
<span class="bold_code">CpuUtil = float()</span><br>
</div>
        <div class="REFTYPES">
<span class="bold_code">Reason = term()</span><br>
</div>
      </div>
<div class="REFBODY"><p>
        <p>Returns CPU utilization since the last call to
          <span class="code">util/0</span> or <span class="code">util/1</span> by the calling process.</p>
        <div class="note">
<div class="label">Note</div>
<div class="content"><p>
          <p>The returned value of the first call to <span class="code">util/0</span> or
            <span class="code">util/1</span> by a process will on most systems be the CPU
            utilization since system boot, but this is not guaranteed
            and the value should therefore be regarded as garbage. This
            also applies to the first call after a restart of
            <span class="code">cpu_sup</span>.</p>
        </p></div>
</div>
        <p>The CPU utilization is defined as the sum of the percentage
          shares of the CPU cycles spent in all busy processor states
          (see <span class="code">util/1</span> below) in average on all CPUs.</p>
        <p>Returns 0 if <span class="code">cpu_sup</span> is not available.</p>
      </p></div>
    <p><a name="util-1"><span class="bold_code">util(Opts) -&gt; UtilSpec | {error, Reason}</span></a><br></p>
<div class="REFBODY">
<p>Types:</p>
        <div class="REFTYPES">
<span class="bold_code">Opts = [detailed | per_cpu]</span><br>
</div>
        <div class="REFTYPES">
<span class="bold_code">UtilSpec = UtilDesc | [UtilDesc]</span><br>
</div>
        <div class="REFTYPES">
<span class="bold_code"> UtilDesc = {Cpus, Busy, NonBusy, Misc}</span><br>
</div>
        <div class="REFTYPES">
<span class="bold_code">  Cpus = all | int() | [int()]()</span><br>
</div>
        <div class="REFTYPES">
<span class="bold_code">  Busy = NonBusy = {State, Share} | Share</span><br>
</div>
        <div class="REFTYPES">
<span class="bold_code">   State = user | nice_user | kernel</span><br>
</div>
        <div class="REFTYPES">
<span class="bold_code">    | wait | idle | atom()</span><br>
</div>
        <div class="REFTYPES">
<span class="bold_code">   Share = float()</span><br>
</div>
        <div class="REFTYPES">
<span class="bold_code">  Misc = []</span><br>
</div>
        <div class="REFTYPES">
<span class="bold_code">Reason = term()</span><br>
</div>
      </div>
<div class="REFBODY"><p>
        <p>Returns CPU utilization since the last call to
          <span class="code">util/0</span> or <span class="code">util/1</span> by the calling process, in
          more detail than <span class="code">util/0</span>.</p>
        <div class="note">
<div class="label">Note</div>
<div class="content"><p>
          <p>The returned value of the first call to <span class="code">util/0</span> or
            <span class="code">util/1</span> by a process will on most systems be the CPU
            utilization since system boot, but this is not guaranteed
            and the value should therefore be regarded as garbage. This
            also applies to the first call after a restart of
            <span class="code">cpu_sup</span>.</p>
        </p></div>
</div>
        <p>Currently recognized options:</p>
        <dl>
          <dt><strong><span class="code">detailed</span></strong></dt>
          <dd>
            <p>The returned <span class="code">UtilDesc</span>(s) will be even more
              detailed.</p>
          </dd>
          <dt><strong><span class="code">per_cpu</span></strong></dt>
          <dd>
            <p>Each CPU will be specified separately (assuming this
              information can be retrieved from the operating system),
              that is, a list with one <span class="code">UtilDesc</span> per CPU will be
              returned.</p>
          </dd>
        </dl>
        <p>Description of <span class="code">UtilDesc = {Cpus, Busy, NonBusy, Misc}</span>:</p>
        <dl>
          <dt><strong><span class="code">Cpus</span></strong></dt>
          <dd>
            <p>If the <span class="code">detailed</span> and/or <span class="code">per_cpu</span> option is
              given, this is the CPU number, or a list of the CPU
              numbers.</p>
            <p>If not, this is the atom <span class="code">all</span> which implies that
              the <span class="code">UtilDesc</span> contains information about all CPUs.</p>
          </dd>
          <dt><strong><span class="code">Busy</span></strong></dt>
          <dd>
            <p>If the <span class="code">detailed</span> option is given, this is a list
              of <span class="code">{State, Share}</span> tuples, where each tuple
              contains information about a processor state that has
              been identified as a busy processor state (see below).
              The atom <span class="code">State</span> is the name of the state, and
              the float <span class="code">Share</span> represents the percentage share of
              the CPU cycles spent in this state since the last call to
              <span class="code">util/0</span> or <span class="code">util/1</span>.</p>
            <p>If not, this is the sum of the percentage shares of
              the CPU cycles spent in all states identified as busy.</p>
            <p>If the <span class="code">per_cpu</span> is not given, the value(s)
              presented are the average of all CPUs.</p>
          </dd>
          <dt><strong><span class="code">NonBusy</span></strong></dt>
          <dd>
            <p>Similar to <span class="code">Busy</span>, but for processor states that
              have been identified as non-busy (see below).</p>
          </dd>
          <dt><strong><span class="code">Misc</span></strong></dt>
          <dd>
            <p>Currently unused; reserved for future use.</p>
          </dd>
        </dl>
        <p>Currently these processor states are identified as busy:</p>
        <dl>
          <dt><strong><span class="code">user</span></strong></dt>
          <dd>
            <p>Executing code in user mode.</p>
          </dd>
          <dt><strong><span class="code">nice_user</span></strong></dt>
          <dd>
            <p>Executing code in low priority (nice) user mode.
              This state is currently only identified on Linux.</p>
          </dd>
          <dt><strong><span class="code">kernel</span></strong></dt>
          <dd>
            <p>Executing code in kernel mode.</p>
          </dd>
        </dl>
        <p>Currently these processor states are identified as non-busy:</p>
        <dl>
          <dt><strong><span class="code">wait</span></strong></dt>
          <dd>
            <p>Waiting. This state is currently only identified on
              Solaris.</p>
          </dd>
          <dt><strong><span class="code">idle</span></strong></dt>
          <dd>
            <p>Idle.</p>
          </dd>
        </dl>
        <div class="note">
<div class="label">Note</div>
<div class="content"><p>
          <p>Identified processor states may be different on different
            operating systems and may change between different versions
            of <span class="code">cpu_sup</span> on the same operating system. The sum of
            the percentage shares of the CPU cycles spent in all busy
            and all non-busy processor states will always add up to
            100%, though.</p>
        </p></div>
</div>
        <p>Returns <span class="code">{all,0,0,[]}</span> if <span class="code">cpu_sup</span> is not
          available.</p>
      </p></div>
  

  <h3><a name="id63414">See Also</a></h3>
<div class="REFBODY">
    
    <p><span class="bold_code"><a href="os_mon_app.html">os_mon(3)</a></span></p>
  </div>
</div>
<div class="footer">
<hr>
<p>Copyright © 1997-2012 Ericsson AB. All Rights Reserved.</p>
</div>
</div>
</div></body>
</html>