get_processes: started holds only the weekday, and command starts with the rest of the start date #21

Open
opened 2026-10-08 07:04:22 +00:00 by christianmanivong · 0 comments
Owner

get_processes() runs ps axo pid,ppid,user:20,pcpu,pmem,vsz,rss,tty,stat,lstart,args and splits each line with line.split(None, 10). lstart is five words (Tue Oct 6 08:47:15 2026), so the split is off by four:

  • started gets only the weekday (Tue),
  • command starts with the rest of the date (Oct 6 08:47:15 2026 /sbin/init splash).

Reproduced with the exact command and the driver's split on a Linux host (locale de_DE, same structure in C):

started = 'Di' | command = 'Okt  6 08:47:15 2026 /sbin/init splash'

The comment in the code already says "lstart takes 5 parts" but the split does not account for it. Fix: split into 15 parts (split(None, 14)), join parts 9–13 as started, take part 14 as command; or use etime/start instead of lstart. Found while writing napalm-bsd's process reader (NetOrk/netork#798).

`get_processes()` runs `ps axo pid,ppid,user:20,pcpu,pmem,vsz,rss,tty,stat,lstart,args` and splits each line with `line.split(None, 10)`. `lstart` is five words (`Tue Oct 6 08:47:15 2026`), so the split is off by four: - `started` gets only the weekday (`Tue`), - `command` starts with the rest of the date (`Oct 6 08:47:15 2026 /sbin/init splash`). Reproduced with the exact command and the driver's split on a Linux host (locale de_DE, same structure in C): ``` started = 'Di' | command = 'Okt 6 08:47:15 2026 /sbin/init splash' ``` The comment in the code already says "lstart takes 5 parts" but the split does not account for it. Fix: split into 15 parts (`split(None, 14)`), join parts 9–13 as `started`, take part 14 as `command`; or use `etime`/`start` instead of `lstart`. Found while writing napalm-bsd's process reader (NetOrk/netork#798).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: NAPALM/napalm-linux#21