systeminformation 5.16.2 → 5.16.4

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/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/lib/users.js CHANGED
@@ -209,7 +209,7 @@ function users(callback) {
209
209
  try {
210
210
  let cmd = 'Get-CimInstance Win32_LogonSession | select LogonId,@{n="StartTime";e={$_.StartTime.ToString("yyyy-MM-dd HH:mm:ss")}} | fl' + '; echo \'#-#-#-#\';';
211
211
  cmd += 'Get-CimInstance Win32_LoggedOnUser | select antecedent,dependent | fl ' + '; echo \'#-#-#-#\';';
212
- cmd += '$process = (Get-CimInstance Win32_Process -Filter "name = \'explorer.exe\'"); Invoke-CimMethod -InputObject $process -MethodName GetOwner | select user, domain | fl; get-process -name explorer | select-object sessionid | fl; echo \'#-#-#-#\';';
212
+ cmd += '$process = (Get-CimInstance Win32_Process -Filter "name = \'explorer.exe\'"); Invoke-CimMethod -InputObject $process[0] -MethodName GetOwner | select user, domain | fl; get-process -name explorer | select-object sessionid | fl; echo \'#-#-#-#\';';
213
213
  cmd += 'query user';
214
214
  util.powerShell(cmd).then((data) => {
215
215
  if (data) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "systeminformation",
3
- "version": "5.16.2",
3
+ "version": "5.16.4",
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)",