Parse CPU per core usage snapshot to output/text file

250 Views Asked by At

I am working on a python script to read CPU usage per core and do some data analysis. 'htop' can show a dynamic usage on standard output but it's not readable by the program.

Is there a way to log snapshot of 'htop' to a text file or standard output?

1

There are 1 best solutions below

0
Tim On

if you have nodejs installed, you can use this package

https://github.com/sweetim/linux-top-parser

it will parse the top output into json, you can access them using the API or the CLI