Don't process command outputs for system knowledge
h6w opened this issue · 0 comments
top
output can be quite unpredictable.
e.g. on Alpine Linux there is no "-i" switch.
Furthermore, the output is different on each system and version so processing the output can result in unexpected crashes.
e.g. Without the "-i" switch, on my Ubuntu box:
$ top -b -n 1
top - 13:06:51 up 43 days, 4:32, 17 users, load average: 0.52, 0.58, 0.87
Tasks: 290 total, 1 running, 287 sleeping, 0 stopped, 2 zombie
%Cpu(s): 8.5 us, 1.7 sy, 0.0 ni, 89.3 id, 0.4 wa, 0.0 hi, 0.0 si, 0.0 st
On Alpine Linux:
top -b -n 1
Mem: 2015520K used, 32164K free, 14400K shrd, 123468K buff, 452536K cached
CPU: 0% usr 0% sys 0% nic 100% idle 0% io 0% irq 0% sirq
Load average: 0.16 0.28 0.31 3/380 442
I don't think we should be using top output to get these values.