-
Notifications
You must be signed in to change notification settings - Fork 0
/
sysinfo.sh
356 lines (315 loc) · 12 KB
/
sysinfo.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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
#!/bin/dash
#Dependencies:
#lspci
#Optional Dependencies:
#lsusb Required for: USB Device list.
#lscpu Required for: Maximum CPU Clock speed.
#uname Required for: Basic system information (OS/Kernel/Arch/Hostname)
#mesa-demos (glxinfo) Required for: Detecting currently active GPU.
#lm_sensors (sensors) Required for: Detecting CPU Temps, and GPU temps on nouveau drivers.
#vulkan-tools (vulkaninfo) Required for: Detecting which graphics cards support vulkan and which versions of vulkan are available.
#TESTED ON:
#Manjaro
#Intel Desktop/Laptop
#Intel + Nvidia Dedicated/Optimus GPU(nvidia)
#UNTESTED:
#Ubuntu
#Debian
#CentOS
#AMD Desktop/Laptop
#AMD Dedicated GPU (Radeon, AMDGPU and Catalyst)
#AMD Integrated GPU (Radeon, AMDGPU and Catalyst)
#AMD + Nvidia Dedicated/Optimus GPU (nouveau and nvidia)
#AMD Hybrid Graphics (Radeon, AMDGPU and Catalyst)
#ATI Dedicated GPU (Radeon and FGLRX)
#Nvidia dedicated and optimus GPU (nouveau only)
#UNSUPPORTED:
#SLI/Crossfire
#AMD APU (Integrated Graphics).
if [ "$1" = "--less" ] || [ "$1" = "-l" ]; then #Add 'less' argument to display less information.
less=1
elif [ "$1" = "--help" ] || [ "$1" = "-h" ]; then #Help
echo "Usage: sysinfo [option]
Options:
--less Display less information.
-h --help Display this dialog."
exit
else
less=0
fi
#lspci depcheck
if [ -f /usr/bin/lscpu ]; then
CPUMax=$(lscpu | grep "max MHz" | cut -d: -f2 | sed 's: ::g' | cut -d ',' -f1)
else
echo "Error: lspci was not found, please install it for this script to work."
exit
fi
#lscpu depcheck
if [ -f /usr/bin/lscpu ]; then
:
else
echo "Please install lscpu to read CPU maximum frequency."
echo ""
fi
#Sensor depcheck
if [ -f /usr/bin/sensors ]; then
:
else
echo "Please install lm_sensors(sensors) to read CPU temperature values."
echo ""
fi
#GLXinfo depcheck
if [ -f /usr/bin/glxinfo ]; then
GPUActive=$(glxinfo 2>/dev/null | grep "renderer string" | cut -d ':' -f2)
GPUGLV=$(glxinfo 2>/dev/null | grep "OpenGL version" | cut -d ':' -f2)
GPUMem=$(glxinfo 2>/dev/null | grep "Video memory" | cut -d ' ' -f7)
else
echo "Please install mesa-demos(glxinfo) to read some of the graphics related values."
echo ""
fi
#Vulkaninfo depcheck
if [ -f /usr/bin/vulkaninfo ]; then
VKGPU=$(vulkaninfo 2>/dev/null | grep "GPU id =" | sed 's/^[[:blank:]]*GPU id = / /g' | sort -u)
VKVer=$(vulkaninfo 2>/dev/null | grep apiVersion | cut -d '(' -f2 | sed 's:)::g')
VKDrv=$(vulkaninfo 2>/dev/null | grep driverInfo | cut -d "=" -f2 | uniq)
else
echo "Please install vulkan-tools(vulkaninfo) to read information about vulkan."
echo ""
fi
PDV=$(cat /sys/devices/virtual/dmi/id/sys_vendor)
PDN=$(cat /sys/devices/virtual/dmi/id/product_name)
MBM=$(cat /sys/devices/virtual/dmi/id/board_vendor)
MBN=$(cat /sys/devices/virtual/dmi/id/board_name)
MBV=$(cat /sys/devices/virtual/dmi/id/board_version)
BIOS=$(echo "$(cat /sys/devices/virtual/dmi/id/bios_vendor) Version:$(cat /sys/devices/virtual/dmi/id/bios_version) ($(cat /sys/devices/virtual/dmi/id/bios_date))")
CPUname=$(cat /proc/cpuinfo | grep -m 1 "model name" | cut -d':' -f2)
CPUVendor=$(cat /proc/cpuinfo | grep -m 1 "vendor_id" | cut -d':' -f2 | sed 's: ::g')
CPUTotal=$(cat /proc/cpuinfo | grep -m 1 siblings | cut -d' ' -f2)
CPUPhysical=$(cat /proc/cpuinfo | grep -m 1 "cpu cores" | cut -d' ' -f3)
CPULogical=$(( $CPUTotal - $CPUPhysical ))
CPUPerf=$(</proc/cpuinfo awk -F : '/MHz/{printf " Core %d:%s MHz\n", n++, $2}')
if [ $CPUVendor=="GenuineIntel" ] && [ -f /usr/bin/sensors ]; then
CPUTemp=$(sensors | grep 'id 0:' -m1 | cut -d ':' -f2 | sed 's: +::g' | cut -d '(' -f1)
elif [ $CPUVendor=="AuthenticAMD" ] && [ -f /usr/bin/sensors ]; then
CPUTemp=$(sensors | grep -A3 k10temp | grep 'Tctl\|temp1' | cut -d '+' -f2 | cut -d '(' -f1)
fi
MemoryT=$(cat /proc/meminfo | grep -Po "MemTotal:\K.*?(?=\ kB)" | sed 's: ::g')
Memory=$(cat /proc/meminfo | grep -Po "MemAvailable:\K.*?(?=\ kB)" | sed 's: ::g')
SwapT=$(cat /proc/meminfo | grep -Po "SwapTotal:\K.*?(?=\ kB)" | sed 's: ::g')
Swap=$(cat /proc/meminfo | grep -Po "SwapFree:\K.*?(?=\ kB)" | sed 's: ::g')
HugeS=$(cat /proc/meminfo | grep -Po "Hugepagesize:\K.*?(?=\ kB)" | sed 's: ::g')
HugeT=$(($HugeS * $(cat /proc/meminfo | grep "HugePages_Total:" | cut -d ' ' -f8)))
if lspci | grep -m1 "VGA compatible controller: Intel" > /dev/null; then
GPUIntegrated=1
GPUIntmodel=$(lspci -v | grep "VGA compatible controller: Intel" | cut -b 36-150 | cut -d '(' -f1)
GPUIID=$(lspci | grep -m1 "VGA compatible controller: Intel" | cut -d 'V' -f1 | sed 's: ::g')
GPUIDriver=$(lspci -vs $GPUIID | grep use | cut -d ':' -f2)
GPUIPMem=$(lspci -vs $GPUIID | grep -m1 " prefetchable" | cut -d '=' -f2 | sed 's:]:B:g')
#GPUIMem=$(DRI_PRIME=0 __NV_PRIME_RENDER_OFFLOAD=0 glxinfo | grep "Video memory" | cut -d ' ' -f7)
GPUISLOT=$(lspci -n | grep $GPUIID | cut -d ' ' -f3)
else
GPUIntegrated=0
fi
if lspci | grep -m1 "VGA compatible controller: NVIDIA" > /dev/null; then
GPUDedicated=1
GPUModel="NVIDIA $(lspci | grep -m1 "VGA compatible controller: NVIDIA" | cut -d '[' -f2 | cut -d ']' -f1)"
GPUDID=$(lspci | grep -m1 "VGA compatible controller: NVIDIA" | cut -d 'V' -f1)
GPUDriver=$(lspci -vs $GPUDID | grep use | cut -d ':' -f2 | sed 's: ::g')
GPUSLOT=$(lspci -n | grep $GPUDID | cut -d ' ' -f3)
if [ "$GPUDriver" = "nvidia" ]; then
GPUMem=$(nvidia-smi | grep MiB -m1 | cut -d '|' -f3 | sed 's: ::g' | sed 's:/: / :g')
GPUPow=$(nvidia-smi | grep W | cut -d '/' -f2 | cut -c 14- | sed 's: ::g')
fi
if [ "$GPUDriver" = "nvidia" ]; then
GPUTemp=$(nvidia-smi -q | grep "GPU Current Temp" | cut -d ':' -f2 | sed 's/ C/°C/g' | sed 's: ::g')
elif [ -f /usr/bin/sensors ]; then
GPUTemp="$(sensors | grep -A10 'nouveau' | grep -m1 temp1 | cut -d '+' -f2 | cut -d '(' -f1)"
fi
elif lspci | grep -m1 "VGA compatible controller: Advanced" > /dev/null; then
GPUDedicated=1
GPUModel="AMD $(lspci | grep -m1 "VGA compatible controller: Advanced" | cut -d '[' -f3 | cut -d ']' -f1)"
GPUDID=$(lspci | grep -m1 "VGA compatible controller: Advanced" | cut -d 'V' -f1)
GPUDriver=$(lspci -vs $GPUDID | grep use | cut -d ':' -f2 | sed 's: ::g')
GPUMem=$(DRI_PRIME=1 glxinfo 2>/dev/null | grep "Video memory" | cut -d ' ' -f7)
if [ -f /usr/bin/sensors ]; then
GPUTemp=sensors | grep amdgpu -m1 -A5 | grep "°C" | cut -d '+' -f2
fi
elif lspci | grep -m1 "VGA compatible controller: ATI" > /dev/null; then
GPUDedicated=1
GPUModel="ATI $(lspci | grep -m1 "VGA compatible controller: ATI" | cut -d '[' -f3 | cut -d ']' -f1)"
GPUDID=$(lspci | grep -m1 "VGA compatible controller: ATI" | cut -d 'V' -f1)
GPUDriver=$(lspci -vs $GPUDID | grep use | cut -d ':' -f2 | sed 's: ::g')
GPUTemp="Not Supported for radeon/fglrx/catalyst"
else
GPUDedicated=0
fi
if [ $GPUDedicated -eq 0 ]; then
if lspci | grep -m1 "3D controller: NVIDIA" > /dev/null; then
GPUModel="NVIDIA $(lspci | grep -m1 "3D controller: NVIDIA" | cut -d '[' -f2 | cut -d ']' -f1)"
elif lspci | grep -m1 "Display controller: Advanced" > /dev/null; then
GPUModel="AMD $(lspci | grep -m1 "Display controller: Advanced" | cut -d '[' -f3 | cut -d ']' -f1)"
elif lspci | grep -m1 "Display controller: ATI" > /dev/null; then
GPUModel="ATI $(lspci | grep -m1 "Display controller: ATI" | cut -d '[' -f3 | cut -d ']' -f1)"
else
GPUModel="Not Available"
fi
fi
case $(cat /sys/devices/virtual/dmi/id/chassis_type) in
1) CHT="Other";;
2) CHT="Unknown";;
3) CHT="Desktop";;
4) CHT="Low Profile Desktop";;
5) CHT="Pizza Box";;
6) CHT="Mini Tower";;
7) CHT="Tower";;
8) CHT="Portable";;
9) CHT="Laptop";;
10) CHT="Notebook";;
11) CHT="Hand Held";;
12) CHT="Docking Station";;
13) CHT="All in One";;
14) CHT="Sub Notebook";;
15) CHT="Space-Saving";;
16) CHT="Lunch Box";;
17) CHT="Main System Chassis";;
18) CHT="Expansion Chassis";;
19) CHT="SubChassis";;
20) CHT="Bus Expansion Chassis";;
21) CHT="Peripheral Chassis";;
22) CHT="Storage Chassis";;
23) CHT="Rack Mount Chassis";;
24) CHT="Sealed-Case PC";;
esac
if [ -f /usr/bin/uname ]; then
echo "System Information:"
echo " Operating System: $(uname -o) $(uname -m)"
echo " Kernel: $(uname -r)"
echo " Hostname: $(uname -n)"
echo "" #Separator
fi
echo "Product Info:"
echo " Product Type: $CHT"
echo " Manufacturer: $PDV"
echo " Model Name: $PDN"
echo "" #Separator
echo "Motherboard:"
echo " Manufacturer: $MBM"
echo " Model: $MBN"
if [ $less -ne 1 ]; then
echo " Version: $MBV"
echo " BIOS: $BIOS"
fi
echo "" #Separator
echo "Processor:"
echo " Model:$CPUname"
echo " Threads: $CPUTotal"
echo " Physical Cores: $CPUPhysical"
echo " Logical Cores: $CPULogical"
if [ -f /usr/bin/sensors ]; then
echo " Temperature: $CPUTemp"
if [ $less -ne 1 ] && [ $CPUVendor=="GenuineIntel" ]; then
echo "$(sensors | grep Core | cut -d '(' -f1 | sed 's: +::g' | sed 's:Co: Co:g')"
fi
fi
if [ -f /usr/bin/lscpu ]; then
echo " Maximum Clock Speed: $CPUMax MHz"
fi
if [ $less -ne 1 ]; then
echo " Current Speeds:"
echo "$CPUPerf"
fi
echo "" #Separator
echo "Memory:"
echo " RAM: $(( $MemoryT / 1000 / 1000 ))GB" #Round to a 1000 to display a correctly rounded gigabyte value.
if [ $less -ne 1 ]; then
echo " RAM Reserved for VMs: $(( $HugeT / 1024 ))MB (HugePages)"
echo " RAM In Use: $((( $MemoryT - $Memory ) / 1024 ))MB"
echo " RAM Available: $(( $Memory / 1024 ))MB" #Not rounding to gigabytes because available memory may often be less than 1GB.
fi
echo " Swap: $(( $SwapT / 1024 ))MB"
if [ $less -ne 1 ]; then
echo " Swap In Use $((( $SwapT - $Swap) / 1024))MB"
echo " Swap Available: $(( $Swap / 1024 ))MB"
fi
echo "" #Separator
echo "Storage Devices:"
for x in `ls /sys/block/ `; do
if echo "$x" | grep -q "loop"; then
continue
fi
HDD=$(cat /sys/block/$x/queue/rotational)
echo " $(cat /sys/block/$x/device/model | sed 's/ *$//g') (/dev/$x): $(($(cat /sys/block/$x/size)*512/1024/1024/1024))GB"
done
echo "" #Separator
echo "Graphics:"
if [ $GPUIntegrated -eq 1 ]; then
echo " Integrated: $GPUIntmodel"
echo " Kernel Driver: $GPUIDriver"
echo " Preallocated Memory: $GPUIPMem"
# echo " Maximum Memory: $GPUIMem"
if [ $less -ne 1 ]; then
echo " PCI SLOT: $GPUISLOT"
echo " PCI ID: $GPUIID"
fi
else
echo " Integrated: Not Available"
fi
echo "" #Separator
if [ $GPUDedicated -eq 1 ]; then
echo " Dedicated: $GPUModel"
echo " Kernel Driver: $GPUDriver"
echo " Memory: $GPUMem"
echo " Temperature: $GPUTemp"
if [ $less -ne 1 ]; then
if [ "$GPUDriver" = "nvidia" ]; then
echo " Power Usage: $GPUPow"
fi
echo " PCI SLOT: $GPUSLOT"
echo " PCI ID: $GPUDID"
fi
else
echo " Dedicated: $GPUModel"
fi
if [ -f /usr/bin/glxinfo ]; then
echo "" #Separator
echo " Active 3D Graphics Controller:$GPUActive"
echo " OpenGL Version: $GPUGLV"
fi
if [ $less -ne 1 ]; then
if [ -f /usr/bin/glxinfo ] && [ -f /usr/bin/vulkaninfo ]; then
echo " Vulkan Compatible Graphics Cards:
$VKGPU"
echo " Vulkan Libraries:"
buf=1
vulkaninfo 2>/dev/null | grep driverName | cut -d "=" -f2 | uniq | while read -r line; do
printf " $((buf-1)): $line -"
printf "$VKDrv\n" | sed "$buf!d"
printf " Vulkan Version:"
printf "$VKVer" | sed "$buf!d"
buf=$(($buf+1))
done
echo ""
fi
if lspci | grep "Display controller" >/dev/null; then
GPUSwitch=$(lspci | grep -m1 "Display controller" | cut -d ':' -f3-6 | cut -d '(' -f1)
echo " Inactive: $GPUSwitch"
elif lspci | grep "3D controller" >/dev/null; then
GPUSwitch=$(lspci | grep -m1 "3D controller" | cut -d ':' -f3-6 | cut -d '(' -f1)
echo " Inactive: $GPUSwitch"
fi
echo "" #Separator
echo "PCI Network Controllers:"
echo "$(lspci | grep "Network" | sed 's=:=: =g'| cut -d ':' -f3)"
echo "$(lspci | grep "Ethernet" | sed 's=:=: =g'| cut -d ':' -f3)"
echo "" #Separator
echo "PCI Audio Devices:"
echo "$(lspci | grep "Audio" | sed 's=:=: =g'| cut -d ':' -f3)"
echo "" #Separator
if [ -f /usr/bin/lsusb ]; then
echo "USB Devices:"
echo "$(lsusb | cut -d ':' -f3 | cut -c 5- | grep -v "root hub" | sed 's/^/ /')"
else
echo "Please install lsusb to read USB Device List."
echo ""
fi
fi