|
|
|
|
|
by Mister_Snuggles
1482 days ago
|
|
In the FreeBSD world, we have libxo[0] which allows utilities to produce structured output. To use your example, taking the output of ps and finding the process using the most RAM, you could do something like this: $ ps aux --libxo json|jq '."process-information"."process" | sort_by((.rss)|tonumber) | .[-1]'
{
"user": "root",
"pid": "2372",
"percent-cpu": "0.0",
"percent-memory": "11.4",
"virtual-size": "2149236",
"rss": "1906584",
"terminal-name": "- ",
"state": "SC",
"start-time": "21May22",
"cpu-time": "1307:09.11",
"command": "bhyve: postgresql (bhyve)"
}
It's not pretty, but it does let you get structured data out of most of the base system utilities to make the slicing and dicing easier.[0] https://www.freebsd.org/cgi/man.cgi?query=libxo&sektion=3 |
|