systeminformation 5.16.3 → 5.16.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/internet.js CHANGED
@@ -158,24 +158,20 @@ function inetLatency(host, callback) {
158
158
  return resolve(null);
159
159
  }
160
160
  let params;
161
- let filt;
162
161
  if (_linux || _freebsd || _openbsd || _netbsd || _darwin) {
163
162
  if (_linux) {
164
163
  params = ['-c', '2', '-w', '3', hostSanitized];
165
- filt = 'rtt';
166
164
  }
167
165
  if (_freebsd || _openbsd || _netbsd) {
168
166
  params = ['-c', '2', '-t', '3', hostSanitized];
169
- filt = 'round-trip';
170
167
  }
171
168
  if (_darwin) {
172
169
  params = ['-c2', '-t3', hostSanitized];
173
- filt = 'avg';
174
170
  }
175
171
  util.execSafe('ping', params).then((stdout) => {
176
172
  let result = null;
177
173
  if (stdout) {
178
- const lines = stdout.split('\n').filter(line => line.indexOf(filt) >= 0).join('\n');
174
+ const lines = stdout.split('\n').filter((line) => (line.indexOf('rtt') >= 0 || line.indexOf('round-trip') >= 0 || line.indexOf('avg') >= 0)).join('\n');
179
175
 
180
176
  const line = lines.split('=');
181
177
  if (line.length > 1) {
package/lib/processes.js CHANGED
@@ -655,7 +655,7 @@ function processes(callback) {
655
655
  function formatDateTime(time) {
656
656
  const month = ('0' + (time.getMonth() + 1).toString()).substr(-2);
657
657
  const year = time.getFullYear().toString();
658
- const day = ('0' + time.getDay().toString()).substr(-2);
658
+ const day = ('0' + time.getDate().toString()).substr(-2);
659
659
  const hours = time.getHours().toString();
660
660
  const mins = time.getMinutes().toString();
661
661
  const secs = ('0' + time.getSeconds().toString()).substr(-2);
@@ -663,6 +663,21 @@ function processes(callback) {
663
663
  return (year + '-' + month + '-' + day + ' ' + hours + ':' + mins + ':' + secs);
664
664
  }
665
665
 
666
+ function parseElapsed(etime) {
667
+ let started = '';
668
+ if (etime.indexOf('d') >= 0) {
669
+ const elapsed_parts = etime.split('d');
670
+ started = formatDateTime(new Date(Date.now() - (elapsed_parts[0] * 24 + elapsed_parts[1] * 1) * 60 * 60 * 1000));
671
+ } else if (etime.indexOf('h') >= 0) {
672
+ const elapsed_parts = etime.split('h');
673
+ started = formatDateTime(new Date(Date.now() - (elapsed_parts[0] * 60 + elapsed_parts[1] * 1) * 60 * 1000));
674
+ } else if (etime.indexOf(':') >= 0) {
675
+ const elapsed_parts = etime.split(':');
676
+ started = formatDateTime(new Date(Date.now() - (elapsed_parts.length > 1 ? (elapsed_parts[0] * 60 + elapsed_parts[1]) * 1000 : elapsed_parts[0] * 1000)));
677
+ }
678
+ return started;
679
+ }
680
+
666
681
  let result = [];
667
682
  lines.forEach(function (line) {
668
683
  if (line.trim() !== '') {
@@ -670,8 +685,7 @@ function processes(callback) {
670
685
  const parts = line.split(' ');
671
686
  const command = parts.slice(9).join(' ');
672
687
  const pmem = parseFloat((1.0 * parseInt(parts[3]) * 1024 / os.totalmem()).toFixed(1));
673
- const elapsed_parts = parts[5].split(':');
674
- const started = formatDateTime(new Date(Date.now() - (elapsed_parts.length > 1 ? (elapsed_parts[0] * 60 + elapsed_parts[1]) * 1000 : elapsed_parts[0] * 1000)));
688
+ const started = parseElapsed(parts[5]);
675
689
 
676
690
  result.push({
677
691
  pid: parseInt(parts[0]),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "systeminformation",
3
- "version": "5.16.3",
3
+ "version": "5.16.5",
4
4
  "description": "Advanced, lightweight system and OS information library",
5
5
  "license": "MIT",
6
6
  "author": "Sebastian Hildebrandt <hildebrandt@plus-innovations.com> (https://plus-innovations.com)",