Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
htop
Commits
6d92d7f7
Commit
6d92d7f7
authored
Nov 27, 2014
by
Hisham Muhammad
Browse files
Load averages for FreeBSD!
parent
96e03739
Changes
3
Hide whitespace changes
Inline
Side-by-side
freebsd/Platform.c
View file @
6d92d7f7
...
...
@@ -20,6 +20,8 @@ in the source distribution for its full text.
#include <sys/types.h>
#include <sys/sysctl.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <vm/vm_param.h>
#include <time.h>
/*{
...
...
@@ -64,3 +66,20 @@ int Platform_getUptime() {
return
(
int
)
difftime
(
currTime
.
tv_sec
,
bootTime
.
tv_sec
);
}
void
Platform_getLoadAverage
(
double
*
one
,
double
*
five
,
double
*
fifteen
)
{
struct
loadavg
loadAverage
;
int
mib
[
2
]
=
{
CTL_VM
,
VM_LOADAVG
};
size_t
size
=
sizeof
(
loadAverage
);
int
err
=
sysctl
(
mib
,
2
,
&
loadAverage
,
&
size
,
NULL
,
0
);
if
(
err
)
{
*
one
=
0
;
*
five
=
0
;
*
fifteen
=
0
;
return
;
}
*
one
=
(
double
)
loadAverage
.
ldavg
[
0
]
/
loadAverage
.
fscale
;
*
five
=
(
double
)
loadAverage
.
ldavg
[
1
]
/
loadAverage
.
fscale
;
*
fifteen
=
(
double
)
loadAverage
.
ldavg
[
2
]
/
loadAverage
.
fscale
;
}
freebsd/Platform.h
View file @
6d92d7f7
...
...
@@ -17,4 +17,6 @@ extern MeterClass* Platform_meterTypes[];
int
Platform_getUptime
();
void
Platform_getLoadAverage
(
double
*
one
,
double
*
five
,
double
*
fifteen
);
#endif
unsupported/Platform.h
View file @
6d92d7f7
...
...
@@ -17,4 +17,6 @@ extern MeterClass* Platform_meterTypes[];
int
Platform_getUptime
();
void
Platform_getLoadAverage
(
double
*
one
,
double
*
five
,
double
*
fifteen
);
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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