From 759852140a722f9194e7050f18a8a545c469f0d5 Mon Sep 17 00:00:00 2001 From: Raine Date: Sat, 10 Feb 2024 13:48:19 +0100 Subject: [PATCH] feat: diagnostic tool; load percentage --- tools/diagnostics/load-percentage.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100755 tools/diagnostics/load-percentage.sh diff --git a/tools/diagnostics/load-percentage.sh b/tools/diagnostics/load-percentage.sh new file mode 100755 index 0000000..7a1fd60 --- /dev/null +++ b/tools/diagnostics/load-percentage.sh @@ -0,0 +1,18 @@ +#!/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 +