aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorManuel Palenzuela <manuelpalenzuelamerino@gmail.com>2019-10-22 13:12:44 +0100
committerManuel Palenzuela <manuelpalenzuelamerino@gmail.com>2019-10-22 13:12:44 +0100
commit1fb47edc46197a8480d525351d47ff15c6e5a2a4 (patch)
tree3524af9ba3f2b2143a19fe240788d0e3f179677d /modules
parent460da853b2ae79fab7580d8f072a6a66c7a43a16 (diff)
Added cpu load module
Diffstat (limited to 'modules')
-rwxr-xr-xmodules/cpuload12
1 files changed, 12 insertions, 0 deletions
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