|
@ -99,8 +99,7 @@ static inline char* _getProcessTitle() { |
|
|
if (GetLastError()) { |
|
|
if (GetLastError()) { |
|
|
_winapi_perror("GetConsoleTitleW"); |
|
|
_winapi_perror("GetConsoleTitleW"); |
|
|
return NULL; |
|
|
return NULL; |
|
|
} |
|
|
} else { |
|
|
else { |
|
|
|
|
|
// The title is empty, so return empty string
|
|
|
// The title is empty, so return empty string
|
|
|
process_title = strdup("\0"); |
|
|
process_title = strdup("\0"); |
|
|
return process_title; |
|
|
return process_title; |
|
@ -252,6 +251,7 @@ int Platform::GetExecutablePath(char* buffer, size_t* size) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
int Platform::GetCPUInfo(Local<Array> *cpus) { |
|
|
int Platform::GetCPUInfo(Local<Array> *cpus) { |
|
|
|
|
|
HandleScope scope; |
|
|
Local<Object> cpuinfo; |
|
|
Local<Object> cpuinfo; |
|
|
Local<Object> cputimes; |
|
|
Local<Object> cputimes; |
|
|
unsigned int ticks = (unsigned int)sysconf(_SC_CLK_TCK), |
|
|
unsigned int ticks = (unsigned int)sysconf(_SC_CLK_TCK), |
|
@ -285,14 +285,17 @@ int Platform::GetCPUInfo(Local<Array> *cpus) { |
|
|
|
|
|
|
|
|
if (fpStat) { |
|
|
if (fpStat) { |
|
|
while (fgets(line, 511, fpStat) != NULL) { |
|
|
while (fgets(line, 511, fpStat) != NULL) { |
|
|
if (strncmp(line, "cpu ", 4) == 0) |
|
|
if (strncmp(line, "cpu ", 4) == 0) { |
|
|
continue; |
|
|
continue; |
|
|
else if (strncmp(line, "intr ", 5) == 0) |
|
|
} else if (strncmp(line, "cpu", 3) != 0) { |
|
|
break; |
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
sscanf(line, "%*s %llu %llu %llu %llu", |
|
|
sscanf(line, "%*s %llu %llu %llu %llu", |
|
|
&ticks_user, &ticks_nice, &ticks_sys, &ticks_idle); |
|
|
&ticks_user, &ticks_nice, &ticks_sys, &ticks_idle); |
|
|
snprintf(speedPath, sizeof(speedPath), |
|
|
snprintf(speedPath, sizeof(speedPath), |
|
|
"/sys/devices/system/cpu/cpu%u/cpufreq/cpuinfo_max_freq", i); |
|
|
"/sys/devices/system/cpu/cpu%u/cpufreq/cpuinfo_max_freq", i); |
|
|
|
|
|
|
|
|
fpSpeed = fopen(speedPath, "r"); |
|
|
fpSpeed = fopen(speedPath, "r"); |
|
|
if (fpSpeed) { |
|
|
if (fpSpeed) { |
|
|
if (fgets(line, 511, fpSpeed) != NULL) { |
|
|
if (fgets(line, 511, fpSpeed) != NULL) { |
|
@ -355,4 +358,5 @@ int Platform::GetLoadAvg(Local<Array> *loads) { |
|
|
return -1; |
|
|
return -1; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace node
|
|
|
} // namespace node
|
|
|