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
1bb96c51
Commit
1bb96c51
authored
Aug 09, 2012
by
Jelte Jansen
Browse files
[2172] use 3-tuple instead of fixed-size list for loadavg
parent
3fc727f1
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/bin/sysinfo/sysinfo.py.in
View file @
1bb96c51
...
...
@@ -90,8 +90,7 @@ def main():
write_value(f, ' + Hostname: %s\n', s.get_platform_hostname)
write_value(f, ' + Uptime: %d seconds\n', s.get_uptime)
l = s.get_loadavg()
f.write(' + Loadavg: %f %f %f\n' % (l[0], l[1], l[2]))
write_value(f, ' + Loadavg: %f %f %f\n', s.get_loadavg)
f.write('\nMemory\n');
write_value(f, ' + Total: %d bytes\n', s.get_mem_total)
...
...
src/lib/python/isc/sysinfo/sysinfo.py
View file @
1bb96c51
...
...
@@ -164,7 +164,7 @@ class SysInfoLinux(SysInfoPOSIX):
with
open
(
'/proc/loadavg'
)
as
f
:
l
=
f
.
read
().
strip
().
split
(
' '
)
if
len
(
l
)
>=
3
:
self
.
_loadavg
=
[
float
(
l
[
0
]),
float
(
l
[
1
]),
float
(
l
[
2
])
]
self
.
_loadavg
=
(
float
(
l
[
0
]),
float
(
l
[
1
]),
float
(
l
[
2
])
)
with
open
(
'/proc/meminfo'
)
as
f
:
m
=
f
.
readlines
()
...
...
@@ -315,7 +315,7 @@ class SysInfoOpenBSD(SysInfoBSD):
s
=
subprocess
.
check_output
([
'sysctl'
,
'-n'
,
'vm.loadavg'
])
l
=
s
.
decode
(
'utf-8'
).
strip
().
split
(
' '
)
if
len
(
l
)
>=
3
:
self
.
_loadavg
=
[
float
(
l
[
0
]),
float
(
l
[
1
]),
float
(
l
[
2
])
]
self
.
_loadavg
=
(
float
(
l
[
0
]),
float
(
l
[
1
]),
float
(
l
[
2
])
)
except
(
subprocess
.
CalledProcessError
,
OSError
):
pass
...
...
@@ -370,7 +370,7 @@ class SysInfoFreeBSDOSX(SysInfoBSD):
else
:
la
=
l
.
split
(
' '
)
if
len
(
la
)
>=
3
:
self
.
_loadavg
=
[
float
(
la
[
0
]),
float
(
la
[
1
]),
float
(
la
[
2
])
]
self
.
_loadavg
=
(
float
(
la
[
0
]),
float
(
la
[
1
]),
float
(
la
[
2
])
)
except
(
subprocess
.
CalledProcessError
,
OSError
):
pass
...
...
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