Skip to content

Commit ed657e9

Browse files
rmustaccry
authored andcommitted
Add loadavg for SunOS
1 parent 6c7c4ae commit ed657e9

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/platform_sunos.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include <errno.h>
3232
#include <inttypes.h>
3333
#include <sys/types.h>
34+
#include <sys/loadavg.h>
3435

3536
#if (!defined(_LP64)) && (_FILE_OFFSET_BITS - 0 == 64)
3637
#define PROCFS_FILE_OFFSET_BITS_HACK 1
@@ -249,6 +250,14 @@ double Platform::GetUptime() {
249250
}
250251

251252
int Platform::GetLoadAvg(Local<Array> *loads) {
253+
HandleScope scope;
254+
double loadavg[3];
255+
256+
(void) getloadavg(loadavg, 3);
257+
(*loads)->Set(0, Number::New(loadavg[LOADAVG_1MIN]));
258+
(*loads)->Set(1, Number::New(loadavg[LOADAVG_5MIN]));
259+
(*loads)->Set(2, Number::New(loadavg[LOADAVG_15MIN]));
260+
252261
return 0;
253262
}
254263

0 commit comments

Comments
 (0)