shellingham icon indicating copy to clipboard operation
shellingham copied to clipboard

Fix error calling ps on AIX platforms

Open kadler opened this issue 5 years ago • 9 comments

AIX ps does not support -w option in POSIX mode, only in Berkeley mode ('w'), but Berkeley mode doesn't support -o, so just remove the -ww option and hope for the best.

Fixes #21

kadler avatar Mar 14 '19 16:03 kadler

Do you have the man entry available? I wonder if there are other flags we can use to keep w. That helps with some edge cases.

uranusjr avatar Mar 14 '19 16:03 uranusjr

Also, is it possible to sniff out IBM systems in Python? Do os.name, sys.platform, or various calls from the platform module return interesting information?

uranusjr avatar Mar 14 '19 16:03 uranusjr

Do you have the man entry available? I wonder if there are other flags we can use to keep w. That helps with some edge cases.

The latest man page is here: https://www.ibm.com/support/knowledgecenter/en/ssw_aix_72/com.ibm.aix.cmds4/ps.htm

I did not see an equivalent option for -w in POSIX mode or -o in Berkeley mode, unfortuantely :(

kadler avatar Mar 14 '19 16:03 kadler

On AIX, os.name is 'posix', sys.platform is 'aix' followed by the major version (ie. 'aix6', 'aix7', ...).

We also run a variant of AIX inside of the IBM i OS. There, sys.platform will return 'os400' followed by the major version. I've included those platform checks in this PR.

kadler avatar Mar 14 '19 16:03 kadler

The latest man page is here: https://www.ibm.com/support/knowledgecenter/en/ssw_aix_72/com.ibm.aix.cmds4/ps.htm

I did not see an equivalent option for -w in POSIX mode or -o in Berkeley mode, unfortuantely :(

Does ps wwl work? That would contain all the information we need (although more difficult to parse than -o).

uranusjr avatar Mar 14 '19 16:03 uranusjr

Yes, here's a sample:

-bash-4.4$ ps wwl
     F S      UID    PID   PPID   C PRI NI ADDR  SZ  RSS   WCHAN    TTY  TIME CMD
240000 A      105 897903 897902   0  20 20    0 7124    0          pts/0  0:00 -bash 
200000 A      105 897904 897903   0  20 20    0 6792    0          pts/0  0:00 ps wwl

kadler avatar Mar 14 '19 16:03 kadler

Ah, excellent. I’ll try to implement a parser for that format. Thanks for the help!

uranusjr avatar Mar 14 '19 16:03 uranusjr

I just realised switching to ps wwl would likely affect #15. @sirn could you try the command out and see whether

  1. ps prints a header row (but no actual content), and
  2. the command returns 0?

uranusjr avatar Mar 15 '19 05:03 uranusjr

From what I tried,

  1. ✅ The command returns header row without content
  2. ❌ The command returns 0
~ $ ssh freebsd.gemini 'uname -a'
FreeBSD freebsd 12.0-RELEASE FreeBSD 12.0-RELEASE r341666 GENERIC  amd64

~ $ ssh freebsd.gemini 'ps wwl || echo $?'
UID PID PPID CPU PRI NI VSZ RSS MWCHAN STAT TT  TIME COMMAND
1

sirn avatar Mar 15 '19 06:03 sirn