systeminformation 5.11.20 → 5.11.23

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/cpu.js CHANGED
@@ -1039,7 +1039,7 @@ function cpuTemperature(callback) {
1039
1039
  util.noop();
1040
1040
  }
1041
1041
 
1042
- const cmd = 'for mon in /sys/class/hwmon/hwmon*; do for label in "$mon"/temp*_label; do if [ -f $label ]; then value=$(echo $label | rev | cut -c 7- | rev)_input; if [ -f "$value" ]; then echo $(cat "$label")___$(cat "$value"); fi; fi; done; done;';
1042
+ const cmd = 'for mon in /sys/class/hwmon/hwmon*; do for label in "$mon"/temp*_label; do if [ -f $label ]; then value=${label%_*}_input; echo $(cat "$label")___$(cat "$value"); fi; done; done;';
1043
1043
  try {
1044
1044
  exec(cmd, function (error, stdout) {
1045
1045
  stdout = stdout.toString();
package/lib/filesystem.js CHANGED
@@ -49,12 +49,37 @@ function fsSize(callback) {
49
49
  return 'HFS';
50
50
  }
51
51
 
52
+ function isLinuxTmpFs(fs) {
53
+ const linuxTmpFileSystems = ['rootfs', 'unionfs', 'squashfs', 'cramfs', 'initrd', 'initramfs', 'devtmpfs', 'tmpfs', 'udev', 'devfs', 'specfs', 'type', 'appimaged', 'fuse.'];
54
+ let result = false;
55
+ linuxTmpFileSystems.forEach(linuxFs => {
56
+ if (fs.toLowerCase().indexOf(linuxFs) >= 0) result = true;
57
+ });
58
+ return result;
59
+ }
60
+
61
+ function filterLines(stdout) {
62
+ let lines = stdout.toString().split('\n');
63
+ if (stdout.toString().toLowerCase().indexOf('filesystem')) {
64
+ let removeLines = 0;
65
+ for (let i = 0; i < lines.length; i++) {
66
+ if (line[i] && lines[i].toLowerCase().startsWith('filesystem')) {
67
+ removeLines = i;
68
+ }
69
+ }
70
+ for (let i = 0; i < removeLines; i++) {
71
+ lines.shift();
72
+ }
73
+ }
74
+ return lines;
75
+ }
76
+
52
77
  function parseDf(lines) {
53
78
  let data = [];
54
79
  lines.forEach(function (line) {
55
80
  if (line !== '') {
56
81
  line = line.replace(/ +/g, ' ').split(' ');
57
- if (line && ((line[0].startsWith('/')) || (line[6] && line[6] === '/') || (line[0].indexOf('/') > 0) || (line[0].indexOf(':') === 1))) {
82
+ if (line && ((line[0].startsWith('/')) || (line[6] && line[6] === '/') || (line[0].indexOf('/') > 0) || (line[0].indexOf(':') === 1) || !_darwin && !isLinuxTmpFs(line[1]))) {
58
83
  const fs = line[0];
59
84
  const fsType = ((_linux || _freebsd || _openbsd || _netbsd) ? line[1] : getmacOsFsType(line[0]));
60
85
  const size = parseInt(((_linux || _freebsd || _openbsd || _netbsd) ? line[2] : line[1])) * 1024;
@@ -96,12 +121,12 @@ function fsSize(callback) {
96
121
  macOsDisks = [];
97
122
  }
98
123
  }
99
- if (_linux) { cmd = 'df -lkPTx squashfs | grep -E "^/|^.\\:"'; }
124
+ if (_linux) { cmd = 'df -lkPTx squashfs'; } // cmd = 'df -lkPTx squashfs | grep -E "^/|^.\\:"';
100
125
  if (_freebsd || _openbsd || _netbsd) { cmd = 'df -lkPT'; }
101
126
  exec(cmd, { maxBuffer: 1024 * 1024 }, function (error, stdout) {
102
- if (!error) {
103
- let lines = stdout.toString().split('\n');
104
- data = parseDf(lines);
127
+ let lines = filterLines(stdout);
128
+ data = parseDf(lines);
129
+ if (!error || data.length) {
105
130
  if (callback) {
106
131
  callback(data);
107
132
  }
@@ -109,7 +134,7 @@ function fsSize(callback) {
109
134
  } else {
110
135
  exec('df -kPT', { maxBuffer: 1024 * 1024 }, function (error, stdout) {
111
136
  if (!error) {
112
- let lines = stdout.toString().split('\n');
137
+ let lines = filterLines(stdout);
113
138
  data = parseDf(lines);
114
139
  }
115
140
  if (callback) {
package/lib/graphics.js CHANGED
@@ -429,7 +429,7 @@ function graphics(callback) {
429
429
  }
430
430
 
431
431
  const gpus = stdout.split('\n').filter(Boolean);
432
- const results = gpus.map(gpu => {
432
+ let results = gpus.map(gpu => {
433
433
  const splittedData = gpu.split(', ').map(value => value.includes('N/A') ? undefined : value);
434
434
  if (splittedData.length === 16) {
435
435
  return {
@@ -450,9 +450,13 @@ function graphics(callback) {
450
450
  clockCore: safeParseNumber(splittedData[14]),
451
451
  clockMemory: safeParseNumber(splittedData[15]),
452
452
  };
453
+ } else {
454
+ return {};
453
455
  }
454
456
  });
455
-
457
+ results = results.filter((item) => {
458
+ return ('pciBus' in item);
459
+ });
456
460
  return results;
457
461
  }
458
462
 
package/lib/index.d.ts CHANGED
@@ -7,8 +7,8 @@ export namespace Systeminformation {
7
7
  // 1. General
8
8
 
9
9
  interface TimeData {
10
- current: string;
11
- uptime: string;
10
+ current: number;
11
+ uptime: number;
12
12
  timezone: string;
13
13
  timezoneName: string;
14
14
  }
@@ -988,3 +988,6 @@ export function getDynamicData(srv?: string, iface?: string, cb?: (data: any) =>
988
988
  export function getAllData(srv?: string, iface?: string, cb?: (data: any) => any): Promise<any>;
989
989
  export function get(valuesObject: any, cb?: (data: any) => any): Promise<any>;
990
990
  export function observe(valuesObject: any, interval: number, cb?: (data: any) => any): number;
991
+
992
+ export function powerShellStart(): void;
993
+ export function powerShellRelease(): void;
package/lib/osinfo.js CHANGED
@@ -307,6 +307,7 @@ function osInfo(callback) {
307
307
  result.codename = (result.release.indexOf('10.15') > -1 ? 'macOS Catalina' : result.codename);
308
308
  result.codename = (result.release.startsWith('11.') ? 'macOS Big Sur' : result.codename);
309
309
  result.codename = (result.release.startsWith('12.') ? 'macOS Monterey' : result.codename);
310
+ result.codename = (result.release.startsWith('13.') ? 'macOS Ventura' : result.codename);
310
311
  result.uefi = true;
311
312
  result.codepage = util.getCodepage();
312
313
  if (callback) {
package/lib/processes.js CHANGED
@@ -88,6 +88,25 @@ function parseTimeUnix(time) {
88
88
  return result;
89
89
  }
90
90
 
91
+ function parseElapsedTime(etime) {
92
+ let current = new Date();
93
+ current = new Date(current.getTime() - current.getTimezoneOffset() * 60000);
94
+
95
+ const elapsed = etime.split('-');
96
+
97
+ const timeIndex = elapsed.length - 1;
98
+ const days = timeIndex > 0 ? parseInt(elapsed[timeIndex - 1]) : 0;
99
+
100
+ const timeStr = elapsed[timeIndex].split(':');
101
+ const hours = timeStr.length === 3 ? parseInt(timeStr[0] || 0) : 0;
102
+ const mins = parseInt(timeStr[timeStr.length === 3 ? 1 : 0] || 0);
103
+ const secs = parseInt(timeStr[timeStr.length === 3 ? 2 : 1] || 0);
104
+ const ms = (((((days * 24 + hours) * 60) + mins) * 60 + secs) * 1000);
105
+
106
+ const res = new Date(current.getTime() - ms);
107
+ return res.toISOString().substring(0, 10) + ' ' + res.toISOString().substring(11, 19);
108
+ }
109
+
91
110
  // --------------------------
92
111
  // PS - services
93
112
  // pass a comma separated string with services to check (mysql, apache, postgresql, ...)
@@ -550,7 +569,7 @@ function processes(callback) {
550
569
  checkColumn(7);
551
570
  const nice = parseInt(line.substring(parsedhead[7].from + offset, parsedhead[7].to + offset2)) || 0;
552
571
  checkColumn(8);
553
- const started = parseTimeUnix(line.substring(parsedhead[8].from + offset, parsedhead[8].to + offset2).trim());
572
+ const started = !_sunos ? parseElapsedTime(line.substring(parsedhead[8].from + offset, parsedhead[8].to + offset2).trim()) : parseTimeUnix(line.substring(parsedhead[8].from + offset, parsedhead[8].to + offset2).trim());
554
573
  checkColumn(9);
555
574
  let state = line.substring(parsedhead[9].from + offset, parsedhead[9].to + offset2).trim();
556
575
  state = (state[0] === 'R' ? 'running' : (state[0] === 'S' ? 'sleeping' : (state[0] === 'T' ? 'stopped' : (state[0] === 'W' ? 'paging' : (state[0] === 'X' ? 'dead' : (state[0] === 'Z' ? 'zombie' : ((state[0] === 'D' || state[0] === 'U') ? 'blocked' : 'unknown')))))));
@@ -567,33 +586,48 @@ function processes(callback) {
567
586
  if (fullcommand.substr(fullcommand.length - 1) === ']') { fullcommand = fullcommand.slice(0, -1); }
568
587
  if (fullcommand.substr(0, 1) === '[') { command = fullcommand.substring(1); }
569
588
  else {
570
- // try to figure out where parameter starts
571
- let firstParamPos = fullcommand.indexOf(' -');
572
- let firstParamPathPos = fullcommand.indexOf(' /');
573
- firstParamPos = (firstParamPos >= 0 ? firstParamPos : 10000);
574
- firstParamPathPos = (firstParamPathPos >= 0 ? firstParamPathPos : 10000);
575
- const firstPos = Math.min(firstParamPos, firstParamPathPos);
576
- let tmpCommand = fullcommand.substr(0, firstPos);
577
- const tmpParams = fullcommand.substr(firstPos);
578
- const lastSlashPos = tmpCommand.lastIndexOf('/');
579
- if (lastSlashPos >= 0) {
580
- cmdPath = tmpCommand.substr(0, lastSlashPos);
581
- tmpCommand = tmpCommand.substr(lastSlashPos + 1);
582
- }
583
-
584
- if (firstPos === 10000 && tmpCommand.indexOf(' ') > -1) {
585
- const parts = tmpCommand.split(' ');
586
- if (fs.existsSync(path.join(cmdPath, parts[0]))) {
587
- command = parts.shift();
588
- params = (parts.join(' ') + ' ' + tmpParams).trim();
589
+ const p1 = fullcommand.indexOf('(');
590
+ const p2 = fullcommand.indexOf(')');
591
+ const p3 = fullcommand.indexOf('/');
592
+ const p4 = fullcommand.indexOf(':');
593
+ if (p1 < p2 && p1 < p3 && p3 < p2) {
594
+ command = fullcommand.split(' ')[0];
595
+ command = command.replace(/:/g, '');
596
+ } else {
597
+ if (p4 > 0 && (p3 === -1 || p3 > 3)) {
598
+ command = fullcommand.split(' ')[0];
599
+ command = command.replace(/:/g, '');
589
600
  } else {
590
- command = tmpCommand.trim();
591
- params = tmpParams.trim();
601
+ // try to figure out where parameter starts
602
+ let firstParamPos = fullcommand.indexOf(' -');
603
+ let firstParamPathPos = fullcommand.indexOf(' /');
604
+ firstParamPos = (firstParamPos >= 0 ? firstParamPos : 10000);
605
+ firstParamPathPos = (firstParamPathPos >= 0 ? firstParamPathPos : 10000);
606
+ const firstPos = Math.min(firstParamPos, firstParamPathPos);
607
+ let tmpCommand = fullcommand.substr(0, firstPos);
608
+ const tmpParams = fullcommand.substr(firstPos);
609
+ const lastSlashPos = tmpCommand.lastIndexOf('/');
610
+ if (lastSlashPos >= 0) {
611
+ cmdPath = tmpCommand.substr(0, lastSlashPos);
612
+ tmpCommand = tmpCommand.substr(lastSlashPos + 1);
613
+ }
614
+
615
+ if (firstPos === 10000 && tmpCommand.indexOf(' ') > -1) {
616
+ const parts = tmpCommand.split(' ');
617
+ if (fs.existsSync(path.join(cmdPath, parts[0]))) {
618
+ command = parts.shift();
619
+ params = (parts.join(' ') + ' ' + tmpParams).trim();
620
+ } else {
621
+ command = tmpCommand.trim();
622
+ params = tmpParams.trim();
623
+ }
624
+ } else {
625
+ command = tmpCommand.trim();
626
+ params = tmpParams.trim();
627
+ }
592
628
  }
593
- } else {
594
- command = tmpCommand.trim();
595
- params = tmpParams.trim();
596
629
  }
630
+
597
631
  }
598
632
 
599
633
  return ({
@@ -693,9 +727,9 @@ function processes(callback) {
693
727
 
694
728
  if ((_processes_cpu.ms && Date.now() - _processes_cpu.ms >= 500) || _processes_cpu.ms === 0) {
695
729
  if (_linux || _freebsd || _openbsd || _netbsd || _darwin || _sunos) {
696
- if (_linux) { cmd = 'export LC_ALL=C; ps -axo pid:11,ppid:11,pcpu:6,pmem:6,pri:5,vsz:11,rss:11,ni:5,lstart:30,state:5,tty:15,user:20,command; unset LC_ALL'; }
697
- if (_freebsd || _openbsd || _netbsd) { cmd = 'export LC_ALL=C; ps -axo pid,ppid,pcpu,pmem,pri,vsz,rss,ni,lstart,state,tty,user,command; unset LC_ALL'; }
698
- if (_darwin) { cmd = 'ps -axo pid,ppid,pcpu,pmem,pri,vsz=xxx_fake_title,rss=fake_title2,nice,lstart,state,tty,user,command -r'; }
730
+ if (_linux) { cmd = 'export LC_ALL=C; ps -axo pid:11,ppid:11,pcpu:6,pmem:6,pri:5,vsz:11,rss:11,ni:5,etime:30,state:5,tty:15,user:20,command; unset LC_ALL'; }
731
+ if (_freebsd || _openbsd || _netbsd) { cmd = 'export LC_ALL=C; ps -axo pid,ppid,pcpu,pmem,pri,vsz,rss,ni,etime,state,tty,user,command; unset LC_ALL'; }
732
+ if (_darwin) { cmd = 'ps -axo pid,ppid,pcpu,pmem,pri,vsz=temp_title_1,rss=temp_title_2,nice,etime=temp_title_3,state,tty,user,command -r'; }
699
733
  if (_sunos) { cmd = 'ps -Ao pid,ppid,pcpu,pmem,pri,vsz,rss,nice,stime,s,tty,user,comm'; }
700
734
  exec(cmd, { maxBuffer: 1024 * 20000 }, function (error, stdout) {
701
735
  if (!error && stdout.toString().trim()) {
package/lib/system.js CHANGED
@@ -662,8 +662,10 @@ function baseboard(callback) {
662
662
  if (_windows) {
663
663
  try {
664
664
  const workload = [];
665
+ const win10plus = parseInt(os.release()) >= 10;
666
+ const maxCapacityAttribute = win10plus ? 'MaxCapacityEx' : 'MaxCapacity';
665
667
  workload.push(util.powerShell('Get-WmiObject Win32_baseboard | select Model,Manufacturer,Product,Version,SerialNumber,PartNumber,SKU | fl'));
666
- workload.push(util.powerShell('Get-WmiObject Win32_physicalmemoryarray | select MaxCapacity, MemoryDevices | fl'));
668
+ workload.push(util.powerShell(`Get-WmiObject Win32_physicalmemoryarray | select ${maxCapacityAttribute}, MemoryDevices | fl`));
667
669
  util.promiseAll(
668
670
  workload
669
671
  ).then(data => {
@@ -683,7 +685,7 @@ function baseboard(callback) {
683
685
 
684
686
  // memphysical
685
687
  lines = data.results[1] ? data.results[1].toString().split('\r\n') : [''];
686
- result.memMax = util.toInt(util.getValue(lines, 'MaxCapacity', ':')) || null;
688
+ result.memMax = util.toInt(util.getValue(lines, maxCapacityAttribute, ':')) * (win10plus ? 1024 : 1) || null;
687
689
  result.memSlots = util.toInt(util.getValue(lines, 'MemoryDevices', ':')) || null;
688
690
 
689
691
  if (callback) { callback(result); }
package/lib/util.js CHANGED
@@ -396,42 +396,47 @@ function powerShellProceedResults(data) {
396
396
  }
397
397
 
398
398
  function powerShellStart() {
399
- _psChild = spawn('powershell.exe', ['-NoLogo', '-InputFormat', 'Text', '-NoExit', '-Command', '-'], {
400
- stdio: 'pipe',
401
- windowsHide: true,
402
- maxBuffer: 1024 * 20000,
403
- encoding: 'UTF-8',
404
- env: util._extend({}, process.env, { LANG: 'en_US.UTF-8' })
405
- });
406
- if (_psChild && _psChild.pid) {
407
- _psPersistent = true;
408
- _psChild.stdout.on('data', function (data) {
409
- _psResult = _psResult + data.toString('utf8');
410
- if (data.indexOf(_psCmdSeperator) >= 0) {
411
- powerShellProceedResults(_psResult);
412
- _psResult = '';
413
- }
414
- });
415
- _psChild.stderr.on('data', function () {
416
- powerShellProceedResults(_psResult + _psError);
417
- });
418
- _psChild.on('error', function () {
419
- powerShellProceedResults(_psResult + _psError);
420
- });
421
- _psChild.on('close', function () {
422
- _psChild.kill();
399
+ if (!_psChild) {
400
+ _psChild = spawn('powershell.exe', ['-NoLogo', '-InputFormat', 'Text', '-NoExit', '-Command', '-'], {
401
+ stdio: 'pipe',
402
+ windowsHide: true,
403
+ maxBuffer: 1024 * 20000,
404
+ encoding: 'UTF-8',
405
+ env: util._extend({}, process.env, { LANG: 'en_US.UTF-8' })
423
406
  });
407
+ if (_psChild && _psChild.pid) {
408
+ _psPersistent = true;
409
+ _psChild.stdout.on('data', function (data) {
410
+ _psResult = _psResult + data.toString('utf8');
411
+ if (data.indexOf(_psCmdSeperator) >= 0) {
412
+ powerShellProceedResults(_psResult);
413
+ _psResult = '';
414
+ }
415
+ });
416
+ _psChild.stderr.on('data', function () {
417
+ powerShellProceedResults(_psResult + _psError);
418
+ });
419
+ _psChild.on('error', function () {
420
+ powerShellProceedResults(_psResult + _psError);
421
+ });
422
+ _psChild.on('close', function () {
423
+ _psChild.kill();
424
+ });
425
+ }
424
426
  }
425
427
  }
426
428
 
427
429
  function powerShellRelease() {
428
430
  try {
429
- _psChild.stdin.write('exit' + os.EOL);
430
- _psChild.stdin.end();
431
- _psPersistent = false;
431
+ if (_psChild) {
432
+ _psChild.stdin.write('exit' + os.EOL);
433
+ _psChild.stdin.end();
434
+ _psPersistent = false;
435
+ }
432
436
  } catch (e) {
433
437
  _psChild.kill();
434
438
  }
439
+ _psChild = null;
435
440
  }
436
441
 
437
442
  function powerShell(cmd) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "systeminformation",
3
- "version": "5.11.20",
3
+ "version": "5.11.23",
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)",