Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ISC Open Source Projects
Kea
Commits
db05d3ba
Commit
db05d3ba
authored
Aug 13, 2012
by
Jelte Jansen
Browse files
[2172] use netstat instead of route on openBSD
parent
ffc684f6
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/lib/python/isc/sysinfo/sysinfo.py
View file @
db05d3ba
...
...
@@ -303,6 +303,12 @@ class SysInfoBSD(SysInfoPOSIX):
except
(
subprocess
.
CalledProcessError
,
OSError
):
self
.
_net_connections
=
'Warning: "netstat -an" command failed.
\n
'
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
SysInfoOpenBSD
(
SysInfoBSD
):
"""OpenBSD implementation of the SysInfo class.
See the SysInfo class documentation for more information.
...
...
@@ -345,12 +351,6 @@ class SysInfoOpenBSD(SysInfoBSD):
except
(
subprocess
.
CalledProcessError
,
OSError
):
pass
try
:
s
=
subprocess
.
check_output
([
'route'
,
'-n'
,
'show'
])
self
.
_net_routing_table
=
s
.
decode
(
'utf-8'
)
except
(
subprocess
.
CalledProcessError
,
OSError
):
self
.
_net_routing_table
=
'Warning: "route -n show" command failed.
\n
'
class
SysInfoFreeBSDOSX
(
SysInfoBSD
):
"""Shared code for the FreeBSD and OS X implementations of the SysInfo
class. See the SysInfo class documentation for more information.
...
...
@@ -381,12 +381,6 @@ class SysInfoFreeBSDOSX(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
SysInfoFreeBSD
(
SysInfoFreeBSDOSX
):
"""FreeBSD implementation of the SysInfo class.
See the SysInfo class documentation for more information.
...
...
src/lib/python/isc/sysinfo/tests/sysinfo_test.py
View file @
db05d3ba
...
...
@@ -138,6 +138,8 @@ def _my_bsd_subprocess_check_output(command):
return
b
'osuxbrcc1g9VgaF4yf3FrtfodrfATrbSnjhqhuQSAs8=
\n
'
elif
command
==
[
'netstat'
,
'-an'
]:
return
b
'Z+w0lwa02/T+5+EIio84rrst/Dtizoz/aL9Im7J7ESA=
\n
'
elif
command
==
[
'netstat'
,
'-nr'
]:
return
b
'XfizswwNA9NkXz6K36ZExpjV08Y5IXkHI8jjDSV+5Nc=
\n
'
else
:
return
None
...
...
@@ -151,8 +153,6 @@ def _my_openbsd_subprocess_check_output(command):
return
b
' procs memory page disks traps cpu
\n
r b w avm fre flt re pi po fr sr wd0 cd0 int sys cs us sy id
\n
0 0 0 121212 123456 47 0 0 0 0 0 2 0 2 80 14 0 1 99
\n
'
elif
command
==
[
'swapctl'
,
'-s'
,
'-k'
]:
return
b
'total: 553507 1K-blocks allocated, 2 used, 553505 available'
elif
command
==
[
'route'
,
'-n'
,
'show'
]:
return
b
'XfizswwNA9NkXz6K36ZExpjV08Y5IXkHI8jjDSV+5Nc=
\n
'
else
:
bsd_output
=
_my_bsd_subprocess_check_output
(
command
)
if
bsd_output
is
not
None
:
...
...
@@ -178,8 +178,6 @@ def _my_freebsd_osx_subprocess_check_output(command):
return
bytes
(
'{ sec = '
+
str
(
int
(
time
.
time
()
-
76632
))
+
', usec = 0 }
\n
'
,
'utf-8'
)
elif
command
==
[
'sysctl'
,
'-n'
,
'vm.loadavg'
]:
return
b
'{ 0.2 0.4 0.6 }
\n
'
elif
command
==
[
'netstat'
,
'-nr'
]:
return
b
'XfizswwNA9NkXz6K36ZExpjV08Y5IXkHI8jjDSV+5Nc=
\n
'
else
:
return
_my_bsd_subprocess_check_output
(
command
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment