Import of pkgsrc-2014Q1
This commit is contained in:
6
sysutils/py-psutil/DESCR
Normal file
6
sysutils/py-psutil/DESCR
Normal file
@@ -0,0 +1,6 @@
|
||||
util is a module providing an interface for retrieving information,
|
||||
on all running processes and system utilization (CPU, memory, disks,
|
||||
network, users) in a portable way by using Python, implementing
|
||||
many functionalities offered by command line tools such as ps, top,
|
||||
df, netstat, who, kill, uptime, free, lsof, ifconfig, nice, ionice,
|
||||
iostat, iotop, pidof, tty, taskset, or pmap.
|
||||
25
sysutils/py-psutil/Makefile
Normal file
25
sysutils/py-psutil/Makefile
Normal file
@@ -0,0 +1,25 @@
|
||||
# $NetBSD: Makefile,v 1.4 2014/01/25 10:30:22 wiz Exp $
|
||||
|
||||
DISTNAME= psutil-1.2.1
|
||||
PKGNAME= ${PYPKGPREFIX}-${DISTNAME}
|
||||
CATEGORIES= sysutils
|
||||
MASTER_SITES= https://pypi.python.org/packages/source/p/psutil/
|
||||
|
||||
MAINTAINER= pkgsrc-users@NetBSD.org
|
||||
HOMEPAGE= http://code.google.com/p/psutil/
|
||||
COMMENT= Cross-platform process and system utilities module for Python
|
||||
LICENSE= modified-bsd
|
||||
|
||||
REPLACE_PYTHON= psutil/*py
|
||||
PYTHON_VERSIONS_INCOMPATIBLE= 33 # not yet ported as of 1.2.1
|
||||
|
||||
.include "../../mk/bsd.prefs.mk"
|
||||
|
||||
# facilitate PLIST processing
|
||||
.if ${OPSYS} == "SunOS"
|
||||
LOWER_OPSYS= ${OPSYS:tl}
|
||||
.endif
|
||||
|
||||
.include "../../lang/python/application.mk"
|
||||
.include "../../lang/python/egg.mk"
|
||||
.include "../../mk/bsd.pkg.mk"
|
||||
43
sysutils/py-psutil/PLIST
Normal file
43
sysutils/py-psutil/PLIST
Normal file
@@ -0,0 +1,43 @@
|
||||
@comment $NetBSD: PLIST,v 1.2 2013/12/07 21:25:23 richard Exp $
|
||||
${PYSITELIB}/_psutil_${LOWER_OPSYS}.so
|
||||
${PYSITELIB}/_psutil_posix.so
|
||||
${PYSITELIB}/${EGG_INFODIR}/PKG-INFO
|
||||
${PYSITELIB}/${EGG_INFODIR}/SOURCES.txt
|
||||
${PYSITELIB}/${EGG_INFODIR}/dependency_links.txt
|
||||
${PYSITELIB}/${EGG_INFODIR}/top_level.txt
|
||||
${PYSITELIB}/psutil/__init__.py
|
||||
${PYSITELIB}/psutil/__init__.pyc
|
||||
${PYSITELIB}/psutil/__init__.pyo
|
||||
${PYSITELIB}/psutil/_common.py
|
||||
${PYSITELIB}/psutil/_common.pyc
|
||||
${PYSITELIB}/psutil/_common.pyo
|
||||
${PYSITELIB}/psutil/_compat.py
|
||||
${PYSITELIB}/psutil/_compat.pyc
|
||||
${PYSITELIB}/psutil/_compat.pyo
|
||||
${PYSITELIB}/psutil/_error.py
|
||||
${PYSITELIB}/psutil/_error.pyc
|
||||
${PYSITELIB}/psutil/_error.pyo
|
||||
${PYSITELIB}/psutil/_psbsd.py
|
||||
${PYSITELIB}/psutil/_psbsd.pyc
|
||||
${PYSITELIB}/psutil/_psbsd.pyo
|
||||
${PYSITELIB}/psutil/_pslinux.py
|
||||
${PYSITELIB}/psutil/_pslinux.pyc
|
||||
${PYSITELIB}/psutil/_pslinux.pyo
|
||||
${PYSITELIB}/psutil/_psmswindows.py
|
||||
${PYSITELIB}/psutil/_psmswindows.pyc
|
||||
${PYSITELIB}/psutil/_psmswindows.pyo
|
||||
${PYSITELIB}/psutil/_psnetbsd.py
|
||||
${PYSITELIB}/psutil/_psnetbsd.pyc
|
||||
${PYSITELIB}/psutil/_psnetbsd.pyo
|
||||
${PYSITELIB}/psutil/_psosx.py
|
||||
${PYSITELIB}/psutil/_psosx.pyc
|
||||
${PYSITELIB}/psutil/_psosx.pyo
|
||||
${PYSITELIB}/psutil/_psposix.py
|
||||
${PYSITELIB}/psutil/_psposix.pyc
|
||||
${PYSITELIB}/psutil/_psposix.pyo
|
||||
${PYSITELIB}/psutil/_pssunos.py
|
||||
${PYSITELIB}/psutil/_pssunos.pyc
|
||||
${PYSITELIB}/psutil/_pssunos.pyo
|
||||
${PYSITELIB}/psutil/error.py
|
||||
${PYSITELIB}/psutil/error.pyc
|
||||
${PYSITELIB}/psutil/error.pyo
|
||||
14
sysutils/py-psutil/distinfo
Normal file
14
sysutils/py-psutil/distinfo
Normal file
@@ -0,0 +1,14 @@
|
||||
$NetBSD: distinfo,v 1.3 2013/12/07 21:25:23 richard Exp $
|
||||
|
||||
SHA1 (psutil-1.2.1.tar.gz) = c8c1842bf1c63b9068ac25a37f7aae11fcecd57f
|
||||
RMD160 (psutil-1.2.1.tar.gz) = 5b014f73dce4035527886637ebd1b653e5a7faba
|
||||
Size (psutil-1.2.1.tar.gz) = 167397 bytes
|
||||
SHA1 (patch-psutil_____init____.py) = aa75a84992250e28db01d5fe13a68ed0cdcea883
|
||||
SHA1 (patch-psutil___psnetbsd.py) = 20089b57640a5eb30aeb1f5460624a570f1d3236
|
||||
SHA1 (patch-psutil___psutil__netbsd.c) = c251e097ce5c919537176f16406ad6892db955fc
|
||||
SHA1 (patch-psutil___psutil__netbsd.h) = 33e3c857f764d8391db747068ade7ea333698ec0
|
||||
SHA1 (patch-psutil___psutil__sunos.c) = 78bdb8103a10022785202873c7e60886a885340f
|
||||
SHA1 (patch-psutil_arch_netbsd_process__info.c) = c384d12cc47514d6396d779d59c586ef2b42a89a
|
||||
SHA1 (patch-psutil_arch_netbsd_process__info.h) = b23075df15749e4e5274ccb9e21d67ac55fdd199
|
||||
SHA1 (patch-setup.py) = 3e87561b6dfd7e851e232342dab3b2e8ade28cfd
|
||||
SHA1 (patch-test_test__psutil.py) = fa3ba09430f8ad307cf6674dee3e7cbfa9144e3b
|
||||
16
sysutils/py-psutil/patches/patch-psutil_____init____.py
Normal file
16
sysutils/py-psutil/patches/patch-psutil_____init____.py
Normal file
@@ -0,0 +1,16 @@
|
||||
$NetBSD: patch-psutil_____init____.py,v 1.1 2013/10/12 13:32:36 wiz Exp $
|
||||
|
||||
Port to NetBSD.
|
||||
|
||||
--- psutil/__init__.py.orig 2013-07-12 15:34:08.000000000 +0000
|
||||
+++ psutil/__init__.py
|
||||
@@ -97,6 +97,9 @@ elif sys.platform.startswith("darwin"):
|
||||
elif sys.platform.startswith("freebsd"):
|
||||
import psutil._psbsd as _psplatform
|
||||
|
||||
+elif sys.platform.startswith("netbsd"):
|
||||
+ import psutil._psnetbsd as _psplatform
|
||||
+
|
||||
elif sys.platform.startswith("sunos"):
|
||||
import psutil._pssunos as _psplatform
|
||||
from psutil._pssunos import (CONN_IDLE,
|
||||
374
sysutils/py-psutil/patches/patch-psutil___psnetbsd.py
Normal file
374
sysutils/py-psutil/patches/patch-psutil___psnetbsd.py
Normal file
@@ -0,0 +1,374 @@
|
||||
$NetBSD: patch-psutil___psnetbsd.py,v 1.1 2013/10/12 13:32:36 wiz Exp $
|
||||
|
||||
Port to NetBSD.
|
||||
|
||||
--- psutil/_psnetbsd.py.orig 2013-10-12 13:19:29.000000000 +0000
|
||||
+++ psutil/_psnetbsd.py
|
||||
@@ -0,0 +1,367 @@
|
||||
+#!/usr/bin/env python
|
||||
+
|
||||
+# Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.
|
||||
+# Use of this source code is governed by a BSD-style license that can be
|
||||
+# found in the LICENSE file.
|
||||
+
|
||||
+"""NetBSD platform implementation."""
|
||||
+
|
||||
+import errno
|
||||
+import os
|
||||
+import sys
|
||||
+import warnings
|
||||
+
|
||||
+import _psutil_netbsd
|
||||
+import _psutil_posix
|
||||
+from psutil import _psposix
|
||||
+from psutil._error import AccessDenied, NoSuchProcess, TimeoutExpired
|
||||
+from psutil._compat import namedtuple, wraps
|
||||
+from psutil._common import *
|
||||
+
|
||||
+__extra__all__ = []
|
||||
+
|
||||
+# --- constants
|
||||
+
|
||||
+# Since these constants get determined at import time we do not want to
|
||||
+# crash immediately; instead we'll set them to None and most likely
|
||||
+# we'll crash later as they're used for determining process CPU stats
|
||||
+# and creation_time
|
||||
+try:
|
||||
+ NUM_CPUS = _psutil_netbsd.get_num_cpus()
|
||||
+except Exception:
|
||||
+ NUM_CPUS = None
|
||||
+ warnings.warn("couldn't determine platform's NUM_CPUS", RuntimeWarning)
|
||||
+try:
|
||||
+ TOTAL_PHYMEM = _psutil_netbsd.get_virtual_mem()[0]
|
||||
+except Exception:
|
||||
+ TOTAL_PHYMEM = None
|
||||
+ warnings.warn("couldn't determine platform's TOTAL_PHYMEM", RuntimeWarning)
|
||||
+try:
|
||||
+ BOOT_TIME = _psutil_netbsd.get_system_boot_time()
|
||||
+except Exception:
|
||||
+ BOOT_TIME = None
|
||||
+ warnings.warn("couldn't determine platform's BOOT_TIME", RuntimeWarning)
|
||||
+
|
||||
+
|
||||
+_PAGESIZE = os.sysconf("SC_PAGE_SIZE")
|
||||
+_cputimes_ntuple = namedtuple('cputimes', 'user nice system idle irq')
|
||||
+
|
||||
+# --- public functions
|
||||
+
|
||||
+get_system_boot_time = _psutil_netbsd.get_system_boot_time
|
||||
+
|
||||
+nt_virtmem_info = namedtuple('vmem', ' '.join([
|
||||
+ # all platforms
|
||||
+ 'total', 'available', 'percent', 'used', 'free',
|
||||
+ # *BSD specific
|
||||
+ 'active',
|
||||
+ 'inactive',
|
||||
+ 'shared',
|
||||
+ 'wired']))
|
||||
+
|
||||
+def virtual_memory():
|
||||
+ """System virtual memory as a namedutple."""
|
||||
+ mem = _psutil_netbsd.get_virtual_mem()
|
||||
+ total, free, active, inactive, wired, shared = mem
|
||||
+ avail = inactive + free
|
||||
+ used = active + wired
|
||||
+ percent = usage_percent((total - avail), total, _round=1)
|
||||
+ return nt_virtmem_info(total, avail, percent, used, free,
|
||||
+ active, inactive, shared, wired)
|
||||
+
|
||||
+def swap_memory():
|
||||
+ """System swap memory as (total, used, free, sin, sout) namedtuple."""
|
||||
+ total, used, free, sin, sout = \
|
||||
+ [x * _PAGESIZE for x in _psutil_netbsd.get_swap_mem()]
|
||||
+ percent = usage_percent(used, total, _round=1)
|
||||
+ return nt_swapmeminfo(total, used, free, percent, sin, sout)
|
||||
+
|
||||
+def get_system_cpu_times():
|
||||
+ """Return system per-CPU times as a named tuple"""
|
||||
+ user, nice, system, idle, irq = _psutil_netbsd.get_system_cpu_times()
|
||||
+ return _cputimes_ntuple(user, nice, system, idle, irq)
|
||||
+
|
||||
+def get_system_per_cpu_times():
|
||||
+ """Return system CPU times as a named tuple"""
|
||||
+ ret = []
|
||||
+ for cpu_t in _psutil_netbsd.get_system_per_cpu_times():
|
||||
+ user, nice, system, idle, irq = cpu_t
|
||||
+ item = _cputimes_ntuple(user, nice, system, idle, irq)
|
||||
+ ret.append(item)
|
||||
+ return ret
|
||||
+
|
||||
+# \todo: check this
|
||||
+# XXX
|
||||
+# Ok, this is very dirty.
|
||||
+# On FreeBSD < 8 we cannot gather per-cpu information, see:
|
||||
+# http://code.google.com/p/psutil/issues/detail?id=226
|
||||
+# If NUM_CPUS > 1, on first call we return single cpu times to avoid a
|
||||
+# crash at psutil import time.
|
||||
+# Next calls will fail with NotImplementedError
|
||||
+if not hasattr(_psutil_netbsd, "get_system_per_cpu_times"):
|
||||
+ def get_system_per_cpu_times():
|
||||
+ if NUM_CPUS == 1:
|
||||
+ return [get_system_cpu_times]
|
||||
+ if get_system_per_cpu_times.__called__:
|
||||
+ raise NotImplementedError("supported only starting from FreeBSD 8")
|
||||
+ get_system_per_cpu_times.__called__ = True
|
||||
+ return [get_system_cpu_times]
|
||||
+get_system_per_cpu_times.__called__ = False
|
||||
+
|
||||
+def disk_partitions(all=False):
|
||||
+ retlist = []
|
||||
+ partitions = _psutil_netbsd.get_disk_partitions()
|
||||
+ for partition in partitions:
|
||||
+ device, mountpoint, fstype, opts = partition
|
||||
+ if device == 'none':
|
||||
+ device = ''
|
||||
+ if not all:
|
||||
+ if not os.path.isabs(device) \
|
||||
+ or not os.path.exists(device):
|
||||
+ continue
|
||||
+ ntuple = nt_partition(device, mountpoint, fstype, opts)
|
||||
+ retlist.append(ntuple)
|
||||
+ return retlist
|
||||
+
|
||||
+def get_system_users():
|
||||
+ retlist = []
|
||||
+ rawlist = _psutil_netbsd.get_system_users()
|
||||
+ for item in rawlist:
|
||||
+ user, tty, hostname, tstamp = item
|
||||
+ if tty == '~':
|
||||
+ continue # reboot or shutdown
|
||||
+ nt = nt_user(user, tty or None, hostname, tstamp)
|
||||
+ retlist.append(nt)
|
||||
+ return retlist
|
||||
+
|
||||
+get_pid_list = _psutil_netbsd.get_pid_list
|
||||
+pid_exists = _psposix.pid_exists
|
||||
+get_disk_usage = _psposix.get_disk_usage
|
||||
+net_io_counters = _psutil_netbsd.get_net_io_counters
|
||||
+disk_io_counters = _psutil_netbsd.get_disk_io_counters
|
||||
+
|
||||
+
|
||||
+def wrap_exceptions(fun):
|
||||
+ """Decorator which translates bare OSError exceptions into
|
||||
+ NoSuchProcess and AccessDenied.
|
||||
+ """
|
||||
+ @wraps(fun)
|
||||
+ def wrapper(self, *args, **kwargs):
|
||||
+ try:
|
||||
+ return fun(self, *args, **kwargs)
|
||||
+ except OSError:
|
||||
+ err = sys.exc_info()[1]
|
||||
+ if err.errno == errno.ESRCH:
|
||||
+ raise NoSuchProcess(self.pid, self._process_name)
|
||||
+ if err.errno in (errno.EPERM, errno.EACCES):
|
||||
+ raise AccessDenied(self.pid, self._process_name)
|
||||
+ raise
|
||||
+ return wrapper
|
||||
+
|
||||
+_status_map = {
|
||||
+ _psutil_netbsd.SSTOP : STATUS_STOPPED,
|
||||
+ _psutil_netbsd.SIDL : STATUS_IDLE,
|
||||
+ _psutil_netbsd.SACTIVE : STATUS_RUNNING,
|
||||
+# \todo: to what to map this?
|
||||
+# _psutil_netbsd.SDYING : STATUS_IDLE,
|
||||
+ _psutil_netbsd.SDEAD : STATUS_DEAD,
|
||||
+ _psutil_netbsd.SZOMB : STATUS_ZOMBIE,
|
||||
+}
|
||||
+
|
||||
+_conn_status_map = {_psutil_netbsd.TCPS_ESTABLISHED : CONN_ESTABLISHED,
|
||||
+ _psutil_netbsd.TCPS_SYN_SENT : CONN_SYN_SENT,
|
||||
+ _psutil_netbsd.TCPS_SYN_RECEIVED : CONN_SYN_RECV,
|
||||
+ _psutil_netbsd.TCPS_FIN_WAIT_1 : CONN_FIN_WAIT1,
|
||||
+ _psutil_netbsd.TCPS_FIN_WAIT_2 : CONN_FIN_WAIT2,
|
||||
+ _psutil_netbsd.TCPS_TIME_WAIT : CONN_TIME_WAIT,
|
||||
+ _psutil_netbsd.TCPS_CLOSED : CONN_CLOSE,
|
||||
+ _psutil_netbsd.TCPS_CLOSE_WAIT : CONN_CLOSE_WAIT,
|
||||
+ _psutil_netbsd.TCPS_LAST_ACK : CONN_LAST_ACK,
|
||||
+ _psutil_netbsd.TCPS_LISTEN : CONN_LISTEN,
|
||||
+ _psutil_netbsd.TCPS_CLOSING : CONN_CLOSING,
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+class Process(object):
|
||||
+ """Wrapper class around underlying C implementation."""
|
||||
+
|
||||
+ __slots__ = ["pid", "_process_name"]
|
||||
+
|
||||
+ def __init__(self, pid):
|
||||
+ self.pid = pid
|
||||
+ self._process_name = None
|
||||
+
|
||||
+ @wrap_exceptions
|
||||
+ def get_process_name(self):
|
||||
+ """Return process name as a string of limited len (15)."""
|
||||
+ return _psutil_netbsd.get_process_name(self.pid)
|
||||
+
|
||||
+ @wrap_exceptions
|
||||
+ def get_process_exe(self):
|
||||
+ """Return process executable pathname."""
|
||||
+ return _psutil_netbsd.get_process_exe(self.pid)
|
||||
+
|
||||
+ @wrap_exceptions
|
||||
+ def get_process_cmdline(self):
|
||||
+ """Return process cmdline as a list of arguments."""
|
||||
+ return _psutil_netbsd.get_process_cmdline(self.pid)
|
||||
+
|
||||
+ @wrap_exceptions
|
||||
+ def get_process_terminal(self):
|
||||
+ tty_nr = _psutil_netbsd.get_process_tty_nr(self.pid)
|
||||
+ tmap = _psposix._get_terminal_map()
|
||||
+ try:
|
||||
+ return tmap[tty_nr]
|
||||
+ except KeyError:
|
||||
+ return None
|
||||
+
|
||||
+ @wrap_exceptions
|
||||
+ def get_process_ppid(self):
|
||||
+ """Return process parent pid."""
|
||||
+ return _psutil_netbsd.get_process_ppid(self.pid)
|
||||
+
|
||||
+ # XXX - available on FreeBSD >= 8 only
|
||||
+ if hasattr(_psutil_netbsd, "get_process_cwd"):
|
||||
+ @wrap_exceptions
|
||||
+ def get_process_cwd(self):
|
||||
+ """Return process current working directory."""
|
||||
+ # sometimes we get an empty string, in which case we turn
|
||||
+ # it into None
|
||||
+ return _psutil_netbsd.get_process_cwd(self.pid) or None
|
||||
+
|
||||
+ @wrap_exceptions
|
||||
+ def get_process_uids(self):
|
||||
+ """Return real, effective and saved user ids."""
|
||||
+ real, effective, saved = _psutil_netbsd.get_process_uids(self.pid)
|
||||
+ return nt_uids(real, effective, saved)
|
||||
+
|
||||
+ @wrap_exceptions
|
||||
+ def get_process_gids(self):
|
||||
+ """Return real, effective and saved group ids."""
|
||||
+ real, effective, saved = _psutil_netbsd.get_process_gids(self.pid)
|
||||
+ return nt_gids(real, effective, saved)
|
||||
+
|
||||
+ @wrap_exceptions
|
||||
+ def get_cpu_times(self):
|
||||
+ """return a tuple containing process user/kernel time."""
|
||||
+ user, system = _psutil_netbsd.get_process_cpu_times(self.pid)
|
||||
+ return nt_cputimes(user, system)
|
||||
+
|
||||
+ @wrap_exceptions
|
||||
+ def get_memory_info(self):
|
||||
+ """Return a tuple with the process' RSS and VMS size."""
|
||||
+ rss, vms = _psutil_netbsd.get_process_memory_info(self.pid)[:2]
|
||||
+ return nt_meminfo(rss, vms)
|
||||
+
|
||||
+ _nt_ext_mem = namedtuple('meminfo', 'rss vms text data stack')
|
||||
+
|
||||
+ @wrap_exceptions
|
||||
+ def get_ext_memory_info(self):
|
||||
+ return self._nt_ext_mem(*_psutil_netbsd.get_process_memory_info(self.pid))
|
||||
+
|
||||
+ @wrap_exceptions
|
||||
+ def get_process_create_time(self):
|
||||
+ """Return the start time of the process as a number of seconds since
|
||||
+ the epoch."""
|
||||
+ return _psutil_netbsd.get_process_create_time(self.pid)
|
||||
+
|
||||
+ @wrap_exceptions
|
||||
+ def get_process_num_threads(self):
|
||||
+ """Return the number of threads belonging to the process."""
|
||||
+ return _psutil_netbsd.get_process_num_threads(self.pid)
|
||||
+
|
||||
+ @wrap_exceptions
|
||||
+ def get_num_ctx_switches(self):
|
||||
+ return nt_ctxsw(*_psutil_netbsd.get_process_num_ctx_switches(self.pid))
|
||||
+
|
||||
+ @wrap_exceptions
|
||||
+ def get_num_fds(self):
|
||||
+ """Return the number of file descriptors opened by this process."""
|
||||
+ return _psutil_netbsd.get_process_num_fds(self.pid)
|
||||
+
|
||||
+ @wrap_exceptions
|
||||
+ def get_process_threads(self):
|
||||
+ """Return the number of threads belonging to the process."""
|
||||
+ rawlist = _psutil_netbsd.get_process_threads(self.pid)
|
||||
+ retlist = []
|
||||
+ for thread_id, utime, stime in rawlist:
|
||||
+ ntuple = nt_thread(thread_id, utime, stime)
|
||||
+ retlist.append(ntuple)
|
||||
+ return retlist
|
||||
+
|
||||
+ @wrap_exceptions
|
||||
+ def get_open_files(self):
|
||||
+ """Return files opened by process as a list of namedtuples."""
|
||||
+ # XXX - C implementation available on FreeBSD >= 8 only
|
||||
+ # else fallback on lsof parser
|
||||
+ if hasattr(_psutil_netbsd, "get_process_open_files"):
|
||||
+ rawlist = _psutil_netbsd.get_process_open_files(self.pid)
|
||||
+ return [nt_openfile(path, fd) for path, fd in rawlist]
|
||||
+ else:
|
||||
+ lsof = _psposix.LsofParser(self.pid, self._process_name)
|
||||
+ return lsof.get_process_open_files()
|
||||
+
|
||||
+ @wrap_exceptions
|
||||
+ def get_connections(self, kind='inet'):
|
||||
+ """Return etwork connections opened by a process as a list of
|
||||
+ namedtuples.
|
||||
+ """
|
||||
+ if kind not in conn_tmap:
|
||||
+ raise ValueError("invalid %r kind argument; choose between %s"
|
||||
+ % (kind, ', '.join([repr(x) for x in conn_tmap])))
|
||||
+ families, types = conn_tmap[kind]
|
||||
+ rawlist = _psutil_netbsd.get_process_connections(self.pid, families,
|
||||
+ types)
|
||||
+ ret = []
|
||||
+ for item in rawlist:
|
||||
+ fd, fam, type, laddr, raddr, status = item
|
||||
+ status = _conn_status_map[status]
|
||||
+ nt = nt_connection(fd, fam, type, laddr, raddr, status)
|
||||
+ ret.append(nt)
|
||||
+ return ret
|
||||
+
|
||||
+ @wrap_exceptions
|
||||
+ def process_wait(self, timeout=None):
|
||||
+ try:
|
||||
+ return _psposix.wait_pid(self.pid, timeout)
|
||||
+ except TimeoutExpired:
|
||||
+ raise TimeoutExpired(self.pid, self._process_name)
|
||||
+
|
||||
+ @wrap_exceptions
|
||||
+ def get_process_nice(self):
|
||||
+ return _psutil_posix.getpriority(self.pid)
|
||||
+
|
||||
+ @wrap_exceptions
|
||||
+ def set_process_nice(self, value):
|
||||
+ return _psutil_posix.setpriority(self.pid, value)
|
||||
+
|
||||
+ @wrap_exceptions
|
||||
+ def get_process_status(self):
|
||||
+ code = _psutil_netbsd.get_process_status(self.pid)
|
||||
+ if code in _status_map:
|
||||
+ return _status_map[code]
|
||||
+ # XXX is this legit? will we even ever get here?
|
||||
+ return "?"
|
||||
+
|
||||
+ @wrap_exceptions
|
||||
+ def get_process_io_counters(self):
|
||||
+ rc, wc, rb, wb = _psutil_netbsd.get_process_io_counters(self.pid)
|
||||
+ return nt_io(rc, wc, rb, wb)
|
||||
+
|
||||
+ nt_mmap_grouped = namedtuple('mmap',
|
||||
+ 'path rss, private, ref_count, shadow_count')
|
||||
+ nt_mmap_ext = namedtuple('mmap',
|
||||
+ 'addr, perms path rss, private, ref_count, shadow_count')
|
||||
+
|
||||
+ @wrap_exceptions
|
||||
+ def get_memory_maps(self):
|
||||
+ return _psutil_netbsd.get_process_memory_maps(self.pid)
|
||||
+
|
||||
+ # FreeBSD < 8 does not support kinfo_getfile() and kinfo_getvmmap()
|
||||
+ if not hasattr(_psutil_netbsd, 'get_process_open_files'):
|
||||
+ def _not_implemented(self):
|
||||
+ raise NotImplementedError("supported only starting from FreeBSD 8")
|
||||
+ get_open_files = _not_implemented
|
||||
+ get_process_cwd = _not_implemented
|
||||
+ get_memory_maps = _not_implemented
|
||||
+ get_num_fds = _not_implemented
|
||||
1314
sysutils/py-psutil/patches/patch-psutil___psutil__netbsd.c
Normal file
1314
sysutils/py-psutil/patches/patch-psutil___psutil__netbsd.c
Normal file
File diff suppressed because it is too large
Load Diff
57
sysutils/py-psutil/patches/patch-psutil___psutil__netbsd.h
Normal file
57
sysutils/py-psutil/patches/patch-psutil___psutil__netbsd.h
Normal file
@@ -0,0 +1,57 @@
|
||||
$NetBSD: patch-psutil___psutil__netbsd.h,v 1.1 2013/10/12 13:32:36 wiz Exp $
|
||||
|
||||
Port to NetBSD.
|
||||
|
||||
--- psutil/_psutil_netbsd.h.orig 2013-10-12 13:19:29.000000000 +0000
|
||||
+++ psutil/_psutil_netbsd.h
|
||||
@@ -0,0 +1,50 @@
|
||||
+/*
|
||||
+ * Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.
|
||||
+ * Use of this source code is governed by a BSD-style license that can be
|
||||
+ * found in the LICENSE file.
|
||||
+ *
|
||||
+ * NetBSD platform-specific module methods for _psutil_netbsd
|
||||
+ */
|
||||
+
|
||||
+#include <Python.h>
|
||||
+
|
||||
+// --- per-process functions
|
||||
+
|
||||
+static PyObject* get_process_cpu_times(PyObject* self, PyObject* args);
|
||||
+static PyObject* get_process_name(PyObject* self, PyObject* args);
|
||||
+static PyObject* get_process_exe(PyObject* self, PyObject* args);
|
||||
+static PyObject* get_process_cmdline(PyObject* self, PyObject* args);
|
||||
+static PyObject* get_process_ppid(PyObject* self, PyObject* args);
|
||||
+static PyObject* get_process_uids(PyObject* self, PyObject* args);
|
||||
+static PyObject* get_process_gids(PyObject* self, PyObject* args);
|
||||
+static PyObject* get_process_connections(PyObject* self, PyObject* args);
|
||||
+static PyObject* get_process_create_time(PyObject* self, PyObject* args);
|
||||
+static PyObject* get_process_memory_info(PyObject* self, PyObject* args);
|
||||
+static PyObject* get_process_num_threads(PyObject* self, PyObject* args);
|
||||
+static PyObject* get_process_num_fds(PyObject* self, PyObject* args);
|
||||
+static PyObject* get_process_threads(PyObject* self, PyObject* args);
|
||||
+static PyObject* get_process_status(PyObject* self, PyObject* args);
|
||||
+static PyObject* get_process_io_counters(PyObject* self, PyObject* args);
|
||||
+static PyObject* get_process_tty_nr(PyObject* self, PyObject* args);
|
||||
+static PyObject* get_process_memory_maps(PyObject* self, PyObject* args);
|
||||
+static PyObject* get_process_num_ctx_switches(PyObject* self, PyObject* args);
|
||||
+#if NOTYET
|
||||
+static PyObject* get_process_open_files(PyObject* self, PyObject* args);
|
||||
+static PyObject* get_process_cwd(PyObject* self, PyObject* args);
|
||||
+#endif
|
||||
+
|
||||
+// --- system-related functions
|
||||
+
|
||||
+static PyObject* get_pid_list(PyObject* self, PyObject* args);
|
||||
+static PyObject* get_num_cpus(PyObject* self, PyObject* args);
|
||||
+static PyObject* get_virtual_mem(PyObject* self, PyObject* args);
|
||||
+static PyObject* get_swap_mem(PyObject* self, PyObject* args);
|
||||
+static PyObject* get_system_cpu_times(PyObject* self, PyObject* args);
|
||||
+#if NOTYET
|
||||
+static PyObject* get_system_per_cpu_times(PyObject* self, PyObject* args);
|
||||
+#endif
|
||||
+static PyObject* get_system_boot_time(PyObject* self, PyObject* args);
|
||||
+static PyObject* get_disk_partitions(PyObject* self, PyObject* args);
|
||||
+static PyObject* get_net_io_counters(PyObject* self, PyObject* args);
|
||||
+static PyObject* get_disk_io_counters(PyObject* self, PyObject* args);
|
||||
+static PyObject* get_system_users(PyObject* self, PyObject* args);
|
||||
33
sysutils/py-psutil/patches/patch-psutil___psutil__sunos.c
Normal file
33
sysutils/py-psutil/patches/patch-psutil___psutil__sunos.c
Normal file
@@ -0,0 +1,33 @@
|
||||
$NetBSD: patch-psutil___psutil__sunos.c,v 1.1 2013/12/07 21:25:24 richard Exp $
|
||||
|
||||
--- psutil/_psutil_sunos.c.orig 2013-11-20 19:29:05.000000000 +0000
|
||||
+++ psutil/_psutil_sunos.c
|
||||
@@ -772,8 +772,9 @@ error:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
-
|
||||
+#ifndef EXPER_IP_AND_ALL_IRES
|
||||
#define EXPER_IP_AND_ALL_IRES (1024+4)
|
||||
+#endif
|
||||
|
||||
// a signaler for connections without an actual status
|
||||
static int PSUTIL_CONN_NONE = 128;
|
||||
@@ -790,7 +791,7 @@ static PyObject*
|
||||
get_process_connections(PyObject* self, PyObject* args)
|
||||
{
|
||||
long pid;
|
||||
- int sd = NULL;
|
||||
+ int sd = 0;
|
||||
mib2_tcpConnEntry_t *tp = NULL;
|
||||
mib2_udpEntry_t *ude;
|
||||
#if defined(AF_INET6)
|
||||
@@ -1059,7 +1060,7 @@ error:
|
||||
Py_XDECREF(py_raddr);
|
||||
Py_DECREF(py_retlist);
|
||||
// TODO : free databuf
|
||||
- if (sd != NULL)
|
||||
+ if (sd > 0)
|
||||
close(sd);
|
||||
return NULL;
|
||||
}
|
||||
@@ -0,0 +1,296 @@
|
||||
$NetBSD: patch-psutil_arch_netbsd_process__info.c,v 1.1 2013/10/12 13:32:36 wiz Exp $
|
||||
|
||||
Port to NetBSD.
|
||||
|
||||
--- psutil/arch/netbsd/process_info.c.orig 2013-10-12 13:19:29.000000000 +0000
|
||||
+++ psutil/arch/netbsd/process_info.c
|
||||
@@ -0,0 +1,289 @@
|
||||
+/*
|
||||
+ * Copyright (c) 2009, Jay Loden, Giampaolo Rodola'. All rights reserved.
|
||||
+ * Use of this source code is governed by a BSD-style license that can be
|
||||
+ * found in the LICENSE file.
|
||||
+ *
|
||||
+ * Helper functions related to fetching process information. Used by _psutil_netbsd
|
||||
+ * module methods.
|
||||
+ */
|
||||
+
|
||||
+#include <Python.h>
|
||||
+#include <assert.h>
|
||||
+#include <errno.h>
|
||||
+#include <stdlib.h>
|
||||
+#include <stdio.h>
|
||||
+#include <string.h>
|
||||
+#include <sys/types.h>
|
||||
+#include <sys/sysctl.h>
|
||||
+#include <sys/param.h>
|
||||
+#include <sys/user.h>
|
||||
+#include <sys/proc.h>
|
||||
+#include <signal.h>
|
||||
+
|
||||
+#include "process_info.h"
|
||||
+
|
||||
+
|
||||
+/*
|
||||
+ * Returns a list of all BSD processes on the system. This routine
|
||||
+ * allocates the list and puts it in *procList and a count of the
|
||||
+ * number of entries in *procCount. You are responsible for freeing
|
||||
+ * this list (use "free" from System framework).
|
||||
+ * On success, the function returns 0.
|
||||
+ * On error, the function returns a BSD errno value.
|
||||
+ */
|
||||
+int
|
||||
+psutil_get_proc_list(struct kinfo_proc2 **procList, size_t *procCount)
|
||||
+{
|
||||
+ int err;
|
||||
+ struct kinfo_proc2 * result;
|
||||
+ int done;
|
||||
+ static const int name[] = { CTL_KERN, KERN_PROC2, KERN_PROC_ALL, 0 };
|
||||
+ // Declaring name as const requires us to cast it when passing it to
|
||||
+ // sysctl because the prototype doesn't include the const modifier.
|
||||
+ size_t length;
|
||||
+
|
||||
+ assert( procList != NULL);
|
||||
+ assert(*procList == NULL);
|
||||
+ assert(procCount != NULL);
|
||||
+
|
||||
+ *procCount = 0;
|
||||
+
|
||||
+ /*
|
||||
+ * We start by calling sysctl with result == NULL and length == 0.
|
||||
+ * That will succeed, and set length to the appropriate length.
|
||||
+ * We then allocate a buffer of that size and call sysctl again
|
||||
+ * with that buffer. If that succeeds, we're done. If that fails
|
||||
+ * with ENOMEM, we have to throw away our buffer and loop. Note
|
||||
+ * that the loop causes use to call sysctl with NULL again; this
|
||||
+ * is necessary because the ENOMEM failure case sets length to
|
||||
+ * the amount of data returned, not the amount of data that
|
||||
+ * could have been returned.
|
||||
+ */
|
||||
+ result = NULL;
|
||||
+ done = 0;
|
||||
+ do {
|
||||
+ assert(result == NULL);
|
||||
+ // Call sysctl with a NULL buffer.
|
||||
+ length = 0;
|
||||
+ err = sysctl((int *)name, (sizeof(name) / sizeof(*name)) - 1,
|
||||
+ NULL, &length, NULL, 0);
|
||||
+ if (err == -1)
|
||||
+ err = errno;
|
||||
+
|
||||
+ // Allocate an appropriately sized buffer based on the results
|
||||
+ // from the previous call.
|
||||
+ if (err == 0) {
|
||||
+ result = malloc(length);
|
||||
+ if (result == NULL)
|
||||
+ err = ENOMEM;
|
||||
+ }
|
||||
+
|
||||
+ // Call sysctl again with the new buffer. If we get an ENOMEM
|
||||
+ // error, toss away our buffer and start again.
|
||||
+ if (err == 0) {
|
||||
+ err = sysctl((int *) name, (sizeof(name) / sizeof(*name)) - 1,
|
||||
+ result, &length, NULL, 0);
|
||||
+ if (err == -1)
|
||||
+ err = errno;
|
||||
+ if (err == 0) {
|
||||
+ done = 1;
|
||||
+ }
|
||||
+ else if (err == ENOMEM) {
|
||||
+ assert(result != NULL);
|
||||
+ free(result);
|
||||
+ result = NULL;
|
||||
+ err = 0;
|
||||
+ }
|
||||
+ }
|
||||
+ } while (err == 0 && ! done);
|
||||
+
|
||||
+ // Clean up and establish post conditions.
|
||||
+ if (err != 0 && result != NULL) {
|
||||
+ free(result);
|
||||
+ result = NULL;
|
||||
+ }
|
||||
+
|
||||
+ *procList = result;
|
||||
+ *procCount = length / sizeof(struct kinfo_proc2);
|
||||
+
|
||||
+ assert((err == 0) == (*procList != NULL));
|
||||
+ return err;
|
||||
+}
|
||||
+
|
||||
+
|
||||
+char
|
||||
+*psutil_get_cmd_path(long pid, size_t *pathsize)
|
||||
+{
|
||||
+#if defined(__FreeBSD__)
|
||||
+ int mib[4];
|
||||
+ char *path;
|
||||
+ size_t size = 0;
|
||||
+
|
||||
+ /*
|
||||
+ * Make a sysctl() call to get the raw argument space of the process.
|
||||
+ */
|
||||
+ mib[0] = CTL_KERN;
|
||||
+ mib[1] = KERN_PROC2;
|
||||
+ mib[2] = KERN_PROC_PATHNAME;
|
||||
+ mib[3] = pid;
|
||||
+
|
||||
+ // call with a null buffer first to determine if we need a buffer
|
||||
+ if (sysctl(mib, 4, NULL, &size, NULL, 0) == -1) {
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ path = malloc(size);
|
||||
+ if (path == NULL) {
|
||||
+ PyErr_NoMemory();
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ *pathsize = size;
|
||||
+ if (sysctl(mib, MIB_LEN, path, &size, NULL, 0) == -1) {
|
||||
+ free(path);
|
||||
+ return NULL; /* Insufficient privileges */
|
||||
+ }
|
||||
+
|
||||
+ return path;
|
||||
+#else
|
||||
+ /* not supported */
|
||||
+ return NULL;
|
||||
+#endif
|
||||
+}
|
||||
+
|
||||
+
|
||||
+/*
|
||||
+ * XXX no longer used; it probably makese sense to remove it.
|
||||
+ * Borrowed from psi Python System Information project
|
||||
+ *
|
||||
+ * Get command arguments and environment variables.
|
||||
+ *
|
||||
+ * Based on code from ps.
|
||||
+ *
|
||||
+ * Returns:
|
||||
+ * 0 for success;
|
||||
+ * -1 for failure (Exception raised);
|
||||
+ * 1 for insufficient privileges.
|
||||
+ */
|
||||
+char
|
||||
+*psutil_get_cmd_args(long pid, size_t *argsize)
|
||||
+{
|
||||
+ int mib[4], argmax;
|
||||
+ size_t size = sizeof(argmax);
|
||||
+ char *procargs = NULL;
|
||||
+
|
||||
+ /* Get the maximum process arguments size. */
|
||||
+ mib[0] = CTL_KERN;
|
||||
+ mib[1] = KERN_ARGMAX;
|
||||
+
|
||||
+ size = sizeof(argmax);
|
||||
+ if (sysctl(mib, 2, &argmax, &size, NULL, 0) == -1)
|
||||
+ return NULL;
|
||||
+
|
||||
+ /* Allocate space for the arguments. */
|
||||
+ procargs = (char *)malloc(argmax);
|
||||
+ if (procargs == NULL) {
|
||||
+ PyErr_NoMemory();
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ /*
|
||||
+ * Make a sysctl() call to get the raw argument space of the process.
|
||||
+ */
|
||||
+ mib[0] = CTL_KERN;
|
||||
+ mib[1] = KERN_PROC;
|
||||
+ mib[2] = KERN_PROC_ARGS;
|
||||
+ mib[3] = pid;
|
||||
+
|
||||
+ size = argmax;
|
||||
+ if (sysctl(mib, 4, procargs, &size, NULL, 0) == -1) {
|
||||
+ free(procargs);
|
||||
+ return NULL; /* Insufficient privileges */
|
||||
+ }
|
||||
+
|
||||
+ // return string and set the length of arguments
|
||||
+ *argsize = size;
|
||||
+ return procargs;
|
||||
+}
|
||||
+
|
||||
+
|
||||
+/* returns the command line as a python list object */
|
||||
+PyObject*
|
||||
+psutil_get_arg_list(long pid)
|
||||
+{
|
||||
+ char *argstr = NULL;
|
||||
+ int pos = 0;
|
||||
+ size_t argsize = 0;
|
||||
+ PyObject *retlist = Py_BuildValue("[]");
|
||||
+ PyObject *item = NULL;
|
||||
+
|
||||
+ if (pid < 0) {
|
||||
+ return retlist;
|
||||
+ }
|
||||
+
|
||||
+ argstr = psutil_get_cmd_args(pid, &argsize);
|
||||
+ if (argstr == NULL) {
|
||||
+ goto error;
|
||||
+ }
|
||||
+
|
||||
+ // args are returned as a flattened string with \0 separators between
|
||||
+ // arguments add each string to the list then step forward to the next
|
||||
+ // separator
|
||||
+ if (argsize > 0) {
|
||||
+ while(pos < argsize) {
|
||||
+ item = Py_BuildValue("s", &argstr[pos]);
|
||||
+ if (!item)
|
||||
+ goto error;
|
||||
+ if (PyList_Append(retlist, item))
|
||||
+ goto error;
|
||||
+ Py_DECREF(item);
|
||||
+ pos = pos + strlen(&argstr[pos]) + 1;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ free(argstr);
|
||||
+ return retlist;
|
||||
+
|
||||
+error:
|
||||
+ Py_XDECREF(item);
|
||||
+ Py_DECREF(retlist);
|
||||
+ if (argstr != NULL)
|
||||
+ free(argstr);
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
+
|
||||
+/*
|
||||
+ * Return 1 if PID exists in the current process list, else 0.
|
||||
+ */
|
||||
+int
|
||||
+psutil_pid_exists(long pid)
|
||||
+{
|
||||
+ int kill_ret;
|
||||
+ if (pid < 0) {
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ // if kill returns success of permission denied we know it's a valid PID
|
||||
+ kill_ret = kill(pid , 0);
|
||||
+ if ((0 == kill_ret) || (EPERM == errno)) {
|
||||
+ return 1;
|
||||
+ }
|
||||
+
|
||||
+ // otherwise return 0 for PID not found
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+
|
||||
+/*
|
||||
+ * Set exception to AccessDenied if pid exists else NoSuchProcess.
|
||||
+ */
|
||||
+int
|
||||
+psutil_raise_ad_or_nsp(pid) {
|
||||
+ if (psutil_pid_exists(pid) == 0) {
|
||||
+ NoSuchProcess();
|
||||
+ }
|
||||
+ else {
|
||||
+ AccessDenied();
|
||||
+ }
|
||||
+}
|
||||
@@ -0,0 +1,23 @@
|
||||
$NetBSD: patch-psutil_arch_netbsd_process__info.h,v 1.1 2013/10/12 13:32:36 wiz Exp $
|
||||
|
||||
Port to NetBSD.
|
||||
|
||||
--- psutil/arch/netbsd/process_info.h.orig 2013-10-12 13:19:29.000000000 +0000
|
||||
+++ psutil/arch/netbsd/process_info.h
|
||||
@@ -0,0 +1,16 @@
|
||||
+/*
|
||||
+ * Copyright (c) 2009, Jay Loden, Giampaolo Rodola'. All rights reserved.
|
||||
+ * Use of this source code is governed by a BSD-style license that can be
|
||||
+ * found in the LICENSE file.
|
||||
+ *
|
||||
+ * Helper functions related to fetching process information. Used by _psutil_netbsd
|
||||
+ * module methods.
|
||||
+ */
|
||||
+
|
||||
+#include <Python.h>
|
||||
+
|
||||
+int psutil_get_proc_list(struct kinfo_proc2 **procList, size_t *procCount);
|
||||
+char *psutil_get_cmd_args(long pid, size_t *argsize);
|
||||
+char *psutil_get_cmd_path(long pid, size_t *pathsize);
|
||||
+int psutil_pid_exists(long pid);
|
||||
+PyObject* psutil_get_arg_list(long pid);
|
||||
25
sysutils/py-psutil/patches/patch-setup.py
Normal file
25
sysutils/py-psutil/patches/patch-setup.py
Normal file
@@ -0,0 +1,25 @@
|
||||
$NetBSD: patch-setup.py,v 1.3 2013/12/07 21:25:24 richard Exp $
|
||||
|
||||
Port to NetBSD.
|
||||
|
||||
--- setup.py.orig 2013-11-20 19:29:05.000000000 +0000
|
||||
+++ setup.py
|
||||
@@ -122,6 +122,18 @@ elif sys.platform.startswith("freebsd"):
|
||||
libraries=["devstat"]),
|
||||
posix_extension,
|
||||
]
|
||||
+# NetBSD
|
||||
+elif sys.platform.startswith("netbsd"):
|
||||
+ extensions = [Extension(
|
||||
+ '_psutil_netbsd',
|
||||
+ sources = [
|
||||
+ 'psutil/_psutil_netbsd.c',
|
||||
+ 'psutil/_psutil_common.c',
|
||||
+ 'psutil/arch/netbsd/process_info.c'
|
||||
+ ],
|
||||
+ libraries=[]),
|
||||
+ posix_extension,
|
||||
+ ]
|
||||
# Linux
|
||||
elif sys.platform.startswith("linux"):
|
||||
extensions = [Extension(
|
||||
15
sysutils/py-psutil/patches/patch-test_test__psutil.py
Normal file
15
sysutils/py-psutil/patches/patch-test_test__psutil.py
Normal file
@@ -0,0 +1,15 @@
|
||||
$NetBSD: patch-test_test__psutil.py,v 1.2 2013/12/07 21:25:24 richard Exp $
|
||||
|
||||
Port to NetBSD.
|
||||
|
||||
--- test/test_psutil.py.orig 2013-11-22 21:26:42.000000000 +0000
|
||||
+++ test/test_psutil.py
|
||||
@@ -77,7 +77,7 @@ POSIX = os.name == 'posix'
|
||||
LINUX = sys.platform.startswith("linux")
|
||||
WINDOWS = sys.platform.startswith("win32")
|
||||
OSX = sys.platform.startswith("darwin")
|
||||
-BSD = sys.platform.startswith("freebsd")
|
||||
+BSD = sys.platform.startswith("freebsd") or sys.platform.startswith("netbsd")
|
||||
SUNOS = sys.platform.startswith("sunos")
|
||||
VALID_PROC_STATUSES = [getattr(psutil, x) for x in dir(psutil)
|
||||
if x.startswith('STATUS_')]
|
||||
Reference in New Issue
Block a user