-
Notifications
You must be signed in to change notification settings - Fork 0
/
FinalCollect.sh
executable file
·171 lines (146 loc) · 4.06 KB
/
FinalCollect.sh
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#!/bin/bash
# 1.OCS Get Manufacturer
get_cpu_mnfct() {
m=`sysctl -a | grep -i vendor | cut -d: -f2 | head -1 | sed 's/^ *//'`
export MANUFACTURER=`echo $m`
}
# 2.OCS Get CPU Type, Model and Frecuency. Global data
get_cpu_type() {
#t=`sysctl -a | grep -i brand | cut -d: -f2 | head -1 | tr -d '[:blank:]'`
t=`sysctl -a | grep -i brand | cut -d: -f2 | head -1 `
export TYPE=`echo $t`
}
# 3.OCS CPU Serial Number
get_cpu_id() {
s=`system_profiler SPHardwareDataType | grep UUID | cut -d : -f2 | sed 's/^ *//'`
export SERIALNUMBER=`echo $s`
}
# 4.OCS
get_cpu_speed() {
sp=`system_profiler SPHardwareDataType | grep "Processor Speed" | cut -d : -f2 | sed 's/^ *//' | tr -d '[:blank:]'`
export SPEED=`echo $sp`
}
# 5.OCS
get_cpu_cores() {
cor=`sysctl -a | grep machdep.cpu.core_count | cut -d: -f2 | sed 's/^ *//'`
export CORES=`echo $cor`
}
# 6.OCS
get_cpu_cachedos() {
eledos=`system_profiler SPHardwareDataType | grep -E "Cache" | cut -d : -f2 | sed 's/^ *//' | tr -d '[:blank:]'`
export L2CACHESIZE=`echo $eledos`
}
# 7.OCS
get_cpu_arch() {
ar=`uname -m`
export CPUARCH=`echo $ar`
}
# 8.OCS
get_cpu_data_width() {
dw=`sysctl -a | grep machdep.cpu.arch_perf.width | cut -d: -f2 | sed 's/^ *//'`
#dw=`sysctl -a | grep machdep.cpu.tlb.data.large_level1: | cut -d: -f2 | sed 's/^ *//'`
export DATA_WIDTH=`echo $dw`
}
# 9.OCS
get_cpu_current_addr_width() {
dw=`sysctl -a | grep machdep.cpu.tlb.data.large_level1: | cut -d: -f2 | sed 's/^ *//'`
export CURRENT_ADDRESS_WIDTH=`echo $dw`
}
# 10.OCS
get_cpu_logical() {
log=`sysctl -a | grep machdep.cpu.thread_count | cut -d: -f2 | sed 's/^ *//'`
export LOGICAL_CPUS=`echo $log`
}
# 11.OCS
get_cpu_volts() {
v=`dmidecode 2>&1 | grep Voltage | cut -d: -f2 | head -1 | sed 's/^ *//'| tr -d '[:blank:]'`
export VOLTAGE=`echo $v`
}
get_bus_speed() {
b=`system_profiler SPHardwareDataType | grep Bus | cut -d : -f2 | sed 's/^ *//'| tr -d '[:blank:]'`
export BUS_SPEED=`echo $b`
}
get_model_id() {
mid=`system_profiler SPHardwareDataType | grep "Model Id" | cut -d : -f2 | sed 's/^ *//'`
export MODEL_ID=`echo $mid`
}
get_model_name() {
min=`system_profiler SPHardwareDataType | grep "Model Name" | cut -d : -f2 | sed 's/^ *//'`
export MODEL_NAME=`echo $min`
}
#get_rom() {
# r=`system_profiler SPHardwareDataType | grep ROM | cut -d : -f2 | sed 's/^ *//'`
# export ROM=`echo $r`
#}
get_serial() {
sr=`system_profiler SPHardwareDataType | grep Serial | cut -d : -f2 | sed 's/^ *//'`
export SERIAL=`echo $sr`
}
get_smc() {
sm=`system_profiler SPHardwareDataType | grep SMC | cut -d : -f2 | sed 's/^ *//'`
export SMC=`echo $sm`
}
# 12.OCS
#get_cpu_cur_speed() {
# csp=$[`sysctl -a | grep hw.cpufrequency: | cut -d: -f2 | sed 's/^ *//'` / 1000000]
# export CURRENT_SPEED=`echo $csp`
#}
# 13.OCS
#get_cpu_socket() {
# soc=`dmidecode 2>&1| grep "Socket Designation:" | cut -d: -f2 | sed 's/^ *//'`
# export SOCKET=`echo $soc`
#}
# GET ALL FUNCTIOS
#get_query
get_cpu_mnfct
get_cpu_type
get_cpu_id
get_cpu_speed
get_cpu_cores
get_cpu_cachedos
get_cpu_arch
get_cpu_data_width
#get_cpu_current_addr_width
get_cpu_logical
get_cpu_volts
get_bus_speed
get_model_id
get_model_name
#get_rom
get_serial
get_smc
#get_cpu_cur_speed
#get_cpu_socket
declare -a INFO=("'$MANUFACTURER'" "'$TYPE'" "'$SERIALNUMBER'" "'$SPEED'" "'$CORES'" "'$L2CACHESIZE'" "'$CPUARCH'" "'$DATA_WIDTH'" "'$LOGICAL_CPUS'" "'$VOLTAGE'" "'$BUS_SPEED'" "'$MODEL_ID'" "'$MODEL_NAME'" "'$ROM'" "'$SERIAL'" "'$SMC'")
#echo ${#INFO[@]} #Number of elements in the array
#echo ${#INFO} #Number of characters in the first element of the array
#echo ${INFO[@]}
#echo ${INFO[@]/#/\`} #PREFIX
#echo ${INFO[@]/%/,} # CONTENT
echo ${INFO[0]/%/,}
echo ${INFO[1]/%/,}
echo ${INFO[2]/%/,}
echo ${INFO[3]/%/,}
echo ${INFO[4]/%/,}
echo ${INFO[5]/%/,}
echo ${INFO[6]/%/,}
echo ${INFO[7]/%/,}
echo ${INFO[8]/%/,}
echo ${INFO[9]/%/,}
echo ${INFO[10]/%/,}
echo ${INFO[11]/%/,}
echo ${INFO[12]/%/,}
#echo ${INFO[13]/%/,}
echo ${INFO[14]/%/,}
echo ${INFO[15]/%/;}
#echo ${INFO[16]/%/;}
#echo ""
#echo ""
#sleep 1
#for t in "${INFO[@]}"
#do
#echo $t
#done
#echo "esto es todo!"
#for t in "${INFO[@]}"
#printf "%s\n" "${INFO[@]}"