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 Process list relies on running external application #1366

Closed
dazhitchman opened this issue Oct 16, 2020 · 3 comments
Closed

AIX Process list relies on running external application #1366

dazhitchman opened this issue Oct 16, 2020 · 3 comments
Labels
performance Speeding up OSHI or reducing memory footprint PR welcome Not maintainer's priority to do but will accept contributions! up for grabs Issues the maintainers want community help with

Comments

@dazhitchman
Copy link

The AIXOSProcess class obtains a list of running processes by calling the "ps" command. Is there a reason it doesn't walk the /proc path like the LinuxOSProcess ?
The /proc has been available in AIX since 5.2 from what I can see.
Issues with current reliance is

  • calling an external binary incurs overhead

  • path the ps isn't fully qualified (e.g. /usr/bin/ps ) so it relies on PATH and hence is vulnerable to exploitation

  • Although unlikely, the user running the application may not have permission to invoke ps (e.g. running in a restricted shell)

If there is a valid reason for this implementation then that's fine otherwise I propose using the same method/impl as oshi.software.os.linux.LinuxOperatingSystem:getProcesses(int limit, ProcessSort sort)

@dbwiddis
Copy link
Member

dbwiddis commented Oct 16, 2020

While there is a proc filesystem and it's sufficient for enumerating processes and their threads, it does not provide nearly the level of detail that Linux systems does. (The same issue exists in Solaris.). Here's what I see on the AIX 7.1 machine that I have (non-root) access to:

~$ ls /proc
0        1376316  1966158  2556020  3014760  3604636  4194432  4718738  5308582  589842   655380   7209002  7799016  8257676  9044002
1        1507580  2031818  262152   3080320  3670026  4259886  4784256  5439654  5964002  6619166  720918   7864482  8323254  9109674
1048684  1573112  2162760  2621542  3145828  3735678  4325518  4915366  5505132  6029502  6684698  7274594  786456   8454300  917532
1114238  1704024  2228292  2687086  327690   3866754  4390936  4980792  5570782  6160394  6750382  7405628  7930002  8519826  9371730
1179736  1769572  2293876  2752656  3342438  393228   4456608  5046450  5636144  6226152  6815782  7536640  7995490  851994   sys
1245226  1835104  2359466  2818188  3408050  3932364  458766   5177558  5701770  6291662  6881328  7602260  8061088  8585314  version
131076   1900624  2425034  2883698  3473568  3997858  4587676  524304   5767398  6357140  7078108  7667926  8126594  8650754
1310858  196614   2490590  2949214  3539054  4063248  4653198  5243072  5832902  6553754  7143632  7733264  8192128  8781990
~$ ls /proc/393228
cred  lwp  psinfo  sigact  status
~$ cat /proc/393228/status
cat: /proc/393228/status: The file access permissions do not allow the specified action.
~$ cat /proc/393228/psinfo

?
xx^?pv?vmmd
~$ ls /proc/393228/lwp   
393229  655381  720919  786457  851995
~$ ls /proc/393228/lwp/393229
lwpsinfo  lwpstatus
~$ cat /proc/393228/cred
cat: /proc/393228/cred: The file access permissions do not allow the specified action.
~$ cat /proc/393228/sigact
cat: /proc/393228/sigact: The file access permissions do not allow the specified action.

We do try to avoid command line calls whenever possible, but unfortunately on many OS's, ps is a necessary evil, because it allows root-level information access at the user level (the ps binary is owned by root).

You do have a point about fully qualified path names, a flaw that should probably be fixed on all the platforms.

@dbwiddis
Copy link
Member

dbwiddis commented Oct 16, 2020

Note: the psinfo file might contain some info but it's in binary format so I'd have to locate the appropriate header file and try to translate, and hope it was consistent across all versions, etc. It looks like the psinfo structure is documented here.

So it would be possible to read that binary file and convert, for both processes and threads.

If you can figure it out, I'd welcome a PR.

@dbwiddis dbwiddis added hacktoberfest Issues we're happy for new #Hacktoberfest2020 participants to do performance Speeding up OSHI or reducing memory footprint PR welcome Not maintainer's priority to do but will accept contributions! labels Oct 16, 2020
@dbwiddis dbwiddis removed the hacktoberfest Issues we're happy for new #Hacktoberfest2020 participants to do label Oct 31, 2020
@dbwiddis dbwiddis added the up for grabs Issues the maintainers want community help with label Nov 27, 2020
@dbwiddis dbwiddis added this to the 6.1.0 milestone Jan 1, 2022
@dbwiddis
Copy link
Member

dbwiddis commented Jan 1, 2022

Closing this and tracking in #1827

@dbwiddis dbwiddis closed this as completed Jan 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Speeding up OSHI or reducing memory footprint PR welcome Not maintainer's priority to do but will accept contributions! up for grabs Issues the maintainers want community help with
Projects
None yet
Development

No branches or pull requests

2 participants