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

processLoad('*') hanging #929

Open
imbdb opened this issue Aug 21, 2024 · 11 comments
Open

processLoad('*') hanging #929

imbdb opened this issue Aug 21, 2024 · 11 comments

Comments

@imbdb
Copy link

imbdb commented Aug 21, 2024

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

To Reproduce
Steps to reproduce the behavior:

  1. used function: processLoad('*')
  2. code snippet
let si = require('systeminformation');
si.processLoad('*').then( v => console.log(v))
  1. start app / code
  2. See output/error '....'

Current Output
No output, it just keeps waiting.

Expected behavior
It should return list of all the current processes

Environment (please complete the following information):

  • systeminformation package version: 5.17.13
  • OS: linux
  • Hardware: m6g.large aws instance
@sebhildebrandt
Copy link
Owner

@imbdb what linux distribution are you using?

And, what is the output of

ps -axo pid,ppid,pcpu,pmem,comm

on this machine (console)

@imbdb
Copy link
Author

imbdb commented Aug 21, 2024

Operating System:
─────────────────────────────────
Platform         : linux
Distro           : Ubuntu
Release          : 22.04.4 LTS
Codename         : jammy
Kernel           : 6.5.0-1015-aws
Arch             : arm64

Truncated output of
ps -axo pid,ppid,pcpu,pmem,comm

    PID    PPID %CPU %MEM COMMAND
      1       0  1.3  0.1 systemd
      2       0  0.0  0.0 kthreadd
      3       2  0.0  0.0 rcu_gp
      4       2  0.0  0.0 rcu_par_gp
      5       2  0.0  0.0 slub_flushwq
      6       2  0.0  0.0 netns
      8       2  0.0  0.0 kworker/0:0H-events_highpri
      9       2  0.0  0.0 kworker/0:1-inode_switch_wbs
     10       2  0.0  0.0 kworker/u4:0-ext4-rsv-conversion
     11       2  0.0  0.0 mm_percpu_wq
     12       2  0.0  0.0 rcu_tasks_rude_kthread
     13       2  0.0  0.0 rcu_tasks_trace_kthread

@sebhildebrandt
Copy link
Owner

@imbdb can you test the latest version 5.23.5?

@imbdb
Copy link
Author

imbdb commented Aug 22, 2024

The function is returning a value now. For some reason, I thought it would return the process list, but it returned a single element in the array.

[
  {
    proc: '',
    pid: 0,
    pids: [
         0,    4,  
      ... 546 more items
    ],
    cpu: 99.99999999999963,
    mem: 84.50729697417735
  }
]

I think it would be better to use the processes function instead, right?

@imbdb imbdb closed this as completed Aug 22, 2024
@sebhildebrandt
Copy link
Owner

sebhildebrandt commented Aug 22, 2024

@imbdb ... well it SHOULD return an array of all processes. I testet it on a machine running the same os:

Platform         : linux
Distro           : Ubuntu
Release          : 22.04.3 LTS
Codename         : jammy

This is the code I am running:

let si = require('systeminformation');
si.processLoad('*').then( v => console.log(v))

And here what It returns on my side (truncated):

[
  { proc: 'systemd', pid: 1, pids: [ 1 ], cpu: 0, mem: 0 },
  { proc: 'kthreadd', pid: 2, pids: [ 2 ], cpu: 0, mem: 0 },
  { proc: 'rcu_gp', pid: 3, pids: [ 3 ], cpu: 0, mem: 0 },
  { proc: 'rcu_par_gp', pid: 4, pids: [ 4 ], cpu: 0, mem: 0 },
  { proc: 'slub_flushwq', pid: 5, pids: [ 5 ], cpu: 0, mem: 0 },
  { proc: 'netns', pid: 6, pids: [ 6 ], cpu: 0, mem: 0 },
  {
    proc: 'kworker',
    pid: 3710814,
    pids: [
            8,      24,      30,      36,      42,      48,
           54,      60,      66,      72,      78,      84,
           90,      96,     102,     108,     176,     212,
          240,     256,     305,     308,     311,     314,
          316,     318,     335,     373,     445,     507,
          536,     545,     567, 2886818, 2966220, 3064270,
      3098483, 3239607, 3331446, 3360939, 3386264, 3390085,
      3476770, 3511405, 3576747, 3585047, 3598985, 3600025,
      3602953, 3611411, 3642134, 3642299, 3671666, 3678637,
      3679710, 3679727, 3690006, 3696258, 3696745, 3699178,
      3699179, 3699468, 3700659, 3704186, 3708115, 3708794,
      3709638, 3710360, 3710631, 3710814
    ],
    cpu: 0,
    mem: 0
  },
  ...
]

Hmmmm ... I reopened the ticket ...

@sebhildebrandt
Copy link
Owner

@imbdb is there any chance, that you can help with debugging? That would mean adding certain console.log into the systeminformation code. If yes, I would guide you, what I would need.

@imbdb
Copy link
Author

imbdb commented Aug 22, 2024

Sure @sebhildebrandt

@sebhildebrandt
Copy link
Owner

@imbdb thank you so much!

So, if you clone the repo with

git clone https://github.com/sebhildebrandt/systeminformation.git
cd systeminformation

Then edit the lib/processes.js file. Line 1138 to 1290 is where the magic happens ;-)

SO let us have a look:

  1. line 1139 to 1166: here we first get and parse all processes and store them into the procStatsvariable (as an array). If you do a console log after line 1166 with console.log(procStats) you should the see all processes. This should be true on your machine.
  2. line 1168 to 1230: now we are going through this array and determine if we are interested in a specific process:
  • line 1172 to 1176: here we just try to check if we already have this process in our result array ... for the first entry this should be false as the result array is empty. But if we find the process name in the result array, we remember the index in the array.
  • line 1177 to 1183: here we check if the process name is in our list of wanted processes ... as proc = '*' this should not be the case so inlist stays false ...
  • line 1184 to 1203 ... this is the interesting part: as processString (which is basically the same as the proc parameter after sanitation) equals * we should enter this if clause. listposshould be -1 as long as we do not have the process ib our list ... and if we have a name for the process (line 1186) we add the process to the result array.

For some reason this last part only happens once. Here it would be interesting to check the conditions WHY this part is not called again. Looking at your result this is anyway strange as there should never be an item in the result with name = '' ... I only allow to add items to the result array if there IS a name (line 1186). Can you try to check the conditions here and post back, what you found out?

Thank you!

@sebhildebrandt
Copy link
Owner

@imbdb did you had time to have a look on it on your side? I tested it here on different machines and different OS versions without any issue ... so it would be interesting to see what the reason is on your machine. Thank you in advance.

@imbdb
Copy link
Author

imbdb commented Aug 24, 2024

Hello @sebhildebrandt

Give me sometime (max 2 days), stuck in some issues right now.

@sebhildebrandt
Copy link
Owner

Hi @imbdb ... sorry I didn't wanted to stress you! Take your time ;-)

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

No branches or pull requests

2 participants