35 lines
770 B
Bash
Executable File
35 lines
770 B
Bash
Executable File
#! /bin/sh
|
|
|
|
. ../mpanel.subr
|
|
|
|
align="right"
|
|
background="$(color 10)"
|
|
foreground="$(color 3)"
|
|
|
|
waitFunc="sleep 1"
|
|
clickFunc='toggle flag; [ "$flag" = "true" ] && waitFunc="sleep 1" || waitFunc="sleep infinity"'
|
|
|
|
flag="true"
|
|
|
|
STORE_FILE="$XDG_RUNTIME_DIR/stats-diskr.tmp"
|
|
SYMBOL=""
|
|
INTERVAL=""
|
|
|
|
store_stats() {
|
|
disk="$(zpool iostat -Hp 1 2 | tail -1 | awk '{r=$6 ; rSuf="B " ; if (r >= 1000) {r=r/1000; rSuf="KB";} if (r >= 1000) {r=r/1000; rSuf="MB";} if (r >= 1000) {r=r/1000; rSuf="GB";} printf "%3.0f", r; printf rSuf;}')"
|
|
|
|
echo "$disk" | atomic_write "$STORE_FILE"
|
|
}
|
|
|
|
print_stats() {
|
|
if [ "$flag" = "true" ]; then
|
|
echo "$SYMBOL$(cat "$STORE_FILE")"
|
|
else
|
|
echo "$SYMBOL"
|
|
fi
|
|
}
|
|
|
|
kickoff store_stats $INTERVAL &
|
|
|
|
loop print_stats
|