Get system information such as CPU usage and RAM usage
First run this command to install the required libraries.
pip install -r requirements.txt
Call it from another program or load it as a module in python.
Call example from nodejs.
const {PythonShell} = require('python-shell');
PythonShell.run('systeminfo.py', null, function (err, result) {
if (err) throw err
resultJson = JSON.parse(result[0])
console.log(resultJson)
})
The meaning of each number in the disk and network results is output in the same order as the following psutil document.
Disk: https://psutil.readthedocs.io/en/latest/#psutil.disk_io_counters
Network: https://psutil.readthedocs.io/en/latest/#psutil.net_io_counters