aboutsummaryrefslogtreecommitdiffstats
path: root/bin/get_cpu_status
diff options
context:
space:
mode:
Diffstat (limited to 'bin/get_cpu_status')
-rwxr-xr-xbin/get_cpu_status10
1 files changed, 10 insertions, 0 deletions
diff --git a/bin/get_cpu_status b/bin/get_cpu_status
new file mode 100755
index 0000000..2aece18
--- /dev/null
+++ b/bin/get_cpu_status
@@ -0,0 +1,10 @@
+#!/usr/bin/env bash
+set -euo pipefail
+IFS=$'\n\t'
+
+proc_output=""
+
+proc_output=$(grep 'cpu ' /proc/stat | awk '{usage=($2+$4)*100/($2+$4+$5)} END {printf("%5.1f", usage)}')
+proc_output=${proc_output#" "}
+
+echo "$proc_output%"