diff --git a/src/platform.h b/src/platform.h index 5aad8e5e2cc..db2c32cadb7 100644 --- a/src/platform.h +++ b/src/platform.h @@ -23,9 +23,6 @@ #define NODE_PLATFORM_H_ #include -#ifdef __sun -#include -#endif namespace node { @@ -42,7 +39,6 @@ class Platform { static double GetTotalMemory(); static double GetUptime(); static int GetLoadAvg(v8::Local *loads); - static v8::Handle GetInterfaceAddresses(); }; diff --git a/src/platform_sunos.cc b/src/platform_sunos.cc index 236d912a79b..dc9617e047b 100644 --- a/src/platform_sunos.cc +++ b/src/platform_sunos.cc @@ -27,10 +27,6 @@ #include /* getexecname() */ #include /* strncpy() */ -#include -#include -#include -#include #if (!defined(_LP64)) && (_FILE_OFFSET_BITS - 0 == 64) #define PROCFS_FILE_OFFSET_BITS_HACK 1 @@ -50,7 +46,6 @@ namespace node { using namespace v8; - char** Platform::SetupArgs(int argc, char *argv[]) { return argv; } @@ -113,103 +108,11 @@ int Platform::GetExecutablePath(char* buffer, size_t* size) { } -static Handle data_named(kstat_named_t *knp) { - Handle val; - - switch (knp->data_type) { - case KSTAT_DATA_CHAR: - val = Number::New(knp->value.c[0]); - break; - case KSTAT_DATA_INT32: - val = Number::New(knp->value.i32); - break; - case KSTAT_DATA_UINT32: - val = Number::New(knp->value.ui32); - break; - case KSTAT_DATA_INT64: - val = Number::New(knp->value.i64); - break; - case KSTAT_DATA_UINT64: - val = Number::New(knp->value.ui64); - break; - case KSTAT_DATA_STRING: - val = String::New(KSTAT_NAMED_STR_PTR(knp)); - break; - default: - throw (String::New("unrecognized data type")); - } - - return (val); -} +// TODO: libkstat provides all this info. Need to link it though. int Platform::GetCPUInfo(Local *cpus) { - HandleScope scope; - Local cpuinfo; - Local cputimes; - - int lookup_instance; - kstat_ctl_t *kc; - kstat_t *ksp; - kstat_named_t *knp; - - if ((kc = kstat_open()) == NULL) - throw "could not open kstat"; - - *cpus = Array::New(); - - lookup_instance = 0; - while (ksp = kstat_lookup(kc, "cpu_info", lookup_instance, NULL)) { - cpuinfo = Object::New(); - - if (kstat_read(kc, ksp, NULL) == -1) { - /* - * It is deeply annoying, but some kstats can return errors - * under otherwise routine conditions. (ACPI is one - * offender; there are surely others.) To prevent these - * fouled kstats from completely ruining our day, we assign - * an "error" member to the return value that consists of - * the strerror(). - */ - cpuinfo->Set(String::New("error"), String::New(strerror(errno))); - (*cpus)->Set(lookup_instance, cpuinfo); - } else { - knp = (kstat_named_t *) kstat_data_lookup(ksp, "clock_MHz"); - cpuinfo->Set(String::New("speed"), data_named(knp)); - knp = (kstat_named_t *) kstat_data_lookup(ksp, "brand"); - cpuinfo->Set(String::New("model"), data_named(knp)); - (*cpus)->Set(lookup_instance, cpuinfo); - } - - lookup_instance++; - } - - lookup_instance = 0; - while (ksp = kstat_lookup(kc, "cpu", lookup_instance, "sys")){ - cpuinfo = (*cpus)->Get(lookup_instance)->ToObject(); - cputimes = Object::New(); - - if (kstat_read(kc, ksp, NULL) == -1) { - cputimes->Set(String::New("error"), String::New(strerror(errno))); - cpuinfo->Set(String::New("times"), cpuinfo); - } else { - knp = (kstat_named_t *) kstat_data_lookup(ksp, "cpu_ticks_kernel"); - cputimes->Set(String::New("system"), data_named(knp)); - knp = (kstat_named_t *) kstat_data_lookup(ksp, "cpu_ticks_user"); - cputimes->Set(String::New("user"), data_named(knp)); - knp = (kstat_named_t *) kstat_data_lookup(ksp, "cpu_ticks_idle"); - cputimes->Set(String::New("idle"), data_named(knp)); - knp = (kstat_named_t *) kstat_data_lookup(ksp, "intr"); - cputimes->Set(String::New("irq"), data_named(knp)); - - cpuinfo->Set(String::New("times"), cputimes); - } - - lookup_instance++; - } - - kstat_close(kc); - + // http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/cmd/psrinfo/psrinfo.pl return 0; } @@ -225,29 +128,8 @@ double Platform::GetTotalMemory() { double Platform::GetUptime() { - kstat_ctl_t *kc; - kstat_t *ksp; - kstat_named_t *knp; - - long hz = sysconf(_SC_CLK_TCK); - ulong_t clk_intr; - - if ((kc = kstat_open()) == NULL) { - throw "could not open kstat"; - } - - ksp = kstat_lookup(kc, "unix", 0, "system_misc"); - - if (kstat_read(kc, ksp, NULL) == -1) { - throw "unable to read kstat"; - } else { - knp = (kstat_named_t *) kstat_data_lookup(ksp, "clk_intr"); - clk_intr = knp->value.ul; - } - - kstat_close(kc); - - return static_cast(clk_intr / hz); + // http://munin-monitoring.org/attachment/ticket/419/uptime + return 0.0; } @@ -256,11 +138,5 @@ int Platform::GetLoadAvg(Local *loads) { } -Handle Platform::GetInterfaceAddresses() { - HandleScope scope; - return scope.Close(Object::New()); -} - - } // namespace node diff --git a/test/simple/test-os.js b/test/simple/test-os.js index 54961fb58ef..5903f8f6b18 100644 --- a/test/simple/test-os.js +++ b/test/simple/test-os.js @@ -23,29 +23,11 @@ var common = require('../common'); var assert = require('assert'); var os = require('os'); -var hostname = os.hostname() -console.log("hostname = %s", hostname); -assert.ok(hostname.length > 0); - -var uptime = os.uptime(); -console.log("uptime = %d", uptime); -assert.ok(uptime > 0); - -var cpus = os.cpus(); -console.log("cpus = ", cpus); -assert.ok(cpus.length > 0); - -var type = os.type(); -console.log("type = ", type); -assert.ok(type.length > 0); - -var release = os.release(); -console.log("release = ", release); -assert.ok(release > 0); - -if (process.platform != 'sunos') { - // not implemeneted yet - assert.ok(os.loadavg().length > 0); - assert.ok(os.freemem() > 0); - assert.ok(os.totalmem() > 0); -} +assert.ok(os.hostname().length > 0); +assert.ok(os.loadavg().length > 0); +assert.ok(os.uptime() > 0); +assert.ok(os.freemem() > 0); +assert.ok(os.totalmem() > 0); +assert.ok(os.cpus().length > 0); +assert.ok(os.type().length > 0); +assert.ok(os.release().length > 0); \ No newline at end of file diff --git a/wscript b/wscript index 756b530cf8c..7692e83f4ed 100644 --- a/wscript +++ b/wscript @@ -359,8 +359,6 @@ def configure(conf): conf.fatal("Cannot find socket library") if not conf.check(lib='nsl', uselib_store="NSL"): conf.fatal("Cannot find nsl library") - if not conf.check(lib='kstat', uselib_store="KSTAT"): - conf.fatal("Cannot find kstat library") conf.sub_config('deps/libeio') @@ -804,7 +802,7 @@ def build(bld): node = bld.new_task_gen("cxx", product_type) node.name = "node" node.target = "node" - node.uselib = 'RT EV OPENSSL CARES EXECINFO DL KVM SOCKET NSL KSTAT UTIL OPROFILE' + node.uselib = 'RT EV OPENSSL CARES EXECINFO DL KVM SOCKET NSL UTIL OPROFILE' node.add_objects = 'eio http_parser' if product_type_is_lib: node.install_path = '${LIBDIR}'