pi-hole / PADD

PADD (formerly Chronometer2) is a more expansive version of the original chronometer.sh that is included with Pi-Hole. PADD provides in-depth information about your Pi-hole.
1.37k stars 121 forks source link

System agnostic CPU core count - tested on Pine64 #33

Closed atiensivu closed 5 years ago

atiensivu commented 6 years ago

Describe the bug Divide by 0 error because the string in /proc/cpuinfo does not exist outside of Raspberry Pi

To Reproduce

  1. Run PADD on a non-Pi device - in my case, a Pine64

Expected behavior Correct corecount

Additional context I fixed it by using the /sys tree version of cpu count - hopefully this is usable on most kernels

Code change:

CORES

coreCount=$(grep -c 'model name' /proc/cpuinfo)

declare -i coreCount=1 coreCount=$(cat /sys/devices/system/cpu/kernel_max 2> /dev/null)+1

This works for me - reports 4 cores which is correct.

https://github.com/atiensivu/PADD/tree/atiensivu-patch-1

tgjohnst commented 6 years ago

Thanks! Confirmed that this also returns the correct CPU count (4) when run on a Pi B+ - should be good to make a PR.

jpmck commented 5 years ago

Thanks Aaron and Tim! I made a PR for this and it will be in the next release.