From 1fb47edc46197a8480d525351d47ff15c6e5a2a4 Mon Sep 17 00:00:00 2001 From: Manuel Palenzuela Date: Tue, 22 Oct 2019 13:12:44 +0100 Subject: [PATCH] Added cpu load module --- modules/cpuload | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100755 modules/cpuload diff --git a/modules/cpuload b/modules/cpuload new file mode 100755 index 0000000..a6cbc26 --- /dev/null +++ b/modules/cpuload @@ -0,0 +1,12 @@ +#!/bin/bash + +# Prints out the CPU load percentage + +PREFIX=' ' + +get_load() +{ + echo "$PREFIX$( printf "%.0f" $(awk '{u=$2+$4; t=$2+$4+$5; if (NR==1){u1=u; t1=t;} else print ($2+$4-u1) * 100 / (t-t1); }' <(grep 'cpu ' /proc/stat) <(sleep 1;grep 'cpu ' /proc/stat)) )%" +} + +get_load