Closed yarikoptic closed 1 month ago
This is a bug-- I accidentally left stat in ps
but brought maxsplit back down to 6.
"pid,pcpu,pmem,rss,vsz,etime,stat,cmd",
],
text=True,
)
for line in output.splitlines()[1:]:
if line:
pid, pcpu, pmem, rss_kib, vsz_kib, etime, cmd = line.split(
maxsplit=6,
)
https://github.com/con/duct/blob/main/src/con_duct/__main__.py#L422-L428
We have two options. We could add stat to the record, which might be a little odd since there are multiple measurements and the stat can change. In that case I think we would just the stat from the final measurement.
Or, if that information isn't particularly useful we could just cut it. I'm leaning towards keeping it. @yarikoptic wdyt
actually not a bad idea to collect all stats, as pretty much "Counter" on them across samples (how often it was in S how often in some other mode). It can come handy!
while doing that -- strengthen the tests, do TDD -- first make a test which currently fails, then fix/extend code accordingly.
here is chatgpt example on such a Counter across ALL processes I have running ATM :
❯ ps -eo stat | tail -n +2 | python3 -c "import sys; from collections import Counter; print(Counter([line.strip() for line in sys.stdin]))"
Counter({'S': 219, 'Sl': 161, 'I<': 93, 'I': 76, 'Ssl': 66, 'Ss': 36, 'S+': 13, 'Ss+': 7, 'SLsl': 6, 'SLl': 6, 'SN': 5, 'SLs': 2, 'Sl+': 2, 'SNl': 2, 'R+': 2, 'S<': 1, 'Ssl+': 1, 'Rl+': 1, 'SNsl': 1, 'D<': 1})
Fixed by https://github.com/con/duct/pull/182
Trying with @candleindark
and we were looking at the usage logs
and I spotted that it is
so includes
Rs
for some reason, likely from STATso I guess parsing is buggy ATM, at least on my laptop.
FWIW I ran tests on that version and they passed
so must be particular about this invocation or testing is not yet strong enough for parsing of cmd out