1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/linuxdash_ynh.git synced 2024-09-03 19:36:07 +02:00
linuxdash_ynh/sources/server/modules/shell_files/cpu_intensive_processes.sh

13 lines
354 B
Bash
Raw Normal View History

#!/bin/bash
result=$(/bin/ps axo pid,user,pcpu,rss,vsz,comm --sort -pcpu,-rss,-vsz \
| head -n 15 \
| /usr/bin/awk 'BEGIN{OFS=":"} NR>1 {print "{ \"pid\": " $1 \
", \"user\": \"" $2 "\"" \
", \"cpu%\": " $3 \
", \"rss\": " $4 \
", \"vsz\": " $5 \
", \"cmd\": \"" $6 "\"" "},"\
}')
echo "[" ${result%?} "]"