-
Notifications
You must be signed in to change notification settings - Fork 0
/
cpuinfo
executable file
·43 lines (35 loc) · 1.31 KB
/
cpuinfo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/sh
#
# Copyright 2015 Olivier van Helden <[email protected]>
# Released under GNU Affero GPL v3.0 license
# http://www.gnu.org/licenses/agpl-3.0.html
PGM=$(basename "$0")
TMP=/tmp/$PGM.$$
export PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin
which dmidecode >/dev/null && {
dmidecode -t processor | egrep ":" | sed "s/^[[:blank:]]*//" | sed "s/: */:/" | while read line
do
var=$(echo "$line" | cut -d ":" -f 1 | sed "s/ //g")
value=$(echo "$line" | cut -d ":" -f 2-)
echo "$var='$value'"
done > $TMP.vars
[ -f "$TMP.vars" ] && . "$TMP.vars"
[ $CoreCount -gt 1 ] && cores=" ($CoreCount cores)"
memory=$(free -b | grep "^Mem:" | while read f mem f; do echo $mem; done)
# memprint=$(printf "%'.3f\n" "$memory")
memprint=$(echo "$memory" | sed -e ': L
s/\([0-9]\{1,19\}\)\([0-9]\{3\}\)/\1,\2/
t L')
echo "$Version$cores $memprint" | grep "CPU @" && rm $TMP.* && exit
echo "$Manufacturer $Family $Version @ $CurrentSpeed $memory"
} || {
Version=$(sysctl -n machdep.cpu.brand_string)
CoreCount=$(sysctl -n machdep.cpu.core_count)
[ $CoreCount -gt 1 ] && cores=" ($CoreCount cores)"
memory=$(sysctl -n hw.memsize)
memprint=$(echo "$memory" | sed -e ': L
s/\([0-9]\{1,19\}\)\([0-9]\{3\}\)/\1,\2/
t L')
echo "$Version$cores $memprint"
}
rm -f $TMP.*