Skip to content

Commit

Permalink
update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
giampaolo committed Apr 11, 2019
1 parent 50defe1 commit 55f4b24
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
19 changes: 8 additions & 11 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -240,17 +240,14 @@ CPU

.. function:: getloadavg()

Returns the average load on the system over the last 1, 5 and 15 minutes
respectively as a tuple. The load represents how many processes are waiting
to be run by the operating system.

On UNIX systems this relies on `os.getloadavg`_. On Windows, this is
emulated by using a Windows API call that spawns a thread which updates the
average every 5 seconds mimicking the UNIX behavior. Thus, the first time
this is called and up until 5 seconds it returns a meaningless
``(0.0, 0.0, 0.0)`` tuple.

Example:
Return the average system load over the last 1, 5 and 15 minutes as a tuple.
The load represents how many processes are waiting to be run by the
operating system.
On UNIX systems this relies on `os.getloadavg`_. On Windows this is
emulated by using a Windows API that spawns a thread which updates the
average every 5 seconds, mimicking the UNIX behavior. Thus, the first time
this is called and for the next 5 seconds it will return a meaningless
``(0.0, 0.0, 0.0)`` tuple. Example:

.. code-block:: python
Expand Down
2 changes: 1 addition & 1 deletion psutil/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@
"pid_exists", "pids", "process_iter", "wait_procs", # proc
"virtual_memory", "swap_memory", # memory
"cpu_times", "cpu_percent", "cpu_times_percent", "cpu_count", # cpu
"cpu_stats", # "cpu_freq",
"cpu_stats", # "cpu_freq", "getloadavg"
"net_io_counters", "net_connections", "net_if_addrs", # network
"net_if_stats",
"disk_io_counters", "disk_partitions", "disk_usage", # disk
Expand Down
3 changes: 1 addition & 2 deletions scripts/top.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@

import atexit
import datetime
import os
import sys
import time
try:
Expand Down Expand Up @@ -151,7 +150,7 @@ def get_dashes(perc):
# load average, uptime
uptime = datetime.datetime.now() - \
datetime.datetime.fromtimestamp(psutil.boot_time())
av1, av2, av3 = os.getloadavg()
av1, av2, av3 = psutil.getloadavg()
line = " Load average: %.2f %.2f %.2f Uptime: %s" \
% (av1, av2, av3, str(uptime).split('.')[0])
print_line(line)
Expand Down

0 comments on commit 55f4b24

Please sign in to comment.