Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows most specs are blank #868

Open
thororen1234 opened this issue Nov 19, 2023 · 22 comments
Open

Windows most specs are blank #868

thororen1234 opened this issue Nov 19, 2023 · 22 comments

Comments

@thororen1234
Copy link

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:
Used this to test the package
si.cpu()
.then(data => console.log(data))
.catch(error => console.error(error));

Current Output
If applicable, add output to help explain your problem.

{
  manufacturer: '',
  brand: '',
  vendor: '',
  family: '',
  model: '',
  stepping: '',
  revision: '',
  voltage: '',
  speed: NaN,
  speedMin: NaN,
  speedMax: NaN,
  governor: '',
  cores: 20,
  physicalCores: 20,
  performanceCores: 20,
  efficiencyCores: 0,
  processors: 1,
  socket: '',
  flags: 'de pse mce sep mtrr mca cmov psn clfsh ds mmx fxsr sse sse2 ss htt tm ia64 pbe',
  virtualization: true,
  cache: { l1d: 0, l1i: 0, l2: 0, l3: 0 }
}

Expected behavior
A clear and concise description of what you expected to happen.
I would expect the specs to be filled in properly so I can use this on a project.

Environment (please complete the following information):

  • systeminformation package version: 5.21.17
  • OS: [e.g. macOS] Windows 11
  • Hardware [e.g. MacBook Pro 13] I7-12700F - RTX 3070

To get all needed environment information, please run the following command:

  npx systeminformation info
Operating System:
──────────────────────────────────────────────────────────────────────────────────────────
Platform         : Windows
Distro           :
Release          : 10.0.22631
Codename         :
Kernel           : 10.0.22631
Arch             : x64
Hostname         : DESKTOP-41ERLGH
Codepage         : 437
Build            :
Hypervisor       : true
RemoteSession    :

System:
──────────────────────────────────────────────────────────────────────────────────────────
Manufacturer     :
Model            :
Version          :
Virtual          :

CPU:
──────────────────────────────────────────────────────────────────────────────────────────
Manufacturer     :
Brand            :
Family           :
Model            :
Stepping         :
Speed            :
Cores            : 20
PhysicalCores    : 20
PerformanceCores : 20
EfficiencyCores  :
Processors       : 1
Socket           :

Additional context
Add any other context about the problem here.

@thororen1234 thororen1234 changed the title Every Spec is blank Windows most specs are blank Nov 19, 2023
@sebhildebrandt
Copy link
Owner

@thororen1234 ok, this is strange ...

Can you run the following commands In Powershell:

Get-CimInstance Win32_processor | select Name, Revision, L2CacheSize, L3CacheSize, Manufacturer, MaxClockSpeed, Description, UpgradeMethod, Caption, NumberOfLogicalProcessors, NumberOfCores | fl
Get-CimInstance Win32_CacheMemory | select CacheType,InstalledSize,Level | fl
(Get-CimInstance Win32_ComputerSystem).HypervisorPresent

and post results as text here? Thank you in advance!

@thororen1234
Copy link
Author

@sebhildebrandt
1

Name                      : 12th Gen Intel(R) Core(TM) i7-12700F
Revision                  :
L2CacheSize               : 12288
L3CacheSize               : 25600
Manufacturer              : GenuineIntel
MaxClockSpeed             : 2100
Description               : Intel64 Family 6 Model 151 Stepping 2
UpgradeMethod             : 1
Caption                   : Intel64 Family 6 Model 151 Stepping 2
NumberOfLogicalProcessors : 20
NumberOfCores             : 12

2

CacheType     : 4
InstalledSize : 384
Level         : 3

CacheType     : 3
InstalledSize : 256
Level         : 3

CacheType     : 5
InstalledSize : 10240
Level         : 4

CacheType     : 5
InstalledSize : 25600
Level         : 5

CacheType     : 4
InstalledSize : 128
Level         : 3

CacheType     : 3
InstalledSize : 256
Level         : 3

CacheType     : 5
InstalledSize : 2048
Level         : 4

CacheType     : 5
InstalledSize : 25600
Level         : 5

3

True

@sebhildebrandt
Copy link
Owner

sebhildebrandt commented Nov 19, 2023

@thororen1234 this is interesting again, so all data seems to be there and we need to find out where it stops within the systeminformation code base. Would it be possible for you to go into the node_modules/systeminformation/lib folder and edit the code of cpu.js to add some console.logs

From line 879 ff ... can you add:

            Promise.all(
              workload
            ).then((data) => {
              console.log(data[0]);
              console.log(data[1]);
              console.log(data[2]);
              let lines = data[0].split('\r\n');

Then run you original code

si.cpu()
   .then(data => console.log(data))
   .catch(error => console.error(error));

@thororen1234
Copy link
Author

@sebhildebrandt
your console log




















True

{
  manufacturer: '',
  brand: '',
  vendor: '',
  family: '',
  model: '',
  stepping: '',
  revision: '',
  voltage: '',
  speed: NaN,
  speedMin: NaN,
  speedMax: NaN,
  governor: '',
  cores: 20,
  physicalCores: 20,
  performanceCores: 20,
  efficiencyCores: 0,
  processors: 1,
  socket: '',
  flags: 'de pse mce sep mtrr mca cmov psn clfsh ds mmx fxsr sse sse2 ss htt tm ia64 pbe',
  virtualization: true,
  cache: { l1d: 0, l1i: 0, l2: 0, l3: 0 }
}

mine

[
  '\r\n\r\n\r\n\r\n\r\n',
  '\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n',
  'True\r\n'
]
{
  manufacturer: '',
  brand: '',
  vendor: '',
  family: '',
  model: '',
  stepping: '',
  revision: '',
  voltage: '',
  speed: NaN,
  speedMin: NaN,
  speedMax: NaN,
  governor: '',
  cores: 20,
  physicalCores: 20,
  performanceCores: 20,
  efficiencyCores: 0,
  processors: 1,
  socket: '',
  flags: 'de pse mce sep mtrr mca cmov psn clfsh ds mmx fxsr sse sse2 ss htt tm ia64 pbe',
  virtualization: true,
  cache: { l1d: 0, l1i: 0, l2: 0, l3: 0 }
}

@thororen1234
Copy link
Author

thororen1234 commented Nov 19, 2023

here is memlayout, mem, and graphics as they are also blank

memlayout:

[]

memory

{
  total: 34163994624,
  free: 18208686080,
  used: 15955312640,
  active: 15955320832,
  available: 18208677888,
  buffers: 0,
  cached: 0,
  slab: 0,
  buffcache: 0,
  swaptotal: 0,
  swapused: 0,
  swapfree: 0,
  writeback: null,
  dirty: null
}

graphics:

{
  controllers: [],
  displays: [
    {
      vendor: '',
      model: '',
      main: true,
      sizeX: null,
      sizeY: null,
      resolutionX: 0,
      resolutionY: 0,
      pixelDepth: null,
      currentResX: 0,
      currentResY: 0,
      positionX: 0,
      positionY: 0
    }
  ]
}

@sebhildebrandt
Copy link
Owner

@thororen1234 so it seems that from inside node.js the first two commands did not returned anything ...

And having a look at your first post ... si.system() and si.cpu() did not returned values, si.osInfo() at least returned some values ... I need to check it again tomorrow on my machines ... but I am sure, I cannot reproduce this...

@thororen1234
Copy link
Author

@sebhildebrandt switched it to powershell 7 and now I have some stuff

3: True

2:
CacheType     : 4
InstalledSize : 384
Level         : 3

CacheType     : 3
InstalledSize : 256
Level         : 3

CacheType     : 5
InstalledSize : 10240
Level         : 4

CacheType     : 5
InstalledSize : 25600
Level         : 5

CacheType     : 4
InstalledSize : 128
Level         : 3

CacheType     : 3
InstalledSize : 256
Level         : 3

CacheType     : 5
InstalledSize : 2048
Level         : 4

CacheType     : 5
InstalledSize : 25600
Level         : 5


1:
Name                      : 12th Gen Intel(R) Core(TM) i7-12700F
Revision                  :
L2CacheSize               : 12288
L3CacheSize               : 25600
Manufacturer              : GenuineIntel
MaxClockSpeed             : 2100
Description               : Intel64 Family 6 Model 151 Stepping 2
UpgradeMethod             : 1
Caption                   : Intel64 Family 6 Model 151 Stepping 2
NumberOfLogicalProcessors : 20
NumberOfCores             : 12


[
  '\r\n' +
    '\x1B[32;1mName                      : \x1B[0m12th Gen Intel(R) Core(TM) i7-12700F\r\n' +
    '\x1B[32;1mRevision                  : \x1B[0m\r\n' +
    '\x1B[32;1mL2CacheSize               : \x1B[0m12288\r\n' +
    '\x1B[32;1mL3CacheSize               : \x1B[0m25600\r\n' +
    '\x1B[32;1mManufacturer              : \x1B[0mGenuineIntel\r\n' +
    '\x1B[32;1mMaxClockSpeed             : \x1B[0m2100\r\n' +
    '\x1B[32;1mDescription               : \x1B[0mIntel64 Family 6 Model 151 Stepping 2\r\n' +
    '\x1B[32;1mUpgradeMethod             : \x1B[0m1\r\n' +
    '\x1B[32;1mCaption                   : \x1B[0mIntel64 Family 6 Model 151 Stepping 2\r\n' +
    '\x1B[32;1mNumberOfLogicalProcessors : \x1B[0m20\r\n' +
    '\x1B[32;1mNumberOfCores             : \x1B[0m12\r\n' +
    '\r\n',
  '\r\n' +
    '\x1B[32;1mCacheType     : \x1B[0m4\r\n' +
    '\x1B[32;1mInstalledSize : \x1B[0m384\r\n' +
    '\x1B[32;1mLevel         : \x1B[0m3\r\n' +
    '\r\n' +
    '\x1B[32;1mCacheType     : \x1B[0m3\r\n' +
    '\x1B[32;1mInstalledSize : \x1B[0m256\r\n' +
    '\x1B[32;1mLevel         : \x1B[0m3\r\n' +
    '\r\n' +
    '\x1B[32;1mCacheType     : \x1B[0m5\r\n' +
    '\x1B[32;1mInstalledSize : \x1B[0m10240\r\n' +
    '\x1B[32;1mLevel         : \x1B[0m4\r\n' +
    '\r\n' +
    '\x1B[32;1mCacheType     : \x1B[0m5\r\n' +
    '\x1B[32;1mInstalledSize : \x1B[0m25600\r\n' +
    '\x1B[32;1mLevel         : \x1B[0m5\r\n' +
    '\r\n' +
    '\x1B[32;1mCacheType     : \x1B[0m4\r\n' +
    '\x1B[32;1mInstalledSize : \x1B[0m128\r\n' +
    '\x1B[32;1mLevel         : \x1B[0m3\r\n' +
    '\r\n' +
    '\x1B[32;1mCacheType     : \x1B[0m3\r\n' +
    '\x1B[32;1mInstalledSize : \x1B[0m256\r\n' +
    '\x1B[32;1mLevel         : \x1B[0m3\r\n' +
    '\r\n' +
    '\x1B[32;1mCacheType     : \x1B[0m5\r\n' +
    '\x1B[32;1mInstalledSize : \x1B[0m2048\r\n' +
    '\x1B[32;1mLevel         : \x1B[0m4\r\n' +
    '\r\n' +
    '\x1B[32;1mCacheType     : \x1B[0m5\r\n' +
    '\x1B[32;1mInstalledSize : \x1B[0m25600\r\n' +
    '\x1B[32;1mLevel         : \x1B[0m5\r\n' +
    '\r\n',
  'True\r\n'
]

@sebhildebrandt
Copy link
Owner

@thororen1234

  • what powershell version you used before?
  • can you also post new output of si.cpu()?

@thororen1234
Copy link
Author

I was using 5.1.22621.2506 and the output is still blank but I have noticed that \x1B[32;1mName works to get the name but Name or name wont work

@thororen1234
Copy link
Author

@sebhildebrandt still not fixed but I did get it all done manually with lines of code.

@thororen1234
Copy link
Author

I still don't understand why the console.log has the values but the actual specs are blank for yours

@thororen1234
Copy link
Author

thororen1234 commented Nov 25, 2023

to get anything to work I had to do let lines = data[0].replace('\x1B[0m', `'`).replaceAll('\x1B[0m', '').split('\r\n' + '\x1B[32;1m');
the first replace just for Name: and then replaceall for the rest

@sebhildebrandt
Copy link
Owner

sebhildebrandt commented Nov 25, 2023

@thororen1234 ... two questions:

  • what line did you change?
  • what is this for a character \x1B[0m?

As I cannot see this on my machine, I need to understand where this char comes from

@thororen1234
Copy link
Author

@sebhildebrandt
1: 886
2: THIS \x1B[0m THIS 12th Gen Intel(R) Core(TM) i7-12700F

@sebhildebrandt
Copy link
Owner

@thororen1234 ... so did you enabled some kind of color coding for your console?

I am sure, this is where this comes from but this seems to be unique to your environment.

@thororen1234
Copy link
Author

To my knowledge I didn't but ill look into it right now

@thororen1234
Copy link
Author

@sebhildebrandt cant find anything to do with color coding on my powershell

@sebhildebrandt
Copy link
Owner

@thororen1234 ... can you try the following on a fresh cloned systeminfo repo

in lib/utils.js can you replace the function powershell() (line 424ff) with

function powerShell(cmd) {

  const pattern = [
    '[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)',
    '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))'
  ].join('|');

  if (_psPersistent) {
    const id = Math.random().toString(36).substring(2, 12);
    return new Promise((resolve) => {
      process.nextTick(() => {
        function callback(data) {
          resolve(data);
        }
        _psCmds.push({
          id,
          cmd,
          callback,
          start: new Date()
        });
        try {
          if (_psChild && _psChild.pid) {
            _psChild.stdin.write(_psToUTF8 + 'echo ' + _psCmdStart + id + _psIdSeperator + '; ' + os.EOL + cmd + os.EOL + 'echo ' + _psCmdSeperator + os.EOL);
          }
        } catch (e) {
          resolve('');
        }
      });
    });

  } else {
    let result = '';

    return new Promise((resolve) => {
      process.nextTick(() => {
        try {
          const child = spawn('powershell.exe', ['-NoProfile', '-NoLogo', '-InputFormat', 'Text', '-NoExit', '-ExecutionPolicy', 'Unrestricted', '-Command', '-'], {
            stdio: 'pipe',
            windowsHide: true,
            maxBuffer: 1024 * 20000,
            encoding: 'UTF-8',
            env: util._extend({}, process.env, { LANG: 'en_US.UTF-8' })
          });

          if (child && !child.pid) {
            child.on('error', function () {
              resolve(result);
            });
          }
          if (child && child.pid) {
            child.stdout.on('data', function (data) {
              result = result + data.toString('utf8').replace(pattern, '');
            });
            child.stderr.on('data', function () {
              child.kill();
              resolve(result);
            });
            child.on('close', function () {
              child.kill();

              resolve(result);
            });
            child.on('error', function () {
              child.kill();
              resolve(result);
            });
            try {
              child.stdin.write(_psToUTF8 + cmd + os.EOL);
              child.stdin.write('exit' + os.EOL);
              child.stdin.end();
            } catch (e) {
              child.kill();
              resolve(result);
            }
          } else {
            resolve(result);
          }
        } catch (e) {
          resolve(result);
        }
      });
    });
  }
}

This should remove all ansi color coding ... and then all should work also on your side.

If you then start

npm run test 

and go through all functions (c for cpu, ...) does this give back proper results??

If this really works, I need to find out WHY we have color codings now...

@thororen1234
Copy link
Author

@sebhildebrandt nothing is returned correctly besides what was correct before

@sebhildebrandt
Copy link
Owner

@thororen1234 all really strange ... need to get deeper into in the next days on my machines ... Will contact you again, if I habe any idea.

@thororen1234
Copy link
Author

sounds good thanks

@thororen1234
Copy link
Author

Any news @sebhildebrandt?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants