aboutsummaryrefslogtreecommitdiff
path: root/powerlevel9k.zsh-theme
diff options
context:
space:
mode:
authorDavid McKay <david@rawkode.com>2016-04-22 14:24:30 +0300
committerDavid McKay <david@rawkode.com>2016-04-22 14:24:30 +0300
commit78b4ab0414eb1c3b69a1fd9eae60f520e7fc79d2 (patch)
treeee0bd9319f9c4b93bcc79724f64453695203e9e2 /powerlevel9k.zsh-theme
parent24fac490507996dbd015e11e0c13b8ee05014d50 (diff)
Improvements to load prompt, now reporting warning and critical at 50% and 70% cpu core utilisation
Diffstat (limited to 'powerlevel9k.zsh-theme')
-rwxr-xr-xpowerlevel9k.zsh-theme21
1 files changed, 15 insertions, 6 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme
index d583eaab..4fd7ecf4 100755
--- a/powerlevel9k.zsh-theme
+++ b/powerlevel9k.zsh-theme
@@ -578,30 +578,39 @@ prompt_ip() {
prompt_load() {
# The load segment can have three different states
local current_state="unknown"
+ local cores
+
+ if [[ "$OS" == "OSX" ]]; then
+ cores=$(sysctl -a | grep machdep.cpu)
+ else
+ cores=$(nproc)
+ fi
+
typeset -AH load_states
load_states=(
'critical' 'red'
'warning' 'yellow'
'normal' 'green'
)
+
if [[ "$OS" == "OSX" ]]; then
- load_avg_5min=$(sysctl vm.loadavg | grep -o -E '[0-9]+(\.|,)[0-9]+' | head -n 1)
+ load_avg_1min=$(sysctl vm.loadavg | grep -o -E '[0-9]+(\.|,)[0-9]+' | head -n 1)
else
- load_avg_5min=$(grep -o "[0-9.]*" /proc/loadavg | head -n 1)
+ load_avg_1min=$(grep -o "[0-9.]*" /proc/loadavg | head -n 1)
fi
# Replace comma
- load_avg_5min=${load_avg_5min//,/.}
+ load_avg_1min=${load_avg_1min//,/.}
- if [[ "$load_avg_5min" -gt 10 ]]; then
+ if [[ "$load_avg_1min" -gt $(bc -l <<< "${cores} * 0.7") ]]; then
current_state="critical"
- elif [[ "$load_avg_5min" -gt 3 ]]; then
+ elif [[ "$load_avg_1min" -gt $(bc -l <<< "${cores} * 0.5") ]]; then
current_state="warning"
else
current_state="normal"
fi
- "$1_prompt_segment" "${0}_${current_state}" "$2" "${load_states[$current_state]}" "$DEFAULT_COLOR" "$load_avg_5min" 'LOAD_ICON'
+ "$1_prompt_segment" "${0}_${current_state}" "$2" "${load_states[$current_state]}" "$DEFAULT_COLOR" "$load_avg_1min" 'LOAD_ICON'
}
# Node version