linux-top-parser
v1.3.5
Published
parser for linux top command
Downloads
6
Readme
Usage
there are 2 ways to use this package
- API
- CLI
API
Installation
npm i linux-top-parser -S
Code
const { parseTopInfo, topInfoTransform } = require("linux-top-parser");
// normal string parsing
const topInfo = parseTopInfo(TOP_INFO_STRING);
// or using transform stream
createReadStream(TOP_FILE_PATH)
.pipe(topInfoTransform({
stringify: true
}))
.pipe(process.stdout)
Examples
There are 2 code examples shown in the example folder on how to use this package
CLI
the CLI can be pipe from the output of top
command
top -b | npx linux-top-parser
or you can use the JSON processor CLI ( jq ) to process the stream
top -b | npx linux-top-parser | jq ".[0].summaryDisplay"
Usage
linux-top-parser [options]
Options:
-V, --version output the version number
-s, --summary output summary display only (default: false)
-p, --prettify output top info with indentation and color (default: false)
-f, --filter output process that has > 0% of CPU usage only (default: false)
-h, --help display help for command
Reference
- https://man7.org/linux/man-pages/man1/top.1.html