Skip to content

Commit

Permalink
AIX support
Browse files Browse the repository at this point in the history
  • Loading branch information
Arnon Yaari committed Sep 5, 2017
1 parent 0abd8c6 commit 1e0aa8f
Show file tree
Hide file tree
Showing 14 changed files with 1,970 additions and 40 deletions.
70 changes: 40 additions & 30 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ Network
| ``"all"`` | the sum of all the possible families and protocols |
+----------------+-----------------------------------------------------+

On OSX this function requires root privileges.
On OSX and AIX this function requires root privileges.
To get per-process connections use :meth:`Process.connections`.
Also, see
`netstat.py sample script <https://github.com/giampaolo/psutil/blob/master/scripts/netstat.py>`__.
Expand All @@ -563,6 +563,10 @@ Network
(OSX) :class:`psutil.AccessDenied` is always raised unless running as root.
This is a limitation of the OS and ``lsof`` does the same.

.. note::
(AIX) :class:`psutil.AccessDenied` is always raised unless running as root
(lsof does the same).

.. note::
(Solaris) UNIX sockets are not supported.

Expand Down Expand Up @@ -1358,7 +1362,7 @@ Process class
>>> p.io_counters()
pio(read_count=454556, write_count=3456, read_bytes=110592, write_bytes=0, read_chars=769931, write_chars=203)

Availability: all platforms except OSX and Solaris
Availability: Linux, BSD, Windows, AIX

.. versionchanged:: 5.2.0 added *read_chars* and *write_chars* on Linux;
added *other_count* and *other_bytes* on Windows.
Expand All @@ -1368,6 +1372,8 @@ Process class
The number voluntary and involuntary context switches performed by
this process (cumulative).

Availability: all platforms except AIX

.. method:: num_fds()

The number of file descriptors currently opened by this process
Expand Down Expand Up @@ -1503,33 +1509,33 @@ Process class
The "portable" fields available on all plaforms are `rss` and `vms`.
All numbers are expressed in bytes.

+---------+---------+-------+---------+------------------------------+
| Linux | OSX | BSD | Solaris | Windows |
+=========+=========+=======+=========+==============================+
| rss | rss | rss | rss | rss (alias for ``wset``) |
+---------+---------+-------+---------+------------------------------+
| vms | vms | vms | vms | vms (alias for ``pagefile``) |
+---------+---------+-------+---------+------------------------------+
| shared | pfaults | text | | num_page_faults |
+---------+---------+-------+---------+------------------------------+
| text | pageins | data | | peak_wset |
+---------+---------+-------+---------+------------------------------+
| lib | | stack | | wset |
+---------+---------+-------+---------+------------------------------+
| data | | | | peak_paged_pool |
+---------+---------+-------+---------+------------------------------+
| dirty | | | | paged_pool |
+---------+---------+-------+---------+------------------------------+
| | | | | peak_nonpaged_pool |
+---------+---------+-------+---------+------------------------------+
| | | | | nonpaged_pool |
+---------+---------+-------+---------+------------------------------+
| | | | | pagefile |
+---------+---------+-------+---------+------------------------------+
| | | | | peak_pagefile |
+---------+---------+-------+---------+------------------------------+
| | | | | private |
+---------+---------+-------+---------+------------------------------+
+---------+---------+-------+---------+-----+------------------------------+
| Linux | OSX | BSD | Solaris | AIX | Windows |
+=========+=========+=======+=========+=====+==============================+
| rss | rss | rss | rss | rss | rss (alias for ``wset``) |
+---------+---------+-------+---------+-----+------------------------------+
| vms | vms | vms | vms | vms | vms (alias for ``pagefile``) |
+---------+---------+-------+---------+-----+------------------------------+
| shared | pfaults | text | | | num_page_faults |
+---------+---------+-------+---------+-----+------------------------------+
| text | pageins | data | | | peak_wset |
+---------+---------+-------+---------+-----+------------------------------+
| lib | | stack | | | wset |
+---------+---------+-------+---------+-----+------------------------------+
| data | | | | | peak_paged_pool |
+---------+---------+-------+---------+-----+------------------------------+
| dirty | | | | | paged_pool |
+---------+---------+-------+---------+-----+------------------------------+
| | | | | | peak_nonpaged_pool |
+---------+---------+-------+---------+-----+------------------------------+
| | | | | | nonpaged_pool |
+---------+---------+-------+---------+-----+------------------------------+
| | | | | | pagefile |
+---------+---------+-------+---------+-----+------------------------------+
| | | | | | peak_pagefile |
+---------+---------+-------+---------+-----+------------------------------+
| | | | | | private |
+---------+---------+-------+---------+-----+------------------------------+

- **rss**: aka "Resident Set Size", this is the non-swapped physical
memory a process has used.
Expand Down Expand Up @@ -1700,7 +1706,7 @@ Process class
pmmap_ext(addr='02829000-02ccf000', perms='rw-p', path='[heap]', rss=4743168, size=4874240, pss=4743168, shared_clean=0, shared_dirty=0, private_clean=0, private_dirty=4743168, referenced=4718592, anonymous=4743168, swap=0),
...]

Availability: All platforms except OpenBSD and NetBSD.
Availability: All platforms except OpenBSD, NetBSD and AIX.

.. method:: children(recursive=False)

Expand Down Expand Up @@ -1864,6 +1870,10 @@ Process class

.. versionchanged:: 5.3.0 : "laddr" and "raddr" are named tuples.

.. note::
(AIX) :class:`psutil.AccessDenied` is always raised unless running
as root (lsof does the same).

.. method:: is_running()

Return whether the current process is running in the current process list.
Expand Down
30 changes: 30 additions & 0 deletions psutil/TODO.aix
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
AIX support is experimental and incomplete at this time.
The following functions and methods are UNSUPPORTED on the AIX platform:

psutil.Process.memory_maps
psutil.Process.num_ctx_switches


Process.io_counters read count is always 0


TestSystemAPIs.test_pid_exists_2 there are pids in /proc that don't really exist
TestProcess.test_name isolated python calls execve which changes process name
TestProcess.test_num_fds opening a socket doesn't create fd in /proc/pid/fd (until data is sent??)
TestProcess.test_open_files /dev/null shows in open_files but it isn't a file
TestProcess.test_pid_0 pid 0 doesn't have a name on AIX
TestProcess.test_prog_w_funky_name funky name test doesn't work on UNIX environments
TestProcess.test_zombie_process trying to create a zombie process doesn't create a zombie process on AIX

TestProcess.test_memory_maps missing API
TestProcess.test_num_ctx_switches missing API
TestExampleScripts.test_pmap missing API

TestProcess.test_send_signal unknown
TestFetchAllProcesses.test_fetch_all unknown
TestProcess.test_Popen unknown (flaky)
TestProcess.test_children unknown (flaky)
TestProcess.test_children_recursive unknown (flaky)
TestProcess.test_connections unknown (flaky)
TestSystemAPIs.test_wait_procs_no_timeout unknown (flaky)
TestProcess.test_cmdline long args are cut from cmdline in /proc/pid/psinfo and getargs (flaky)
20 changes: 12 additions & 8 deletions psutil/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
from ._common import POSIX # NOQA
from ._common import SUNOS
from ._common import WINDOWS
from ._common import AIX

if LINUX:
# This is public API and it will be retrieved from _pslinux.py
Expand Down Expand Up @@ -158,6 +159,9 @@
# _pssunos.py via sys.modules.
PROCFS_PATH = "/proc"

elif AIX:
from . import _psaix as _psplatform

else: # pragma: no cover
raise NotImplementedError('platform %s is not supported' % sys.platform)

Expand Down Expand Up @@ -185,7 +189,7 @@
"POWER_TIME_UNKNOWN", "POWER_TIME_UNLIMITED",

"BSD", "FREEBSD", "LINUX", "NETBSD", "OPENBSD", "OSX", "POSIX", "SUNOS",
"WINDOWS",
"WINDOWS", "AIX",

# classes
"Process", "Popen",
Expand Down Expand Up @@ -785,7 +789,7 @@ def num_fds(self):
"""
return self._proc.num_fds()

# Linux, BSD and Windows only
# Linux, BSD, AIX and Windows only
if hasattr(_psplatform.Process, "io_counters"):

def io_counters(self):
Expand Down Expand Up @@ -890,11 +894,12 @@ def num_handles(self):
"""
return self._proc.num_handles()

def num_ctx_switches(self):
"""Return the number of voluntary and involuntary context
switches performed by this process.
"""
return self._proc.num_ctx_switches()
if not AIX:
def num_ctx_switches(self):
"""Return the number of voluntary and involuntary context
switches performed by this process.
"""
return self._proc.num_ctx_switches()

def num_threads(self):
"""Return the number of threads used by this process."""
Expand Down Expand Up @@ -1171,7 +1176,6 @@ def memory_percent(self, memtype="rss"):

if hasattr(_psplatform.Process, "memory_maps"):
# Available everywhere except OpenBSD and NetBSD.

def memory_maps(self, grouped=True):
"""Return process' mapped memory regions as a list of namedtuples
whose fields are variable depending on the platform.
Expand Down
1 change: 1 addition & 0 deletions psutil/_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
NETBSD = sys.platform.startswith("netbsd")
BSD = FREEBSD or OPENBSD or NETBSD
SUNOS = sys.platform.startswith("sunos") or sys.platform.startswith("solaris")
AIX = sys.platform.startswith("aix")


# ===================================================================
Expand Down
Loading

0 comments on commit 1e0aa8f

Please sign in to comment.