BIND 10 trac2172, updated. a47c2eae8dd926d05a7ba27f1cde67ac98006673 [2172] rearrange freebsd/osx hierarchy
BIND 10 source code commits
bind10-changes at lists.isc.org
Wed Aug 8 19:05:56 UTC 2012
The branch, trac2172 has been updated
via a47c2eae8dd926d05a7ba27f1cde67ac98006673 (commit)
from 371d3158521b1072115c55cac20b61ab9e605ea2 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit a47c2eae8dd926d05a7ba27f1cde67ac98006673
Author: Jelte Jansen <jelte at isc.org>
Date: Wed Aug 8 21:05:25 2012 +0200
[2172] rearrange freebsd/osx hierarchy
-----------------------------------------------------------------------
Summary of changes:
src/lib/python/isc/sysinfo/sysinfo.py | 88 +++++++++++++--------------------
1 file changed, 35 insertions(+), 53 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/python/isc/sysinfo/sysinfo.py b/src/lib/python/isc/sysinfo/sysinfo.py
index 69032f7..5f9b97f 100644
--- a/src/lib/python/isc/sysinfo/sysinfo.py
+++ b/src/lib/python/isc/sysinfo/sysinfo.py
@@ -349,9 +349,9 @@ class SysInfoOpenBSD(SysInfoBSD):
except (subprocess.CalledProcessError, OSError):
self._net_routing_table = 'Warning: "route -n show" command failed.\n'
-class SysInfoFreeBSD(SysInfoBSD):
- """FreeBSD implementation of the SysInfo class.
- See the SysInfo class documentation for more information.
+class SysInfoFreeBSDOSX(SysInfoBSD):
+ """Shared code for the FreeBSD and OS X implementations of the SysInfo
+ class. See the SysInfo class documentation for more information.
"""
def __init__(self):
super().__init__()
@@ -361,12 +361,6 @@ class SysInfoFreeBSD(SysInfoBSD):
self._mem_buffers = -1
try:
- s = subprocess.check_output(['sysctl', '-n', 'kern.smp.active'])
- self._platform_is_smp = int(s.decode('utf-8').strip()) > 0
- except (subprocess.CalledProcessError, OSError):
- pass
-
- try:
s = subprocess.check_output(['sysctl', '-n', 'kern.boottime'])
t = s.decode('utf-8').strip()
r = re.match('^\{\s+sec\s+\=\s+(\d+),.*', t)
@@ -390,6 +384,25 @@ class SysInfoFreeBSD(SysInfoBSD):
pass
try:
+ s = subprocess.check_output(['netstat', '-nr'])
+ self._net_routing_table = s.decode('utf-8')
+ except (subprocess.CalledProcessError, OSError):
+ self._net_connections = 'Warning: "netstat -nr" command failed.\n'
+
+class SysInfoFreeBSD(SysInfoFreeBSDOSX):
+ """FreeBSD implementation of the SysInfo class.
+ See the SysInfo class documentation for more information.
+ """
+ def __init__(self):
+ super().__init()
+
+ try:
+ s = subprocess.check_output(['sysctl', '-n', 'kern.smp.active'])
+ self._platform_is_smp = int(s.decode('utf-8').strip()) > 0
+ except (subprocess.CalledProcessError, OSError):
+ pass
+
+ try:
s = subprocess.check_output(['vmstat', '-H'])
lines = s.decode('utf-8').split('\n')
v = re.split('\s+', lines[2])
@@ -408,49 +421,22 @@ class SysInfoFreeBSD(SysInfoBSD):
except (subprocess.CalledProcessError, OSError):
pass
- try:
- s = subprocess.check_output(['netstat', '-nr'])
- self._net_routing_table = s.decode('utf-8')
- except (subprocess.CalledProcessError, OSError):
- self._net_connections = 'Warning: "netstat -nr" command failed.\n'
-class SysInfoOSX(SysInfoBSD):
+
+class SysInfoOSX(SysInfoFreeBSDOSX):
"""OS X (Darwin) implementation of the SysInfo class.
See the SysInfo class documentation for more information.
"""
def __init__(self):
super().__init__()
- # Don't know how to gather these
- self._mem_cached = -1
- self._mem_buffers = -1
-
- try:
- s = subprocess.check_output(['sysctl', '-n', 'kern.smp.active'])
- self._platform_is_smp = int(s.decode('utf-8').strip()) > 0
- except (subprocess.CalledProcessError, OSError):
- pass
-
- try:
- s = subprocess.check_output(['sysctl', '-n', 'kern.boottime'])
- t = s.decode('utf-8').strip()
- r = re.match('^\{\s+sec\s+\=\s+(\d+),.*', t)
- if r:
- sec = time.time() - int(r.group(1))
- self._uptime = int(round(sec))
- except (subprocess.CalledProcessError, OSError):
- pass
-
+ # note; this call overrides the value already set when hw.physmem
+ # was read. However, on OSX, physmem is not necessarily the correct
+ # value. But since it does not fail and does work on most BSD's, it's
+ # left in the base class and overwritten here
try:
- s = subprocess.check_output(['sysctl', '-n', 'vm.loadavg'])
- l = s.decode('utf-8').strip()
- r = re.match('^\{(.*)\}$', l)
- if r:
- la = r.group(1).strip().split(' ')
- else:
- la = l.split(' ')
- if len(la) >= 3:
- self._loadavg = [float(la[0]), float(la[1]), float(la[2])]
+ s = subprocess.check_output(['sysctl', '-n', 'hw.memsize'])
+ self._mem_total = int(s.decode('utf-8').strip())
except (subprocess.CalledProcessError, OSError):
pass
@@ -459,7 +445,7 @@ class SysInfoOSX(SysInfoBSD):
lines = s.decode('utf-8').split('\n')
# store all values in a dict
values = {}
- page_size = 4096
+ page_size = None
page_size_re = re.compile('page size of [0-9]+ bytes')
for line in lines:
page_size_m = page_size_re.match(line)
@@ -468,7 +454,10 @@ class SysInfoOSX(SysInfoBSD):
else:
key, _, value = line.partition(':')
values[key] = value.strip()[:-1]
- self._mem_free = int(values['Pages free']) * page_size
+ # Only calculate memory if page size is known
+ if page_size is not None:
+ self._mem_free = int(values['Pages free']) * page_size +
+ int(values['Pages speculative']) * page_size
except (subprocess.CalledProcessError, OSError):
pass
@@ -482,13 +471,6 @@ class SysInfoOSX(SysInfoBSD):
except (subprocess.CalledProcessError, OSError):
pass
- try:
- s = subprocess.check_output(['netstat', '-nr'])
- self._net_routing_table = s.decode('utf-8')
- except (subprocess.CalledProcessError, OSError):
- self._net_connections = 'Warning: "netstat -nr" command failed.\n'
-
-
class SysInfoTestcase(SysInfo):
def __init__(self):
More information about the bind10-changes
mailing list