neekey / table-parser

A parser to parse table style output from shell
MIT License
25 stars 13 forks source link

some of `ps -lx` log crash the output #17

Open jasonliao opened 6 years ago

jasonliao commented 6 years ago

I found some of ps -lx log crash the output

import Parser from 'table-parser'

const log = `
F   UID    PID   PPID PRI  NI    VSZ   RSS WCHAN  STAT TTY        TIME COMMAND
1  1000  22896      1  20   0 862556  2020 hrtime Ss   ?          0:44 /home/user/server/sbin/agent -i /home/user/server/etc/agent.conf -d
`

console.log(Parser.parse(log)) // work perfect!

but when I add a log below, the output getting odd...

1  1000  37155  37142  20   0 1418072 613332 hrtime Sl ?        11719:38 /home/user/sbin/otherAgent -i /home/user/etc/otherAgent.conf
import Parser from 'table-parser'

const new_log = `
F   UID    PID   PPID PRI  NI    VSZ   RSS WCHAN  STAT TTY        TIME COMMAND
1  1000  22896      1  20   0 862556  2020 hrtime Ss   ?          0:44 /home/user/server/sbin/agent -i /home/user/server/etc/agent.conf -d
1  1000  37155  37142  20   0 1418072 613332 hrtime Sl ?        11719:38 /home/user/sbin/otherAgent -i /home/user/etc/otherAgent.conf
`

console.log(Parser.parse(new_log)) 

/*
{
  COMMAND: ["0:44", "/home/user/server/sbin/agent"],
  TIME: ["0:44", "/home/user/server/sbin/agent", "-i", "/home/user/server/etc/agent.conf", "-d"]
}
*/

here is demo

table-parser v1.0.1

cyrusbowman commented 4 months ago

Happened to me as well, I think it's when the running time of a process reaches 5 digits causing a shift between time/command column.

Screenshot 2024-03-21 at 4 07 08 PM