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

AIX 7.2 Process data get by process_iter contains weird process names #1529

Closed
bartekmp opened this issue Jun 11, 2019 · 3 comments
Closed

Comments

@bartekmp
Copy link

AIX

  • AIX 7.2
  • psutil 5.6.2

Bug description
When using process_iter to iterate through process list, it is impossible to filter out some well-known processes, because in resulting Process structure name field has a wrong value, from what I reckon it contains binary name and a cropped command line, e.g. (notice 2nd line, where you can see my application myTestEnvAppInst being run and a cropped command line passed to it instead of the name):

6685142: {'pid': 6685142, 'name': 'IBM.MgmtDomainRM/opt/rsct/bin/IBM.MgmtDomainRMd'},
6095186: {'pid': 6095186, 'name': 'myTestEnvAppInst/home/labuser/workspace_direc/downloads/component/exec/lib/myTestEnvAppInst -lo'}

This is what I get when I execute this code:

proc_list = {process.pid: process.info for process in psutil.process_iter(attrs=["pid", "name"])}

Not all processes have wrong names, e.g.:

3998084: {'pid': 3998084, 'name': 'rsyslogd'}

Most of them are OK.

I also compared psutil's results to system's ps using this code:

name = "myTestEnvAppInst"
cmd = "ps -A | grep '" + name + "' | awk '{print $1}'"
ps = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)

and got the same pid as in the snippet above, i.e. 6095186. I also checked the ps output manually and the process name is also as expected:

6095186      -  0:00 myTestEnvAppInst

This issue is making process list filtering like this:

names = ["a", "b", "c"]
pids = [process.info["pid"] for process in psutil.process_iter(attrs=["pid", "name"]) if process.info["name"] in names]

very difficult, as you have to use some regexing to get it right. I guess this comes from binary structure of /proc but right now it doesn't always work properly.

@wiggin15
Copy link
Collaborator

This may have been resolved in psutil 5.6.3, which fixed a few things regarding process names and command line arguments. Can you please try that version?

@bartekmp
Copy link
Author

Sure, will do once my team will compile v5.6.3, as there was also a bug regarding compilation on our setup. I will get back and let you know about it.

@no-response
Copy link

no-response bot commented Jan 2, 2021

This issue has been automatically closed because there has been no response for more information from the original author. Please reach out if you have or find the answers requested so that this can be investigated further.

@no-response no-response bot closed this as completed Jan 2, 2021
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

3 participants