mirror of
https://github.com/dustinkirkland/byobu
synced 2025-08-20 21:43:19 -07:00
Add FreeBSD CPU stats, disk usage, load average
This commit is contained in:
parent
b8760befc7
commit
c0b86f63a9
5 changed files with 26 additions and 20 deletions
|
@ -24,9 +24,11 @@ __cpu_count_detail() {
|
||||||
}
|
}
|
||||||
|
|
||||||
__cpu_count() {
|
__cpu_count() {
|
||||||
local c
|
if [ $(uname) = "FreeBSD" ]; then
|
||||||
c=$(getconf _NPROCESSORS_ONLN 2>/dev/null || grep -ci "^processor" /proc/cpuinfo)
|
c=$(sysctl -n hw.ncpu)
|
||||||
|
else
|
||||||
|
local c
|
||||||
|
c=$(getconf _NPROCESSORS_ONLN 2>/dev/null || grep -ci "^processor" /proc/cpuinfo)
|
||||||
|
fi
|
||||||
[ "$c" = "1" ] || printf "%sx" "$c"
|
[ "$c" = "1" ] || printf "%sx" "$c"
|
||||||
}
|
}
|
||||||
|
|
||||||
# vi: syntax=sh ts=4 noexpandtab
|
|
||||||
|
|
|
@ -25,7 +25,11 @@ __cpu_freq_detail() {
|
||||||
|
|
||||||
__cpu_freq() {
|
__cpu_freq() {
|
||||||
local hz freq count
|
local hz freq count
|
||||||
if [ -r "/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq" ]; then
|
if [ $(uname) = "FreeBSD" ]; then
|
||||||
|
hz=$(sysctl -n machdep.tsc_freq)
|
||||||
|
fpdiv $hz "1000000000" 1
|
||||||
|
freq="$_RET"
|
||||||
|
elif [ -r "/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq" ]; then
|
||||||
read hz < /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq
|
read hz < /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq
|
||||||
fpdiv $hz "1000000" 1 # 1Ghz
|
fpdiv $hz "1000000" 1 # 1Ghz
|
||||||
freq="$_RET"
|
freq="$_RET"
|
||||||
|
@ -45,5 +49,3 @@ __cpu_freq() {
|
||||||
[ -n "$freq" ] || return
|
[ -n "$freq" ] || return
|
||||||
color b c W; printf "%s" "$freq"; color -; color c W; printf "%s" "$ICON_GHz"; color --
|
color b c W; printf "%s" "$freq"; color -; color c W; printf "%s" "$ICON_GHz"; color --
|
||||||
}
|
}
|
||||||
|
|
||||||
# vi: syntax=sh ts=4 noexpandtab
|
|
||||||
|
|
|
@ -20,7 +20,11 @@
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
__disk_detail() {
|
__disk_detail() {
|
||||||
df -h -P
|
if [ $(uname) = "FreeBSD" ]; then
|
||||||
|
df -h
|
||||||
|
else
|
||||||
|
df -h -P
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
__disk() {
|
__disk() {
|
||||||
|
@ -32,7 +36,11 @@ __disk() {
|
||||||
esac
|
esac
|
||||||
# this could be done faster with 'stat --file-system --format'
|
# this could be done faster with 'stat --file-system --format'
|
||||||
# but then we'd have to do blocks -> human units ourselves
|
# but then we'd have to do blocks -> human units ourselves
|
||||||
out=$({ df -h -P "$MP" 2>/dev/null || df -h "$MP"; } | awk 'END { printf("%s %s", $2, $5); }')
|
if [ $(uname) = "FreeBSD" ]; then
|
||||||
|
out=$({ df -h "$MP" 2>/dev/null || df -h "$MP"; } | awk 'END { printf("%s %s", $2, $5); }')
|
||||||
|
else
|
||||||
|
out=$({ df -h -P "$MP" 2>/dev/null || df -h "$MP"; } | awk 'END { printf("%s %s", $2, $5); }')
|
||||||
|
fi
|
||||||
set -- ${out}
|
set -- ${out}
|
||||||
size=${1}; pct=${2};
|
size=${1}; pct=${2};
|
||||||
unit=${size#${size%?}} # get the unit (last char)
|
unit=${size#${size%?}} # get the unit (last char)
|
||||||
|
@ -48,5 +56,3 @@ __disk() {
|
||||||
color b m W; printf "%s" "$size"; color -; color m W; printf "%s" "$unit"; color -;
|
color b m W; printf "%s" "$size"; color -; color m W; printf "%s" "$unit"; color -;
|
||||||
color b m W; printf "%s" "$pct"; color -; color m W; printf "%s" "$PCT"; color --;
|
color b m W; printf "%s" "$pct"; color -; color m W; printf "%s" "$PCT"; color --;
|
||||||
}
|
}
|
||||||
|
|
||||||
# vi: syntax=sh ts=4 noexpandtab
|
|
||||||
|
|
|
@ -34,5 +34,3 @@ __load_average() {
|
||||||
[ -n "$one" ] || return
|
[ -n "$one" ] || return
|
||||||
color Y k; printf "$one"; color --
|
color Y k; printf "$one"; color --
|
||||||
}
|
}
|
||||||
|
|
||||||
# vi: syntax=sh ts=4 noexpandtab
|
|
||||||
|
|
|
@ -40,5 +40,3 @@ __users() {
|
||||||
rm -f "$BYOBU_RUN_DIR/status.$BYOBU_BACKEND/users"*
|
rm -f "$BYOBU_RUN_DIR/status.$BYOBU_BACKEND/users"*
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# vi: syntax=sh ts=4 noexpandtab
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue