diff options
author | Manuel Palenzuela <manuelpalenzuelamerino@gmail.com> | 2019-10-22 13:12:44 +0100 |
---|---|---|
committer | Manuel Palenzuela <manuelpalenzuelamerino@gmail.com> | 2019-10-22 13:12:44 +0100 |
commit | 1fb47edc46197a8480d525351d47ff15c6e5a2a4 (patch) | |
tree | 3524af9ba3f2b2143a19fe240788d0e3f179677d /modules | |
parent | 460da853b2ae79fab7580d8f072a6a66c7a43a16 (diff) |
Added cpu load module
Diffstat (limited to 'modules')
-rwxr-xr-x | modules/cpuload | 12 |
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 |