neb/tools/diagnostics/load-percentage.sh

19 lines
328 B
Bash
Raw Normal View History

2024-02-10 13:48:19 +01:00
#!/bin/sh
argi=1
while getopts '5qh' opt; do
case $opt in
5) argi=2 ;;
q) argi=3 ;;
h) echo "-5 = 5 minutes, -q = a quarter (15 min)"; exit ;;
\?) exit 1 ;;
esac
done
shift $((OPTIND-1))
LOADVAL=$(awk "{ print \$$argi; }" < /proc/loadavg)
NUMCPUS=$(getconf _NPROCESSORS_ONLN)
echo "$LOADVAL * 100 / $NUMCPUS" | bc