-
-
Save ThreePointSquare/161833c35cf49552d5c6d3db8c2f7221 to your computer and use it in GitHub Desktop.
Getting system info (CPU, GPU, Memory and OS)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cpu": { | |
"model": "Intel Core i7", | |
"clockspeed": "2.8 Ghz", | |
"processors": 1, | |
"cores": 2 | |
}, | |
"memory": "16GB", | |
"gpu": { | |
"model": "Intel HD 3000", | |
"vram": "2GB", | |
"driver": "abc" // windows only, not set on mac | |
}, | |
"os": { | |
"name": "Mac", | |
"version": "OSX 10.9.1" | |
}, | |
"architecture": "64bit" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var os = require('os'); | |
var child_process = require('child_process'); | |
function parseFields(rawInfo) | |
{ | |
var info = {}; | |
// Software: | |
// System Version | |
// Hardware: | |
// Processor Name | |
// Processor Speed | |
// Number of Processors | |
// Total Number of Cores | |
// L2 Cache (per Core) | |
// L3 Cache | |
// Graphics/Displays: | |
// Memory | |
// Chipset Model | |
// VRAM (Total) | |
return info; | |
} | |
var command = child_process.exec( | |
'system_profiler SPDisplaysDataType SPHardwareDataType SPSoftwareDataType', | |
function(err, stdout, stderr) { | |
if (err) { | |
console.log('Error getting system information ' + err); | |
} | |
console.log(parseFields(stdout)); | |
} | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var os = require('os'); | |
var child_process = require('child_process'); | |
function parseFields(rawInfo) | |
{ | |
var rawInfo = rawInfo.toString().trim(); | |
var devices = []; | |
var sections = rawInfo.split(os.EOL + os.EOL); | |
for (var i in sections) { | |
devices.push({}); | |
var lines = sections[i].split(os.EOL); | |
for (var j in lines) { | |
var line = lines[j].split(':'); | |
var key = line[0]; | |
var value = line[1]; | |
devices[i][key] = value; | |
} | |
} | |
return devices; | |
} | |
// Graphics card info: | |
var command = child_process.exec( | |
'powershell.exe -Command \"Get-WmiObject Win32_Videocontroller | Select-Object -Property Caption,Description,Name,Videoprocessor,DriverVersion,AdapterRam | Format-List *\"', | |
function(err, stdout, stderr) { | |
if (err) { | |
console.log('Error getting Win32_Videocontroller ' + err); | |
return; | |
} | |
console.log('Win32_Videocontroller:'); | |
console.dir(parseFields(stdout)); | |
} | |
); | |
command.stdin.end(); | |
// Memory info: | |
var command = child_process.exec( | |
'powershell.exe -Command "Get-WmiObject Win32_PhysicalMemory | Select-Object -Property Caption,Description,BankLabel,Capacity,Speed,DataWidth | Format-List *"', | |
function(err, stdout, stderr) { | |
if (err) { | |
console.log('error getting Win32_PhysicalMemory'); | |
return; | |
} | |
console.log('Win32_PhysicalMemory:'); | |
console.dir(parseFields(stdout)); | |
} | |
); | |
command.stdin.end(); | |
// CPU info: | |
var command = child_process.exec( | |
'powershell.exe -Command "Get-WmiObject Win32_Processor | Select-Object -Property Caption,Description,AddressWidth,Architecture,DataWidth,DeviceID,Manufacturer,Name,NumberOfCores,NumberOfLogicalProcessors,MaxClockSpeed,L2CacheSize,L3CacheSize | Format-List *"', | |
function(err, stdout, stderr) { | |
if (err) { | |
console.log('error getting Win32_Processor'); | |
return; | |
} | |
console.log('Win32_Processor:'); | |
console.dir(parseFields(stdout)); | |
} | |
); | |
command.stdin.end(); | |
// Operating system info: | |
var command = child_process.exec( | |
'powershell.exe -Command "Get-WmiObject Win32_OperatingSystem | Select-Object -Property BuildNumber,Version | Format-List *"', | |
function(err, stdout, stderr) { | |
if (err) { | |
console.log('error getting Win32_OperatingSystem'); | |
return; | |
} | |
console.log('Win32_OperatingSystem:'); | |
console.dir(parseFields(stdout)); | |
} | |
); | |
command.stdin.end(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment