Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions explorer/cpu_cores
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,20 @@ in
(macosx)
sysctl -n hw.physicalcpu
;;
(openbsd)
sysctl -n hw.ncpuonline
(netbsd|openbsd)
# OpenBSD sysctl(8) always exits 0 (thus `grep .' to check for success)
/sbin/sysctl -n hw.ncpuonline 2>/dev/null | grep . \
|| /sbin/sysctl -n hw.ncpu
;;
(freebsd|netbsd)
PATH=$(getconf PATH)
(freebsd)
sysctl -n hw.ncpu
;;
(*)
if test -r /proc/cpuinfo
then
cores=$(grep -c -e '^processor[[:blank:]]*:' /proc/cpuinfo)
test $((cores)) -ge 1 && echo $((cores)) || echo 1
cores=$(grep -c -e '^processor[[:blank:]]*:' /proc/cpuinfo || :)
test $((cores)) -gt 0 || cores=1
printf '%u\n' "${cores}"
fi
;;
esac
9 changes: 4 additions & 5 deletions explorer/cpu_sockets
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,14 @@ in
(macosx)
system_profiler SPHardwareDataType | grep -F 'Number of Processors' | awk -F': ' '{print $2}'
;;
(netbsd)
;;
(*)
if test -r /proc/cpuinfo
then
sockets=$(grep -e '^physical id[[:blank:]]*:' /proc/cpuinfo | sort -u | wc -l)
if test $((sockets)) -lt 1
then
sockets=$(grep -c -e '^processor[[:blank:]]*:' /proc/cpuinfo)
fi
echo $((sockets))
test $((sockets)) -gt 0 || sockets=1
printf '%u\n' "${sockets}"
fi
;;
esac
24 changes: 17 additions & 7 deletions explorer/memory
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,17 @@ in
(FreeBSD)
sysctl -n hw.realmem | bytes2kib
;;
(NetBSD|OpenBSD)
# NOTE: This reports "usable" memory, not physically installed memory.
command -p sysctl -n hw.physmem | bytes2kib
(NetBSD)
# NOTE: This reports "usable" memory, not physically installed memory
# (on some architectures).
#
# hw.physmem64 is available on NetBSD >= 2.0
/sbin/sysctl -n hw.physmem64 | bytes2kib
;;
(OpenBSD)
# NOTE: This reports "usable" memory, not physically installed memory
# (on some architectures).
sysctl -n hw.physmem | bytes2kib
;;
(SunOS)
# Make sure that awk from xpg4 is used for the scripts to work
Expand All @@ -81,10 +89,12 @@ in
then
# Use memory blocks if the architecture (e.g. x86, PPC64, s390)
# supports them (they denote physical memory)
num_mem_blocks=$(cat /sys/devices/system/memory/memory[0-9]*/state | grep -cxF online)
mem_block_size=$(cat /sys/devices/system/memory/block_size_bytes)

echo $((num_mem_blocks * 0x${mem_block_size})) | bytes2kib && exit
if num_mem_blocks=$(cat /sys/devices/system/memory/memory[0-9]*/state 2>/dev/null | grep -cxF online)
then
mem_block_size=$(cat /sys/devices/system/memory/block_size_bytes)
echo $((num_mem_blocks * 0x${mem_block_size})) | bytes2kib
exit 0
fi
fi
if test -r /proc/meminfo
then
Expand Down