systeminformation
Advanced tools
Comparing version 3.21.0 to 3.22.0
@@ -98,2 +98,3 @@ # Changelog | ||
| -------------- | -------------- | -------- | | ||
| 3.22.0 | 2017-06-19 | extended windows support (`users`, `inetLatency`) | | ||
| 3.21.0 | 2017-06-18 | extended time (timezone), extended windows support (battery, getAll...) | | ||
@@ -100,0 +101,0 @@ | 3.20.1 | 2017-06-17 | updated docs | |
@@ -184,3 +184,3 @@ 'use strict'; | ||
let functionProcessed = (function () { | ||
let totalFunctions = (_windows ? 5 : 14); | ||
let totalFunctions = (_windows ? 7 : 14); | ||
@@ -224,8 +224,6 @@ return function () { | ||
if (!_windows) { | ||
users.users().then(res => { | ||
data.users = res; | ||
functionProcessed(); | ||
}); | ||
} | ||
users.users().then(res => { | ||
data.users = res; | ||
functionProcessed(); | ||
}); | ||
@@ -301,8 +299,6 @@ if (!_windows) { | ||
if (!_windows) { | ||
internet.inetLatency().then(res => { | ||
data.inetLatency = res; | ||
functionProcessed(); | ||
}); | ||
} | ||
internet.inetLatency().then(res => { | ||
data.inetLatency = res; | ||
functionProcessed(); | ||
}); | ||
}); | ||
@@ -309,0 +305,0 @@ }); |
@@ -82,25 +82,40 @@ 'use strict'; | ||
process.nextTick(() => { | ||
if (_windows) { | ||
let error = new Error(NOT_SUPPORTED); | ||
if (callback) { callback(NOT_SUPPORTED) } | ||
reject(error); | ||
} | ||
let t = Date.now(); | ||
let cmd; | ||
if (_linux) { | ||
cmd = "ping -c 2 -w 3 " + host + " | grep rtt | cut -d'/' -f4 | awk '{ print $3 }'"; | ||
if (_linux || _darwin) { | ||
if (_linux) { | ||
cmd = "ping -c 2 -w 3 " + host + " | grep rtt | cut -d'/' -f4 | awk '{ print $3 }'"; | ||
} | ||
if (_darwin) { | ||
cmd = "ping -c 2 -t 3 " + host + " | grep avg | cut -d'/' -f4 | awk '{ print $3 }'"; | ||
} | ||
exec(cmd, function (error, stdout) { | ||
let result = -1; | ||
if (!error) { | ||
result = parseFloat(stdout.toString()); | ||
} | ||
if (callback) { callback(result) } | ||
resolve(result); | ||
}) | ||
} | ||
if (_darwin) { | ||
cmd = "ping -c 2 -t 3 " + host + " | grep avg | cut -d'/' -f4 | awk '{ print $3 }'"; | ||
if (_windows) { | ||
exec('ping ' + host + ' -n 1', function (error, stdout) { | ||
let result = -1; | ||
if (!error) { | ||
let lines = stdout.toString().split('\r\n'); | ||
lines.shift(); | ||
lines.forEach(function (line) { | ||
if (line.toLowerCase().startsWith(' min')) { | ||
let l = line.replace(/ +/g, " ").split(' '); | ||
if (l.length > 8) { | ||
result = parseFloat(l[9]) | ||
} | ||
} | ||
}); | ||
} | ||
if (callback) { callback(result) } | ||
resolve(result); | ||
}) | ||
} | ||
exec(cmd, function (error, stdout) { | ||
let result = -1; | ||
if (!error) { | ||
result = parseFloat(stdout.toString()); | ||
} | ||
if (callback) { callback(result) } | ||
resolve(result); | ||
}) | ||
}); | ||
@@ -107,0 +122,0 @@ }); |
@@ -143,8 +143,2 @@ 'use strict'; | ||
process.nextTick(() => { | ||
if (_windows) { | ||
let error = new Error(NOT_SUPPORTED); | ||
if (callback) { callback(NOT_SUPPORTED) } | ||
reject(error); | ||
} | ||
let result = []; | ||
@@ -165,8 +159,5 @@ | ||
result = parseUsers1(lines); | ||
if (callback) { callback(result) } | ||
resolve(result); | ||
} else { | ||
if (callback) { callback(result) } | ||
resolve(result); | ||
} | ||
if (callback) { callback(result) } | ||
resolve(result); | ||
}); | ||
@@ -190,11 +181,31 @@ } else { | ||
result = parseUsers2(lines); | ||
if (callback) { callback(result) } | ||
resolve(result); | ||
} else { | ||
if (callback) { callback(result) } | ||
resolve(result); | ||
} | ||
if (callback) { callback(result) } | ||
resolve(result); | ||
}); | ||
} | ||
if (_windows) { | ||
exec("query user", function (error, stdout) { | ||
if (stdout) { | ||
// lines / split | ||
let lines = stdout.toString().split('\r\n'); | ||
lines.shift(); | ||
lines.forEach(function (line) { | ||
let l = line.replace(/ +/g, " ").split(' '); | ||
if (l.length >= 7) { | ||
result.push({ | ||
user: l[0].replace(/>/g, " "), | ||
tty: l[1], | ||
date: l[5].substr(6,4) + '-' + l[5].substr(3,2) + '-' + l[5].substr(0,2), | ||
time: l[4], | ||
ip: '', | ||
command: '' | ||
}) | ||
} | ||
}) | ||
} | ||
if (callback) { callback(result) } | ||
resolve(result); | ||
}); | ||
} | ||
@@ -201,0 +212,0 @@ }); |
{ | ||
"name": "systeminformation", | ||
"version": "3.21.0", | ||
"version": "3.22.0", | ||
"description": "Simple system and OS information library", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -45,2 +45,3 @@ # systeminformation | ||
- Version 3.22.0: extended windows support (`users`, `inetLatency`) | ||
- Version 3.21.0: extended `time` (timezone), extended windows support (`battery`, `getAll...`) | ||
@@ -196,7 +197,7 @@ - Version 3.20.0: added additional windows support (`cpu`, `cpuCache`, `cpuCurrentspeed`, `mem`, `networkInterfaces`, `docker`) | ||
| si.shell(cb) | : string | X | X | | standard shell | | ||
| si.users(cb) | [{...}] | X | X | | array of users online | | ||
| | [0].user | X | X | | user name | | ||
| | [0].tty | X | X | | terminal | | ||
| | [0].date | X | X | | login date | | ||
| | [0].time | X | X | | login time | | ||
| si.users(cb) | [{...}] | X | X | X | array of users online | | ||
| | [0].user | X | X | X | user name | | ||
| | [0].tty | X | X | X | terminal | | ||
| | [0].date | X | X | X | login date | | ||
| | [0].time | X | X | X | login time | | ||
| | [0].ip | X | X | | ip address (remote login) | | ||
@@ -277,3 +278,3 @@ | | [0].command | X | X | | last command or shell | | ||
| | ms | X | X | | response time in ms | | ||
| si.inetLatency(host, cb) | : number | X | X | | response-time (ms) to external resource<br>host parameter is optional (default 8.8.8.8)| | ||
| si.inetLatency(host, cb) | : number | X | X | X | response-time (ms) to external resource<br>host parameter is optional (default 8.8.8.8)| | ||
@@ -280,0 +281,0 @@ #### 7. Current Load, Processes & Services |
190827
4049
541