-
Notifications
You must be signed in to change notification settings - Fork 41
Parse OSX process details correctly #64
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
Parse OSX process details correctly #64
Conversation
milankinen
commented
Aug 14, 2017
@neekey have you had time to look at this yet?
neekey
commented
Aug 14, 2017
Hi @milankinen thanks for your PR. Your way of parsing the output is quite the same as the original version of this module, which works in this case but will fail in other cases as well, so I won't accept this as a solution, though it works in your case.
you can take a look at this discussion neekey/table-parser#3 (comment), there are more cases like the discussion mentioned.
Actually table-parser has done its best already (since it tries to catch as much edge cases as it can), but it can't work well if the input's format is very hard to predict, there is a boundary needs to be set for table-parser's ability.
So instead of improving table-parser itself, I am thinking if there's any way to regulate the output format of ps, which is the core part of the issue. (like @falconscript did here #62 (comment))
neekey
commented
Aug 14, 2017
yes, I think I can definitely narrow down the metrics to only pid, command, arguments, ppid
which works in this case but will fail in other cases as well
I coudn't find those cases (not even from the table parser thread you posted). Could you provide a link to them?
So instead of improving table-parser itself, I am thinking if there's any way to regulate the output format of ps, which is the core part of the issue.
Yes that's definitely the right way, although it'd introduce non-backwards compatible API changes. The purpose of this PR is to fix the parsing without breaking the backwards compatibility so that's why I thought it could be the first step.
lkounadis
commented
Sep 18, 2017
Hello, when will this commit be merged into the release branch? I am dealing with an error and this is the solution needed.. I am currently using this commit in order to work now. would appreciate it if we could get in though..
raszi
commented
Oct 26, 2017
I believe you could run the ps with the following args on BSDs and macOS:
$ ps -x -opid,ppid,command|head -3
PID PPID COMMAND
308 1 /usr/sbin/cfprefsd agent
313 1 /usr/sbin/distnoted agent
On mac, the ps output can be misaligned, e.g. when some VSZ field is longer than expected. The default ps-node lookup is via ps lx, which includes: -l Display information associated with the following keywords: uid, pid, ppid, flags, cpu, pri, nice, vsz=SZ, rss, wchan, state=S, paddr=ADDR, tty, time, and command=CMD. Many of these fields are unnecessary because we're looking up by name only, so we can lookup using only the default fields of ps. neekey/table-parser#11 neekey/ps#64
`ps x -o pid,command` rather than `ps lx` The default ps-node lookup is via ps lx, which includes: -l Display information associated with the following keywords: uid, pid, ppid, flags, cpu, pri, nice, vsz=SZ, rss, wchan, state=S, paddr=ADDR, tty, time, and command=CMD. On mac, the `ps l` output can be misaligned, e.g. when some VSZ field is longer than expected. Many of these fields are unnecessary because we're looking up by name only, so we can lookup using only the command fields of ps. https://gist.github.com/ivankovacevic/9918272 More on the issue with ps-node: neekey/table-parser#11 neekey/ps#64
`ps x -o pid,command` rather than `ps lx` The default ps-node lookup is via ps lx, which includes: -l Display information associated with the following keywords: uid, pid, ppid, flags, cpu, pri, nice, vsz=SZ, rss, wchan, state=S, paddr=ADDR, tty, time, and command=CMD. On mac, the `ps l` output can be misaligned, e.g. when some VSZ field is longer than expected. Many of these fields are unnecessary because we're looking up by name only, so we can lookup using only the command fields of ps. https://gist.github.com/ivankovacevic/9918272 More on the issue with ps-node: neekey/table-parser#11 neekey/ps#64
`ps x -o pid,command` rather than `ps lx` The default ps-node lookup is via ps lx, which includes: -l Display information associated with the following keywords: uid, pid, ppid, flags, cpu, pri, nice, vsz=SZ, rss, wchan, state=S, paddr=ADDR, tty, time, and command=CMD. On mac, the `ps l` output can be misaligned, e.g. when some VSZ field is longer than expected. Many of these fields are unnecessary because we're looking up by name only, so we can lookup using only the command fields of ps. https://gist.github.com/ivankovacevic/9918272 More on the issue with ps-node: neekey/table-parser#11 neekey/ps#64
`ps x -o pid,command` rather than `ps lx` The default ps-node lookup is via ps lx, which includes: -l Display information associated with the following keywords: uid, pid, ppid, flags, cpu, pri, nice, vsz=SZ, rss, wchan, state=S, paddr=ADDR, tty, time, and command=CMD. On mac, the `ps l` output can be misaligned, e.g. when some VSZ field is longer than expected. Many of these fields are unnecessary because we're looking up by name only, so we can lookup using only the command fields of ps. https://gist.github.com/ivankovacevic/9918272 More on the issue with ps-node: neekey/table-parser#11 neekey/ps#64
`ps x -o pid,command` rather than `ps lx` The default ps-node lookup is via ps lx, which includes: -l Display information associated with the following keywords: uid, pid, ppid, flags, cpu, pri, nice, vsz=SZ, rss, wchan, state=S, paddr=ADDR, tty, time, and command=CMD. On mac, the `ps l` output can be misaligned, e.g. when some VSZ field is longer than expected. Many of these fields are unnecessary because we're looking up by name only, so we can lookup using only the command fields of ps. https://gist.github.com/ivankovacevic/9918272 More on the issue with ps-node: neekey/table-parser#11 neekey/ps#64
`ps x -o pid,command` rather than `ps lx` The default ps-node lookup is via ps lx, which includes: -l Display information associated with the following keywords: uid, pid, ppid, flags, cpu, pri, nice, vsz=SZ, rss, wchan, state=S, paddr=ADDR, tty, time, and command=CMD. On mac, the `ps l` output can be misaligned, e.g. when some VSZ field is longer than expected. Many of these fields are unnecessary because we're looking up by name only, so we can lookup using only the command fields of ps. https://gist.github.com/ivankovacevic/9918272 More on the issue with ps-node: neekey/table-parser#11 neekey/ps#64
`ps x -o pid,command` rather than `ps lx` The default ps-node lookup is via ps lx, which includes: -l Display information associated with the following keywords: uid, pid, ppid, flags, cpu, pri, nice, vsz=SZ, rss, wchan, state=S, paddr=ADDR, tty, time, and command=CMD. On mac, the `ps l` output can be misaligned, e.g. when some VSZ field is longer than expected. Many of these fields are unnecessary because we're looking up by name only, so we can lookup using only the command fields of ps. https://gist.github.com/ivankovacevic/9918272 More on the issue with ps-node: neekey/table-parser#11 neekey/ps#64
`ps x -o pid,command` rather than `ps lx` The default ps-node lookup is via ps lx, which includes: -l Display information associated with the following keywords: uid, pid, ppid, flags, cpu, pri, nice, vsz=SZ, rss, wchan, state=S, paddr=ADDR, tty, time, and command=CMD. On mac, the `ps l` output can be misaligned, e.g. when some VSZ field is longer than expected. Many of these fields are unnecessary because we're looking up by name only, so we can lookup using only the command fields of ps. https://gist.github.com/ivankovacevic/9918272 More on the issue with ps-node: neekey/table-parser#11 neekey/ps#64
`ps x -o pid,command` rather than `ps lx` The default ps-node lookup is via ps lx, which includes: -l Display information associated with the following keywords: uid, pid, ppid, flags, cpu, pri, nice, vsz=SZ, rss, wchan, state=S, paddr=ADDR, tty, time, and command=CMD. On mac, the `ps l` output can be misaligned, e.g. when some VSZ field is longer than expected. Many of these fields are unnecessary because we're looking up by name only, so we can lookup using only the command fields of ps. https://gist.github.com/ivankovacevic/9918272 More on the issue with ps-node: neekey/table-parser#11 neekey/ps#64
`ps x -o pid,command` rather than `ps lx` The default ps-node lookup is via ps lx, which includes: -l Display information associated with the following keywords: uid, pid, ppid, flags, cpu, pri, nice, vsz=SZ, rss, wchan, state=S, paddr=ADDR, tty, time, and command=CMD. On mac, the `ps l` output can be misaligned, e.g. when some VSZ field is longer than expected. Many of these fields are unnecessary because we're looking up by name only, so we can lookup using only the command fields of ps. https://gist.github.com/ivankovacevic/9918272 More on the issue with ps-node: neekey/table-parser#11 neekey/ps#64
`ps x -o pid,command` rather than `ps lx` The default ps-node lookup is via ps lx, which includes: -l Display information associated with the following keywords: uid, pid, ppid, flags, cpu, pri, nice, vsz=SZ, rss, wchan, state=S, paddr=ADDR, tty, time, and command=CMD. On mac, the `ps l` output can be misaligned, e.g. when some VSZ field is longer than expected. Many of these fields are unnecessary because we're looking up by name only, so we can lookup using only the command fields of ps. https://gist.github.com/ivankovacevic/9918272 More on the issue with ps-node: neekey/table-parser#11 neekey/ps#64
`ps x -o pid,command` rather than `ps lx` The default ps-node lookup is via ps lx, which includes: -l Display information associated with the following keywords: uid, pid, ppid, flags, cpu, pri, nice, vsz=SZ, rss, wchan, state=S, paddr=ADDR, tty, time, and command=CMD. On mac, the `ps l` output can be misaligned, e.g. when some VSZ field is longer than expected. Many of these fields are unnecessary because we're looking up by name only, so we can lookup using only the command fields of ps. https://gist.github.com/ivankovacevic/9918272 More on the issue with ps-node: neekey/table-parser#11 neekey/ps#64
`ps x -o pid,command` rather than `ps lx` The default ps-node lookup is via ps lx, which includes: -l Display information associated with the following keywords: uid, pid, ppid, flags, cpu, pri, nice, vsz=SZ, rss, wchan, state=S, paddr=ADDR, tty, time, and command=CMD. On mac, the `ps l` output can be misaligned, e.g. when some VSZ field is longer than expected. Many of these fields are unnecessary because we're looking up by name only, so we can lookup using only the command fields of ps. https://gist.github.com/ivankovacevic/9918272 More on the issue with ps-node: neekey/table-parser#11 neekey/ps#64
Hello!
Here is a fix for #62.
TableParserwas a bit too generic so I tailored the parsing logic forpsin order to improve robustness. I added a test case based on the given example output from #62.I hope we can get this fix released asap. Our testing pipeline needs this fix because
testcafe(which depends on this package) can't parse browser PID correctly, hence leaving the browser process open after every test run. 😕