@cryptotaxi247 / netdata-1 / commits / 51f0ee6d9

Minor improvement to CPU number function regarding macOS. (#11746)

* Minor improvement to CPU number function regarding macOS. * elif was used instead of else

Igor Karpov committed Nov 8, 2021 at 16:42 UTC 51f0ee6d9a4d4c6a133b2b0cfa3c8ba8da38248e
1 file changed +7 -2
packaging/installer/functions.sh
+7 -2
@@ -224,17 +224,22 @@ safe_pidof() {
224
225 # -----------------------------------------------------------------------------
226 find_processors() {
227 - # Most UNIX systems have `nproc` as part of their userland (including macOS, Linux and BSD)
227 + # Most UNIX systems have `nproc` as part of their userland (including Linux and BSD)
228 if command -v nproc > /dev/null; then
229 nproc && return
230 fi
231
232 + # macOS has no nproc but it may have gnproc installed from Homebrew or from Macports.
233 + if command -v gnproc > /dev/null; then
234 + gnproc && return
235 + fi
236 +
237 local cpus
238 if [ -f "/proc/cpuinfo" ]; then
239 # linux
240 cpus=$(grep -c ^processor /proc/cpuinfo)
241 else
237 - # freebsd
242 + # freebsd
243 cpus=$(sysctl hw.ncpu 2> /dev/null | grep ^hw.ncpu | cut -d ' ' -f 2)
244 fi
245 if [ -z "${cpus}" ] || [ $((cpus)) -lt 1 ]; then