~rdoering/ubuntu/karmic/erlang/fix-535090

« back to all changes in this revision

Viewing changes to lib/os_mon/doc/src/cpu_sup.xml

  • Committer: Bazaar Package Importer
  • Author(s): Sergei Golovan
  • Date: 2009-02-15 16:42:52 UTC
  • mfrom: (1.1.13 upstream)
  • mto: (3.3.1 squeeze)
  • mto: This revision was merged to the branch mainline in revision 17.
  • Revision ID: james.westby@ubuntu.com-20090215164252-dxpjjuq108nz4noa
Upload to unstable after lenny is released.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="latin1" ?>
 
2
<!DOCTYPE erlref SYSTEM "erlref.dtd">
 
3
 
 
4
<erlref>
 
5
  <header>
 
6
    <copyright>
 
7
      <year>1997</year>
 
8
      <year>2007</year>
 
9
      <holder>Ericsson AB, All Rights Reserved</holder>
 
10
    </copyright>
 
11
    <legalnotice>
 
12
  The contents of this file are subject to the Erlang Public License,
 
13
  Version 1.1, (the "License"); you may not use this file except in
 
14
  compliance with the License. You should have received a copy of the
 
15
  Erlang Public License along with this software. If not, it can be
 
16
  retrieved online at http://www.erlang.org/.
 
17
 
 
18
  Software distributed under the License is distributed on an "AS IS"
 
19
  basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
 
20
  the License for the specific language governing rights and limitations
 
21
  under the License.
 
22
 
 
23
  The Initial Developer of the Original Code is Ericsson AB.
 
24
    </legalnotice>
 
25
 
 
26
    <title>cpu_sup</title>
 
27
    <prepared></prepared>
 
28
    <docno></docno>
 
29
    <date></date>
 
30
    <rev></rev>
 
31
  </header>
 
32
  <module>cpu_sup</module>
 
33
  <modulesummary>A CPU Load and CPU Utilization Supervisor Process</modulesummary>
 
34
  <description>
 
35
    <p><c>cpu_sup</c> is a process which supervises the CPU load
 
36
      and CPU utilization. It is part of the OS_Mon application, see
 
37
      <seealso marker="os_mon">os_mon(6)</seealso>. Available for Unix,
 
38
      although CPU utilization values (<c>util/0,1</c>) are only
 
39
      available for Solaris and Linux.</p>
 
40
    <p>The load values are proportional to how long time a runnable
 
41
      Unix process has to spend in the run queue before it is scheduled.
 
42
      Accordingly, higher values mean more system load. The returned
 
43
      value divided by 256 produces the figure displayed by <c>rup</c>
 
44
      and <c>top</c>. What is displayed as 2.00 in <c>rup</c>, is
 
45
      displayed as load up to the second mark in <c>xload</c>.</p>
 
46
    <p>For example, <c>rup</c> displays a load of 128 as 0.50, and
 
47
      512 as 2.00.</p>
 
48
    <p>If the user wants to view load values as percentage of machine
 
49
      capacity, then this way of measuring presents a problem, because
 
50
      the load values are not restricted to a fixed interval. In this
 
51
      case, the following simple mathematical transformation can
 
52
      produce the load value as a percentage:</p>
 
53
    <code type="none">
 
54
      PercentLoad = 100 * (1 - D/(D + Load))
 
55
    </code>
 
56
    <p><c>D</c> determines which load value should be associated with
 
57
      which percentage. Choosing <c>D</c> = 50 means that 128 is 60% 
 
58
      load, 256 is 80%, 512 is 90%, and so on.</p>
 
59
    <p>Another way of measuring system load is to divide the number of
 
60
      busy CPU cycles by the total number of CPU cycles. This produces 
 
61
      values in the 0-100 range immediately. However, this method hides 
 
62
      the fact that a machine can be more or less saturated. CPU
 
63
      utilization is therefore a better name than system load for this
 
64
      measure.</p>
 
65
    <p>A server which receives just enough requests to never become
 
66
      idle will score a CPU utilization of 100%. If the server receives
 
67
      50% more requests, it will still scores 100%. When the system load
 
68
      is calculated with the percentage formula shown previously,
 
69
      the load will increase from 80% to 87%.</p>
 
70
    <p>The <c>avg1/0</c>, <c>avg5/0</c>, and <c>avg15/0</c> functions
 
71
      can be used for retrieving system load values, and
 
72
      the <c>util/0</c> and <c>util/1</c> functions can be used for
 
73
      retrieving CPU utilization values.</p>
 
74
    <p>When run on Linux, <c>cpu_sup</c> assumes that the <c>/proc</c>
 
75
      file system is present and accessible by <c>cpu_sup</c>. If it is
 
76
      not, <c>cpu_sup</c> will terminate.</p>
 
77
  </description>
 
78
  <funcs>
 
79
    <func>
 
80
      <name>nprocs() -> UnixProcesses | {error, Reason}</name>
 
81
      <fsummary>Get the number of UNIX processes running on this host</fsummary>
 
82
      <type>
 
83
        <v>UnixProcesses = int()</v>
 
84
        <v>Reason = term()</v>
 
85
      </type>
 
86
      <desc>
 
87
        <p>Returns the number of UNIX processes running on this machine.
 
88
          This is a crude way of measuring the system load, but it may
 
89
          be of interest in some cases.</p>
 
90
        <p>Returns 0 if <c>cpu_sup</c> is not available.</p>
 
91
      </desc>
 
92
    </func>
 
93
    <func>
 
94
      <name>avg1() -> SystemLoad | {error, Reason}</name>
 
95
      <fsummary>Get the system load average for the last minute</fsummary>
 
96
      <type>
 
97
        <v>SystemLoad = int()</v>
 
98
        <v>Reason = term()</v>
 
99
      </type>
 
100
      <desc>
 
101
        <p>Returns the average system load in the last minute, as
 
102
          described above. 0 represents no load, 256 represents the load
 
103
          reported as 1.00 by <c>rup</c>.</p>
 
104
        <p>Returns 0 if <c>cpu_sup</c> is not available.</p>
 
105
      </desc>
 
106
    </func>
 
107
    <func>
 
108
      <name>avg5() -> SystemLoad | {error, Reason}</name>
 
109
      <fsummary>Get the system load average for the last five minutes</fsummary>
 
110
      <type>
 
111
        <v>SystemLoad = int()</v>
 
112
        <v>Reason = term()</v>
 
113
      </type>
 
114
      <desc>
 
115
        <p>Returns the average system load in the last five minutes, as
 
116
          described above. 0 represents no load, 256 represents the load
 
117
          reported as 1.00 by <c>rup</c>.</p>
 
118
        <p>Returns 0 if <c>cpu_sup</c> is not available.</p>
 
119
      </desc>
 
120
    </func>
 
121
    <func>
 
122
      <name>avg15() -> SystemLoad | {error, Reason}</name>
 
123
      <fsummary>Get the system load average for the last fifteen minutes</fsummary>
 
124
      <type>
 
125
        <v>SystemLoad = int()</v>
 
126
        <v>Reason = term()</v>
 
127
      </type>
 
128
      <desc>
 
129
        <p>Returns the average system load in the last 15 minutes, as
 
130
          described above. 0 represents no load, 256 represents the load
 
131
          reported as 1.00 by <c>rup</c>.</p>
 
132
        <p>Returns 0 if <c>cpu_sup</c> is not available.</p>
 
133
      </desc>
 
134
    </func>
 
135
    <func>
 
136
      <name>util() -> CpuUtil | {error, Reason}</name>
 
137
      <fsummary>Get the CPU utilization</fsummary>
 
138
      <type>
 
139
        <v>CpuUtil = float()</v>
 
140
        <v>Reason = term()</v>
 
141
      </type>
 
142
      <desc>
 
143
        <p>Returns CPU utilization since the last call to
 
144
          <c>util/0</c> or <c>util/1</c> by the calling process.</p>
 
145
        <note>
 
146
          <p>The returned value of the first call to <c>util/0</c> or
 
147
            <c>util/1</c> by a process will on most systems be the CPU
 
148
            utilization since system boot, but this is not guaranteed
 
149
            and the value should therefore be regarded as garbage. This
 
150
            also applies to the first call after a restart of
 
151
            <c>cpu_sup</c>.</p>
 
152
        </note>
 
153
        <p>The CPU utilization is defined as the sum of the percentage
 
154
          shares of the CPU cycles spent in all busy processor states
 
155
          (see <c>util/1</c> below) in average on all CPUs.</p>
 
156
        <p>Returns 0 if <c>cpu_sup</c> is not available.</p>
 
157
      </desc>
 
158
    </func>
 
159
    <func>
 
160
      <name>util(Opts) -> UtilSpec | {error, Reason}</name>
 
161
      <fsummary>Get the CPU utilization</fsummary>
 
162
      <type>
 
163
        <v>Opts = [detailed | per_cpu]</v>
 
164
        <v>UtilSpec = UtilDesc | [UtilDesc]</v>
 
165
        <v>&nbsp;UtilDesc = {Cpus, Busy, NonBusy, Misc}</v>
 
166
        <v>&nbsp;&nbsp;Cpus = all | int() | [int()]()</v>
 
167
        <v>&nbsp;&nbsp;Busy = NonBusy = {State, Share} | Share</v>
 
168
        <v>&nbsp;&nbsp;&nbsp;State = user | nice_user | kernel</v>
 
169
        <v>&nbsp;&nbsp;&nbsp;&nbsp;| wait | idle | atom()</v>
 
170
        <v>&nbsp;&nbsp;&nbsp;Share = float()</v>
 
171
        <v>&nbsp;&nbsp;Misc = []</v>
 
172
        <v>Reason = term()</v>
 
173
      </type>
 
174
      <desc>
 
175
        <p>Returns CPU utilization since the last call to
 
176
          <c>util/0</c> or <c>util/1</c> by the calling process, in
 
177
          more detail than <c>util/0</c>.</p>
 
178
        <note>
 
179
          <p>The returned value of the first call to <c>util/0</c> or
 
180
            <c>util/1</c> by a process will on most systems be the CPU
 
181
            utilization since system boot, but this is not guaranteed
 
182
            and the value should therefore be regarded as garbage. This
 
183
            also applies to the first call after a restart of
 
184
            <c>cpu_sup</c>.</p>
 
185
        </note>
 
186
        <p>Currently recognized options:</p>
 
187
        <taglist>
 
188
          <tag><c>detailed</c></tag>
 
189
          <item>
 
190
            <p>The returned <c>UtilDesc</c>(s) will be even more
 
191
              detailed.</p>
 
192
          </item>
 
193
          <tag><c>per_cpu</c></tag>
 
194
          <item>
 
195
            <p>Each CPU will be specified separately (assuming this
 
196
              information can be retrieved from the operating system),
 
197
              that is, a list with one <c>UtilDesc</c> per CPU will be
 
198
              returned.</p>
 
199
          </item>
 
200
        </taglist>
 
201
        <p>Description of <c>UtilDesc = {Cpus, Busy, NonBusy, Misc}</c>:</p>
 
202
        <taglist>
 
203
          <tag><c>Cpus</c></tag>
 
204
          <item>
 
205
            <p>If the <c>detailed</c> and/or <c>per_cpu</c> option is
 
206
              given, this is the CPU number, or a list of the CPU
 
207
              numbers.</p>
 
208
            <p>If not, this is the atom <c>all</c> which implies that
 
209
              the <c>UtilDesc</c> contains information about all CPUs.</p>
 
210
          </item>
 
211
          <tag><c>Busy</c></tag>
 
212
          <item>
 
213
            <p>If the <c>detailed</c> option is given, this is a list
 
214
              of <c>{State, Share}</c> tuples, where each tuple
 
215
              contains information about a processor state that has
 
216
              been identified as a busy processor state (see below).
 
217
              The atom <c>State</c> is the name of the state, and
 
218
              the float <c>Share</c> represents the percentage share of
 
219
              the CPU cycles spent in this state since the last call to
 
220
              <c>util/0</c> or <c>util/1</c>.</p>
 
221
            <p>If not, this is the sum of the percentage shares of
 
222
              the CPU cycles spent in all states identified as busy.</p>
 
223
            <p>If the <c>per_cpu</c> is not given, the value(s)
 
224
              presented are the average of all CPUs.</p>
 
225
          </item>
 
226
          <tag><c>NonBusy</c></tag>
 
227
          <item>
 
228
            <p>Similar to <c>Busy</c>, but for processor states that
 
229
              have been identified as non-busy (see below).</p>
 
230
          </item>
 
231
          <tag><c>Misc</c></tag>
 
232
          <item>
 
233
            <p>Currently unused; reserved for future use.</p>
 
234
          </item>
 
235
        </taglist>
 
236
        <p>Currently these processor states are identified as busy:</p>
 
237
        <taglist>
 
238
          <tag><c>user</c></tag>
 
239
          <item>
 
240
            <p>Executing code in user mode.</p>
 
241
          </item>
 
242
          <tag><c>nice_user</c></tag>
 
243
          <item>
 
244
            <p>Executing code in low priority (nice) user mode.
 
245
              This state is currently only identified on Linux.</p>
 
246
          </item>
 
247
          <tag><c>kernel</c></tag>
 
248
          <item>
 
249
            <p>Executing code in kernel mode.</p>
 
250
          </item>
 
251
        </taglist>
 
252
        <p>Currently these processor states are identified as non-busy:</p>
 
253
        <taglist>
 
254
          <tag><c>wait</c></tag>
 
255
          <item>
 
256
            <p>Waiting. This state is currently only identified on
 
257
              Solaris.</p>
 
258
          </item>
 
259
          <tag><c>idle</c></tag>
 
260
          <item>
 
261
            <p>Idle.</p>
 
262
          </item>
 
263
        </taglist>
 
264
        <note>
 
265
          <p>Identified processor states may be different on different
 
266
            operating systems and may change between different versions
 
267
            of <c>cpu_sup</c> on the same operating system. The sum of
 
268
            the percentage shares of the CPU cycles spent in all busy
 
269
            and all non-busy processor states will always add up to
 
270
            100%, though.</p>
 
271
        </note>
 
272
        <p>Returns <c>{all,0,0,[]}</c> if <c>cpu_sup</c> is not
 
273
          available.</p>
 
274
      </desc>
 
275
    </func>
 
276
  </funcs>
 
277
 
 
278
  <section>
 
279
    <title>See Also</title>
 
280
    <p><seealso marker="os_mon">os_mon(3)</seealso></p>
 
281
  </section>
 
282
</erlref>
 
283