2024-06-12 18:07:31 +02:00
|
|
|
#!/usr/bin/env zsh
|
|
|
|
# print 1 minute load average with tooltip for 1, 5 and 15 minutes
|
|
|
|
# emit 3 classes: good, warning, critical
|
|
|
|
|
|
|
|
local load_all=$(cut -d' ' -f1,2,3 /proc/loadavg)
|
|
|
|
local load=${${(@s: :)load_all}[1]}
|
|
|
|
|
2024-06-13 14:44:04 +02:00
|
|
|
local class=good
|
|
|
|
local nproc=$(nproc)
|
2024-06-21 03:41:42 +02:00
|
|
|
if [[ ${load} -gt $(( ${nproc} + 1 )) ]]; then
|
2024-06-13 14:44:04 +02:00
|
|
|
class=critical
|
2024-06-16 15:59:18 +02:00
|
|
|
elif [[ ${load} -gt $(( ${nproc} + 0.2 )) ]]; then
|
2024-06-13 14:44:04 +02:00
|
|
|
class=warning
|
2024-06-12 18:07:31 +02:00
|
|
|
fi
|
2024-06-13 14:44:04 +02:00
|
|
|
|
|
|
|
print -l ${load} ${load_all} ${class}
|