-
Notifications
You must be signed in to change notification settings - Fork 56
Expand file tree
/
Copy pathscripts.go
More file actions
2065 lines (1955 loc) · 71 KB
/
scripts.go
File metadata and controls
2065 lines (1955 loc) · 71 KB
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
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright (C) 2021-2025 Intel Corporation
// SPDX-License-Identifier: BSD-3-Clause
package script
import (
"bytes"
"perfspect/internal/cpus"
texttemplate "text/template" // nosemgrep
)
// scripts.go defines the bash scripts that are used to collect information from target systems
type ScriptDefinition struct {
Name string // just a name
ScriptTemplate string // the bash script that will be run
Architectures []string // architectures, i.e., x86_64, aarch64. If empty, it will run on all architectures.
Vendors []string // vendors, i.e., GenuineIntel, AuthenticAMD. If empty, it will run on all vendors.
MicroArchitectures []string // microarchitectures, e.g., SPR, EMR. If empty, it will run on all microarchitectures.
Lkms []string // loadable kernel modules
Depends []string // binary dependencies that must be available for the script to run
Superuser bool // requires sudo or root
Sequential bool // run script sequentially (not at the same time as others)
}
// script names, these must be unique
const (
// report and configuration (reading) scripts
HostnameScriptName = "hostname"
DateScriptName = "date"
DmidecodeScriptName = "dmidecode"
LscpuScriptName = "lscpu"
LscpuCacheScriptName = "lscpu cache"
LspciBitsScriptName = "lspci bits"
LspciDevicesScriptName = "lspci devices"
LspciVmmScriptName = "lspci vmm"
UnameScriptName = "uname"
ProcCmdlineScriptName = "proc cmdline"
ProcCpuinfoScriptName = "proc cpuinfo"
SysctlScriptName = "sysctl"
EtcReleaseScriptName = "etc release"
GccVersionScriptName = "gcc version"
BinutilsVersionScriptName = "binutils version"
GlibcVersionScriptName = "glibc version"
PythonVersionScriptName = "python version"
Python3VersionScriptName = "python3 version"
JavaVersionScriptName = "java version"
OpensslVersionScriptName = "openssl version"
CpuidScriptName = "cpuid"
BaseFrequencyScriptName = "base frequency"
ScalingDriverScriptName = "scaling driver"
ScalingGovernorScriptName = "scaling governor"
CstatesScriptName = "c-states"
C1DemotionScriptName = "c1 demotion"
SpecCoreFrequenciesScriptName = "spec core frequencies"
PPINName = "ppin"
PrefetchControlName = "prefetch control"
PrefetchersName = "prefetchers"
PrefetchersAtomName = "prefetchers atom"
L3CacheWayEnabledName = "l3 way enabled"
PackagePowerLimitName = "package power limit"
EpbScriptName = "energy performance bias"
EpbSourceScriptName = "energy performance bias source"
EppScriptName = "energy performance preference"
EppValidScriptName = "epp valid"
EppPackageControlScriptName = "epp package control"
EppPackageScriptName = "energy performance preference package"
IaaDevicesScriptName = "iaa devices"
DsaDevicesScriptName = "dsa devices"
LshwScriptName = "lshw"
UncoreMaxFromMSRScriptName = "uncore max from msr"
UncoreMinFromMSRScriptName = "uncore min from msr"
UncoreMaxFromTPMIScriptName = "uncore max from tpmi"
UncoreMinFromTPMIScriptName = "uncore min from tpmi"
UncoreDieTypesFromTPMIScriptName = "uncore die types from tpmi"
ElcScriptName = "efficiency latency control"
SSTTFHPScriptName = "ssttf hp frequencies"
SSTTFLPScriptName = "ssttf lp frequencies"
ChaCountScriptName = "cha count"
MeminfoScriptName = "meminfo"
TransparentHugePagesScriptName = "transparent huge pages"
NumaBalancingScriptName = "numa balancing"
NicInfoScriptName = "nic info"
IRQBalanceScriptName = "irq balance"
DiskInfoScriptName = "disk info"
HdparmScriptName = "hdparm"
DfScriptName = "df"
FindMntScriptName = "findmnt"
CveScriptName = "cve"
ProcessListScriptName = "process list"
IpmitoolSensorsScriptName = "ipmitool sensors"
IpmitoolChassisScriptName = "ipmitool chassis"
IpmitoolEventsScriptName = "ipmitool events"
TmeScriptName = "tme"
KernelLogScriptName = "kernel log"
PMUDriverVersionScriptName = "pmu driver version"
PMUBusyScriptName = "pmu busy"
GaudiInfoScriptName = "gaudi info"
GaudiFirmwareScriptName = "gaudi firmware"
GaudiNumaScriptName = "gaudi numa"
GaudiArchitectureScriptName = "gaudi architecture"
ArmImplementerScriptName = "arm implementer"
ArmPartScriptName = "arm part"
ArmDmidecodePartScriptName = "arm dmidecode part"
// benchmark scripts
MemoryLoadedLatencyBenchmarkScriptName = "memory loaded latency benchmark"
MemoryNUMABandwidthMatrixBenchmarkScriptName = "memory numa bandwidth matrix benchmark"
MemoryNUMALatencyMatrixBenchmarkScriptName = "memory numa latency matrix benchmark"
L1IdleLatencyBenchmarkScriptName = "l1 idle latency benchmark"
L2IdleLatencyBenchmarkScriptName = "l2 idle latency benchmark"
L3IdleLatencyBenchmarkScriptName = "l3 idle latency benchmark"
L1MaxBandwidthBenchmarkScriptName = "l1 max bandwidth benchmark"
L2MaxBandwidthBenchmarkScriptName = "l2 max bandwidth benchmark"
L3MaxBandwidthBenchmarkScriptName = "l3 max bandwidth benchmark"
SpeedBenchmarkScriptName = "speed benchmark"
FrequencyBenchmarkScriptName = "frequency benchmark"
PowerBenchmarkScriptName = "power benchmark"
IdlePowerBenchmarkScriptName = "idle power benchmark"
StorageBenchmarkScriptName = "storage benchmark"
// telemetry scripts
MpstatTelemetryScriptName = "mpstat telemetry"
IostatTelemetryScriptName = "iostat telemetry"
MemoryTelemetryScriptName = "memory telemetry"
NetworkTelemetryScriptName = "network telemetry"
TurbostatTelemetryScriptName = "turbostat telemetry"
InstructionTelemetryScriptName = "instruction telemetry"
GaudiTelemetryScriptName = "gaudi telemetry"
PDUTelemetryScriptName = "pdu telemetry"
KernelTelemetryScriptName = "kernel telemetry"
SyscallsTelemetryScriptName = "syscalls telemetry"
// flamegraph scripts
FlameGraphScriptName = "flamegraph"
// lock scripts
ProfileKernelLockScriptName = "profile kernel lock"
)
// GetScriptByName returns the script definition with the given name. It will panic if the script is not found.
func GetScriptByName(name string) ScriptDefinition {
return GetParameterizedScriptByName(name, nil)
}
// GetParameterizedScriptByName returns the script definition with the given name. It will panic if the script is not found.
func GetParameterizedScriptByName(name string, params map[string]string) ScriptDefinition {
// if the script doesn't exist, panic
if _, ok := scriptDefinitions[name]; !ok {
panic("script not found: " + name)
}
if params == nil {
params = make(map[string]string)
}
// augment params with script name
params["ScriptName"] = sanitizeScriptName(name)
// replace the script template with the parameterized version
scriptTemplate := texttemplate.Must(texttemplate.New("scriptTemplate").Parse(scriptDefinitions[name].ScriptTemplate))
buf := new(bytes.Buffer)
err := scriptTemplate.Execute(buf, params)
if err != nil {
panic(err)
}
scriptDefinition := scriptDefinitions[name]
scriptDefinition.ScriptTemplate = buf.String()
return scriptDefinition
}
// mlc benchmark script constants (buffer setup snippets passed into mlcBenchmarkScript)
const (
// for measuring memory bandwidth and latency (2x of L3 cache size)
mlcBufferSetupMemory = `L3_KB=$(cache_size_kb L3)
BUF_KB=$(( L3_KB * 2 ))
[ $BUF_KB -lt 1 ] && BUF_KB=1`
// for measuring L1 bandwidth and latency (half of L1D cache size minus 4KB)
mlcBufferSetupL1 = `L1D_KB=$(cache_size_kb L1D)
BUF_KB=$(( L1D_KB / 2 - 4 ))
[ $BUF_KB -lt 1 ] && BUF_KB=1`
// for measuring L2 bandwidth and latency (half of L2 cache size)
mlcBufferSetupL2 = `L2_KB=$(cache_size_kb L2)
BUF_KB=$(( L2_KB / 2 ))
[ $BUF_KB -lt 1 ] && BUF_KB=1`
// for measuring L3 idle latency (4x of L2 cache size, single thread)
mlcBufferSetupL3 = `L2_KB=$(cache_size_kb L2)
BUF_KB=$(( L2_KB * 4 ))
[ $BUF_KB -lt 1 ] && BUF_KB=1`
// for measuring L3 max bandwidth (80% of per-thread L3 share, all threads)
mlcBufferSetupL3BW = `L2_KB=$(cache_size_kb L2)
L3_KB=$(cache_size_kb L3)
TPC=$(lscpu | grep 'Thread(s) per core' | awk '{print $NF}')
CPS=$(lscpu | grep -E 'Core\(s\) per socket:' | head -1 | awk '{print $4}')
TOTAL=$(( TPC * CPS ))
BUF_KB=$(( L3_KB * 8 / 10 / TOTAL ))
MIN_KB=$(( L2_KB / TPC + 1 ))
[ $BUF_KB -lt $MIN_KB ] && BUF_KB=$MIN_KB
[ $BUF_KB -lt 1 ] && BUF_KB=1`
)
// mlcBenchmarkScript returns the full bash script for an MLC memory/cache benchmark.
// bufferSetup: bash that sets BUF_KB (and ensures min 1). MLC -b is kB by default; append 'm' for MB.
// mlcInvocation: exact arguments to mlc (e.g. "--loaded_latency -b${BUF_KB} -X"). Enables
// different flags for memory vs cache; can be updated per script when cache flags are finalized.
func mlcBenchmarkScript(bufferSetup, mlcInvocation string) string {
return `cache_size_kb() {
local one_size
one_size=$(lscpu -C 2>/dev/null | awk -v level="$1" '$1==level {print $2; exit}')
if [ -z "$one_size" ]; then echo 1; return; fi
# Parse lscpu size (e.g. 32K, 1M, 2G): M->KB (v*1024, min 1), K->as-is (min 1), G->KB ($1*1024*1024), else 1
echo "$one_size" | awk '/M$/{gsub(/M/,""); v=$1+0; printf "%.0f", (v<0.001?1:v*1024); exit} /K$/{gsub(/K/,""); v=$1+0; printf "%.0f", (v<1?1:v); exit} /G$/{gsub(/G/,""); printf "%.0f", $1*1024*1024; exit} {print 1}'
}
` +
bufferSetup + "\n" +
`min_kb=2097152
numa_nodes=$( lscpu | grep "NUMA node(s):" | awk '{print $3}' )
size_huge_pages_kb=$( grep Hugepagesize /proc/meminfo | awk '{print $2}' )
orig_num_huge_pages=$( cat /proc/sys/vm/nr_hugepages )
needed_num_huge_pages=$((numa_nodes * min_kb / size_huge_pages_kb))
if [ $needed_num_huge_pages -gt $orig_num_huge_pages ]; then
echo $needed_num_huge_pages > /proc/sys/vm/nr_hugepages
fi
` +
"mlc " + mlcInvocation + "\n" +
"echo $orig_num_huge_pages > /proc/sys/vm/nr_hugepages\n"
}
// script definitions
var scriptDefinitions = map[string]ScriptDefinition{
// report and configuration (read) scripts
HostnameScriptName: {
Name: HostnameScriptName,
ScriptTemplate: "hostname",
},
DateScriptName: {
Name: DateScriptName,
ScriptTemplate: "date",
},
DmidecodeScriptName: {
Name: DmidecodeScriptName,
ScriptTemplate: "dmidecode",
Superuser: true,
Depends: []string{"dmidecode"},
},
LscpuScriptName: {
Name: LscpuScriptName,
ScriptTemplate: "lscpu",
},
LscpuCacheScriptName: {
Name: LscpuCacheScriptName,
ScriptTemplate: `lscpu -C`,
},
LspciBitsScriptName: {
Name: LspciBitsScriptName,
ScriptTemplate: `lspci -s $(lspci | grep 325b | awk 'NR==1{{"{"}}print $1{{"}"}}') -xxx | awk '$1 ~ /^90/{{"{"}}print $9 $8 $7 $6; exit{{"}"}}'`,
MicroArchitectures: []string{cpus.UarchSPR, cpus.UarchEMR},
Superuser: true,
Depends: []string{"lspci"},
},
LspciDevicesScriptName: {
Name: LspciDevicesScriptName,
ScriptTemplate: "lspci -d 8086:3258 | wc -l",
MicroArchitectures: []string{cpus.UarchGNR, cpus.UarchGNR_D, cpus.UarchSRF, cpus.UarchCWF, cpus.UarchDMR},
Depends: []string{"lspci"},
},
LspciVmmScriptName: {
Name: LspciVmmScriptName,
ScriptTemplate: "lspci -i pci.ids.gz -vmm",
Depends: []string{"lspci", "pci.ids.gz"},
},
UnameScriptName: {
Name: UnameScriptName,
ScriptTemplate: "uname -a",
},
ProcCmdlineScriptName: {
Name: ProcCmdlineScriptName,
ScriptTemplate: "cat /proc/cmdline",
},
ProcCpuinfoScriptName: {
Name: ProcCpuinfoScriptName,
ScriptTemplate: "cat /proc/cpuinfo",
},
SysctlScriptName: {
Name: SysctlScriptName,
ScriptTemplate: "sysctl -a",
Superuser: true,
}, EtcReleaseScriptName: {
Name: EtcReleaseScriptName,
ScriptTemplate: "cat /etc/*-release",
},
GccVersionScriptName: {
Name: GccVersionScriptName,
ScriptTemplate: "gcc --version",
},
BinutilsVersionScriptName: {
Name: BinutilsVersionScriptName,
ScriptTemplate: "ld -v",
},
GlibcVersionScriptName: {
Name: GlibcVersionScriptName,
ScriptTemplate: "ldd --version",
},
PythonVersionScriptName: {
Name: PythonVersionScriptName,
ScriptTemplate: "python --version 2>&1",
},
Python3VersionScriptName: {
Name: Python3VersionScriptName,
ScriptTemplate: "python3 --version",
},
JavaVersionScriptName: {
Name: JavaVersionScriptName,
ScriptTemplate: "java -version 2>&1",
},
OpensslVersionScriptName: {
Name: OpensslVersionScriptName,
ScriptTemplate: "openssl version",
},
CpuidScriptName: {
Name: CpuidScriptName,
ScriptTemplate: "cpuid -1",
Lkms: []string{"cpuid"},
Depends: []string{"cpuid"},
Superuser: true,
},
BaseFrequencyScriptName: {
Name: BaseFrequencyScriptName,
ScriptTemplate: "cat /sys/devices/system/cpu/cpu0/cpufreq/base_frequency",
},
ScalingDriverScriptName: {
Name: ScalingDriverScriptName,
ScriptTemplate: "cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_driver",
},
ScalingGovernorScriptName: {
Name: ScalingGovernorScriptName,
ScriptTemplate: "cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor",
},
CstatesScriptName: {
Name: CstatesScriptName,
ScriptTemplate: `# Directory where C-state information is stored
cstate_dir="/sys/devices/system/cpu/cpu0/cpuidle"
# Check if the directory exists
if [ -d "$cstate_dir" ]; then
for state in "$cstate_dir"/state*; do
name=$(cat "$state/name")
disable=$(cat "$state/disable")
if [ "$disable" -eq 0 ]; then
status="Enabled"
else
status="Disabled"
fi
echo "$name,$status"
done
else
echo "C-state directory not found."
fi
`,
},
C1DemotionScriptName: {
Name: C1DemotionScriptName,
ScriptTemplate: `# if both bit 26 and bit 28 are set then C1 demotion is enabled
bit26=$(rdmsr -f 26:26 0xe2 2>/dev/null)
bit28=$(rdmsr -f 28:28 0xe2 2>/dev/null)
if [[ "$bit26" == "1" && "$bit28" == "1" ]]; then
echo "Enabled"
elif [[ "$bit26" == "0" && "$bit28" == "0" ]]; then
echo "Disabled"
else
exit 1
fi
`,
Vendors: []string{cpus.IntelVendor},
Lkms: []string{"msr"},
Depends: []string{"rdmsr"},
Superuser: true,
},
SpecCoreFrequenciesScriptName: {
Name: SpecCoreFrequenciesScriptName,
ScriptTemplate: `lscpu=$(lscpu)
family=$(echo "$lscpu" | grep -E "^CPU family:" | awk '{print $3}')
model=$(echo "$lscpu" | grep -E "^Model:" | awk '{print $2}')
# if cpu is GNR, GNR-D, or DMR get the frequencies from tpmi
if ( [ "$family" -eq 6 ] && [ "$model" -eq 173 ] ) || ( [ "$family" -eq 6 ] && [ "$model" -eq 174 ] ) || ( [ "$family" -eq 19 ] && [ "$model" -eq 1 ] ); then # GNR, GNR-D, DMR
cores=$(pcm-tpmi 0x5 0xD8 -i 0 -e 0 | tail -n 2 | head -n 1 | awk '{print $3}') # SST_PP_INFO_10
# this works unless the TRL is overridden on MSR 0x1AD --> sse=$(pcm-tpmi 0x5 0xA8 -i 0 -e 0 | tail -n 2 | head -n 1 | awk '{print $3}') # SST_PP_INFO_4
sse=$(rdmsr 0x1ad) # MSR_TURBO_RATIO_LIMIT: Maximum Ratio Limit of Turbo Mode
avx2=$(pcm-tpmi 0x5 0xB0 -i 0 -e 0 | tail -n 2 | head -n 1 | awk '{print $3}') # SST_PPINFO_5
avx512=$(pcm-tpmi 0x5 0xB8 -i 0 -e 0 | tail -n 2 | head -n 1 | awk '{print $3}') # SST_PPINFO_6
avx512h=$(pcm-tpmi 0x5 0xC0 -i 0 -e 0 | tail -n 2 | head -n 1 | awk '{print $3}') # SST_PPINFO_7
amx=$(pcm-tpmi 0x5 0xC8 -i 0 -e 0 | tail -n 2 | head -n 1 | awk '{print $3}') # SST_PPINFO_8
elif [ "$family" -eq 6 ] && ( [ "$model" -eq 175 ] || [ "$model" -eq 221 ] ); then # SRF, CWF
cores=$(rdmsr 0x1ae) # MSR_TURBO_GROUP_CORE_CNT: Group Size of Active Cores for Turbo Mode Operation
# if pstate driver is intel_pstate use 0x774 else use 0x199
driver=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_driver)
if [ "$driver" = "intel_pstate" ]; then
sse=$(rdmsr 0x774 -f 15:8) # IA32_HWP_REQUEST
else
sse=$(rdmsr 0x199 -f 15:8) # IA32_PERF_CTL
fi
avx2=0
avx512=0
avx512h=0
amx=0
else # not SRF, CWF or GNR
cores=$(rdmsr 0x1ae) # MSR_TURBO_GROUP_CORE_CNT: Group Size of Active Cores for Turbo Mode Operation
sse=$(rdmsr 0x1ad) # MSR_TURBO_RATIO_LIMIT: Maximum Ratio Limit of Turbo Mode
avx2=0
avx512=0
avx512h=0
amx=0
fi
echo "cores sse avx2 avx512 avx512h amx"
echo "$cores" "$sse" "$avx2" "$avx512" "$avx512h" "$amx"`,
Vendors: []string{cpus.IntelVendor},
Lkms: []string{"msr"},
Depends: []string{"rdmsr", "pcm-tpmi"},
Superuser: true,
},
PPINName: {
Name: PPINName,
ScriptTemplate: "rdmsr -a 0x4f", // MSR_PPIN: Protected Processor Inventory Number
Vendors: []string{cpus.IntelVendor},
Lkms: []string{"msr"},
Depends: []string{"rdmsr"},
Superuser: true,
},
PrefetchControlName: {
Name: PrefetchControlName,
ScriptTemplate: "rdmsr -f 7:0 0x1a4", // MSR_PREFETCH_CONTROL: L2, DCU, and AMP Prefetchers enabled/disabled
Vendors: []string{cpus.IntelVendor},
Lkms: []string{"msr"},
Depends: []string{"rdmsr"},
Superuser: true,
},
PrefetchersName: {
Name: PrefetchersName,
ScriptTemplate: "rdmsr 0x6d", // TODO: get name, used to read prefetchers
Vendors: []string{cpus.IntelVendor},
Lkms: []string{"msr"},
Depends: []string{"rdmsr"},
Superuser: true,
},
PrefetchersAtomName: {
Name: PrefetchersAtomName,
ScriptTemplate: "rdmsr 0x1320", // Atom Pref_tuning1
Vendors: []string{cpus.IntelVendor},
MicroArchitectures: []string{cpus.UarchSRF, cpus.UarchCWF}, // SRF, CWF
Lkms: []string{"msr"},
Depends: []string{"rdmsr"},
Superuser: true,
},
L3CacheWayEnabledName: {
Name: L3CacheWayEnabledName,
ScriptTemplate: "rdmsr 0xc90", // TODO: get name, used to read l3 size
Vendors: []string{cpus.IntelVendor},
Lkms: []string{"msr"},
Depends: []string{"rdmsr"},
Superuser: true,
},
PackagePowerLimitName: {
Name: PackagePowerLimitName,
ScriptTemplate: "rdmsr -f 14:0 0x610", // MSR_PKG_POWER_LIMIT: Package limit in bits 14:0
Vendors: []string{cpus.IntelVendor},
Lkms: []string{"msr"},
Depends: []string{"rdmsr"},
Superuser: true,
},
EpbSourceScriptName: {
Name: EpbSourceScriptName,
ScriptTemplate: "rdmsr -f 34:34 0x1FC", // MSR_POWER_CTL, PWR_PERF_TUNING_ALT_EPB: Energy Performance Bias Hint Source (1 is from BIOS, 0 is from OS)
Vendors: []string{cpus.IntelVendor},
Lkms: []string{"msr"},
Depends: []string{"rdmsr"},
Superuser: true,
}, EpbScriptName: {
Name: EpbScriptName,
ScriptTemplate: `# get EPB source
# MSR_POWER_CTL, PWR_PERF_TUNING_ALT_EPB: Energy Performance Bias Hint Source (1 is from BIOS, 0 is from OS)
if ! source=$(rdmsr -f 34:34 0x1FC); then
echo "Error: Failed to read MSR 0x1FC" >&2
exit 1
fi
if [ "$source" -eq 1 ]; then
# get EPB from BIOS
# ENERGY_PERF_BIAS_CONFIG, ALT_ENERGY_PERF_BIAS: Energy Performance Bias Hint from BIOS (0 is highest perf, 15 is highest energy saving)
if ! epb=$(rdmsr -f 6:3 0xA01); then
echo "Error: Failed to read MSR 0xA01" >&2
exit 1
fi
else
# get EPB from OS
# IA32_ENERGY_PERF_BIAS: Energy Performance Bias Hint (0 is highest perf, 15 is highest energy saving))
if ! epb=$(rdmsr -f 3:0 0x1B0); then
echo "Error: Failed to read MSR 0x1B0" >&2
exit 1
fi
fi
echo "$epb"`,
Vendors: []string{cpus.IntelVendor},
Lkms: []string{"msr"},
Depends: []string{"rdmsr"},
Superuser: true,
},
EppValidScriptName: {
Name: EppValidScriptName,
ScriptTemplate: "rdmsr -a -f 60:60 0x774", // IA32_HWP_REQUEST: Energy Performance Preference, bit 60 indicates if per-cpu EPP is valid
Vendors: []string{cpus.IntelVendor},
Lkms: []string{"msr"},
Depends: []string{"rdmsr"},
Superuser: true,
},
EppPackageControlScriptName: {
Name: EppPackageControlScriptName,
ScriptTemplate: "rdmsr -a -f 42:42 0x774", // IA32_HWP_REQUEST: Energy Performance Preference, bit 42 indicates if package control is enabled
Vendors: []string{cpus.IntelVendor},
Lkms: []string{"msr"},
Depends: []string{"rdmsr"},
Superuser: true,
},
EppScriptName: {
Name: EppScriptName,
ScriptTemplate: "rdmsr -a -f 31:24 0x774", // IA32_HWP_REQUEST: Energy Performance Preference, bits 24-31 (0 is highest perf, 255 is highest energy saving)
Vendors: []string{cpus.IntelVendor},
Lkms: []string{"msr"},
Depends: []string{"rdmsr"},
Superuser: true,
},
EppPackageScriptName: {
Name: EppPackageScriptName,
ScriptTemplate: "rdmsr -f 31:24 0x772", // IA32_HWP_REQUEST_PKG: Energy Performance Preference, bits 24-31 (0 is highest perf, 255 is highest energy saving)
Vendors: []string{cpus.IntelVendor},
Lkms: []string{"msr"},
Depends: []string{"rdmsr"},
Superuser: true,
},
UncoreMaxFromMSRScriptName: {
Name: UncoreMaxFromMSRScriptName,
ScriptTemplate: "rdmsr -f 6:0 0x620", // MSR_UNCORE_RATIO_LIMIT: MAX_RATIO in bits 6:0
Vendors: []string{cpus.IntelVendor},
Lkms: []string{"msr"},
Depends: []string{"rdmsr"},
Superuser: true,
},
UncoreMinFromMSRScriptName: {
Name: UncoreMinFromMSRScriptName,
ScriptTemplate: "rdmsr -f 14:8 0x620", // MSR_UNCORE_RATIO_LIMIT: MAX_RATIO in bits 14:8
Vendors: []string{cpus.IntelVendor},
Lkms: []string{"msr"},
Depends: []string{"rdmsr"},
Superuser: true,
},
UncoreMaxFromTPMIScriptName: {
Name: UncoreMaxFromTPMIScriptName,
ScriptTemplate: "pcm-tpmi 2 0x18 -d -b 8:14",
MicroArchitectures: []string{cpus.UarchGNR, cpus.UarchGNR_D, cpus.UarchSRF, cpus.UarchCWF, cpus.UarchDMR},
Depends: []string{"pcm-tpmi"},
Superuser: true,
},
UncoreMinFromTPMIScriptName: {
Name: UncoreMinFromTPMIScriptName,
ScriptTemplate: "pcm-tpmi 2 0x18 -d -b 15:21",
MicroArchitectures: []string{cpus.UarchGNR, cpus.UarchGNR_D, cpus.UarchSRF, cpus.UarchCWF, cpus.UarchDMR},
Depends: []string{"pcm-tpmi"},
Superuser: true,
},
UncoreDieTypesFromTPMIScriptName: {
Name: UncoreDieTypesFromTPMIScriptName,
ScriptTemplate: "pcm-tpmi 2 0x10 -d -b 26:26",
MicroArchitectures: []string{cpus.UarchGNR, cpus.UarchGNR_D, cpus.UarchSRF, cpus.UarchCWF, cpus.UarchDMR},
Depends: []string{"pcm-tpmi"},
Superuser: true,
},
ElcScriptName: {
Name: ElcScriptName,
ScriptTemplate: `# Script derived from bhs-power-mode script in Intel PCM repository
# Run the pcm-tpmi command to determine I/O and compute dies
output=$(pcm-tpmi 2 0x10 -d -b 26:26)
# Parse the output to build lists of I/O and compute dies
# Store as "instance:entry" to handle multiple instances per socket
io_dies=()
compute_dies=()
declare -A die_types
while read -r line; do
if [[ $line == *"entry"* && $line == *"instance"* ]]; then
entry=$(echo "$line" | grep -oP 'entry \K[0-9]+')
instance=$(echo "$line" | grep -oP 'instance \K[0-9]+')
die_key="${instance}:${entry}"
if [[ $line == *"value 1"* ]]; then
die_types[$die_key]="IO"
io_dies+=("$die_key")
elif [[ $line == *"value 0"* ]]; then
die_types[$die_key]="Compute"
compute_dies+=("$die_key")
fi
fi
done <<< "$output"
# Function to extract and calculate metrics from the value
extract_and_print_metrics() {
local value=$1
local socket_id=$2
local die_key=$3
local die_type=${die_types[$die_key]}
# Extract instance and entry from die_key
local inst="${die_key%:*}"
local entry="${die_key#*:}"
# Extract bits and calculate metrics
local min_ratio=$(( (value >> 15) & 0x7F ))
local max_ratio=$(( (value >> 8) & 0x7F ))
local eff_latency_ctrl_ratio=$(( (value >> 22) & 0x7F ))
local eff_latency_ctrl_low_threshold=$(( (value >> 32) & 0x7F ))
local eff_latency_ctrl_high_threshold=$(( (value >> 40) & 0x7F ))
local eff_latency_ctrl_high_threshold_enable=$(( (value >> 39) & 0x1 ))
# Convert to MHz or percentage
min_ratio=$(( min_ratio * 100 ))
max_ratio=$(( max_ratio * 100 ))
eff_latency_ctrl_ratio=$(( eff_latency_ctrl_ratio * 100 ))
eff_latency_ctrl_low_threshold=$(( (eff_latency_ctrl_low_threshold * 100) / 127 ))
eff_latency_ctrl_high_threshold=$(( (eff_latency_ctrl_high_threshold * 100) / 127 ))
# Print metrics
echo -n "$socket_id,$inst,$entry,$die_type,$min_ratio,$max_ratio,$eff_latency_ctrl_ratio,"
echo "$eff_latency_ctrl_low_threshold,$eff_latency_ctrl_high_threshold,$eff_latency_ctrl_high_threshold_enable"
}
# Print CSV header
echo "Socket,Instance,Die,Type,Min Ratio (MHz),Max Ratio (MHz),ELC Ratio (MHz),ELC Low Threshold (%),ELC High Threshold (%),ELC High Threshold Enable"
# Iterate over all dies and run pcm-tpmi for each to get the metrics
for die_key in "${!die_types[@]}"; do
instance="${die_key%:*}"
entry="${die_key#*:}"
output=$(pcm-tpmi 2 0x18 -d -i "$instance" -e "$entry")
# Parse the output and extract metrics for each socket
while read -r line; do
if [[ $line == *"Read value"* ]]; then
value=$(echo "$line" | grep -oP 'value \K[0-9]+')
# Extract instance ID
inst=$(echo "$line" | grep -oP 'instance \K[0-9]+')
# Extract entry ID
ent=$(echo "$line" | grep -oP 'entry \K[0-9]+')
# Create die_key from instance and entry
parsed_die_key="${inst}:${ent}"
# Extract socket ID if present, otherwise fallback to instance ID
if [[ $line =~ \(socket\ ([0-9]+)\) ]]; then
socket_id=${BASH_REMATCH[1]}
else
socket_id=$inst
fi
# Extract NUMA node ID if present in the output (format: "(NUMA node X)")
numa_node=""
if [[ $line =~ \(NUMA\ node\ ([0-9]+)\) ]]; then
numa_node=${BASH_REMATCH[1]}
fi
extract_and_print_metrics "$value" "$socket_id" "$parsed_die_key" "$numa_node" "$inst"
fi
done <<< "$output"
done
`,
MicroArchitectures: []string{cpus.UarchGNR, cpus.UarchGNR_D, cpus.UarchSRF, cpus.UarchCWF, cpus.UarchDMR},
Depends: []string{"pcm-tpmi"},
Superuser: true,
},
SSTTFHPScriptName: {
Name: SSTTFHPScriptName,
ScriptTemplate: `# Is SST-TF supported?
if ! supported=$(pcm-tpmi 5 0xF8 -d -b 12:12 -i 0 -e 0 | tail -n 2 | head -n 1 | awk '{print $5}'); then
echo "Error: Failed to check if SST-TF is supported" >&2
exit 1
fi
if [[ ! "$supported" =~ ^[0-9]+$ ]]; then
echo "Error: Invalid output from pcm-tpmi when checking support" >&2
exit 1
fi
if [ "$supported" -eq 0 ]; then
echo "SST-TF is not supported"
exit 0
fi
# Is SST-TF enabled?
if ! enabled=$(pcm-tpmi 5 0x78 -d -b 9:9 -i 0 -e 0 | tail -n 2 | head -n 1 | awk '{print $5}'); then
echo "Error: Failed to check if SST-TF is enabled" >&2
exit 1
fi
if [[ ! "$enabled" =~ ^[0-9]+$ ]]; then
echo "Error: Invalid output from pcm-tpmi when checking enabled status" >&2
exit 1
fi
if [ "$enabled" -eq 0 ]; then
echo "SST-TF is not enabled"
exit 0
fi
echo "bucket,cores,AVX,AVX2,AVX-512,AVX-512 heavy,AMX"
# up to 5 buckets
for ((i=0; i<5; i++))
do
# Get the # of cores in this bucket
bithigh=$((i*8+7))
bitlow=$((i*8))
if ! numcores=$(pcm-tpmi 5 0x100 -d -b $bithigh:$bitlow -i 0 -e 0 | tail -n 2 | head -n 1 | awk '{print $5}'); then
echo "Error: Failed to get number of cores for bucket $i" >&2
exit 1
fi
if [[ ! "$numcores" =~ ^[0-9]+$ ]]; then
echo "Error: Invalid output from pcm-tpmi when getting number of cores for bucket $i" >&2
exit 1
fi
# if the number of cores is 0, skip this bucket
if [ "$numcores" -eq 0 ]; then
continue
fi
echo -n "$i,$numcores,"
# Get the frequencies for this bucket
bithigh=$((i*8+7)) # 8 bits per frequency
bitlow=$((i*8))
# 5 isa frequencies per bucket (AVX, AVX2, AVX-512, AVX-512 heavy, AMX)
for((j=0; j<5; j++))
do
offset=$((j*8 + 264)) # 264 is 0x108 (SST_TF_INFO_2) AVX
if ! freq=$(pcm-tpmi 5 $offset -d -b $bithigh:$bitlow -i 0 -e 0 | tail -n 2 | head -n 1 | awk '{print $5}'); then
echo "Error: Failed to get frequency for instruction set $j in bucket $i" >&2
exit 1
fi
if [[ ! "$freq" =~ ^[0-9]+$ ]]; then
echo "Error: Invalid frequency value for instruction set $j in bucket $i" >&2
exit 1
fi
echo -n "$freq"
if [ $j -lt 4 ]; then
echo -n ","
fi
done
echo "" # finish the line
done
`,
MicroArchitectures: []string{cpus.UarchGNR, cpus.UarchGNR_D, cpus.UarchDMR},
Depends: []string{"pcm-tpmi"},
Superuser: true,
},
SSTTFLPScriptName: {
Name: SSTTFLPScriptName,
ScriptTemplate: `# Is SST-TF supported?
if ! supported=$(pcm-tpmi 5 0xF8 -d -b 12:12 -i 0 -e 0 | tail -n 2 | head -n 1 | awk '{print $5}'); then
echo "Error: Failed to check if SST-TF is supported" >&2
exit 1
fi
if [[ ! "$supported" =~ ^[0-9]+$ ]]; then
echo "Error: Invalid output from pcm-tpmi when checking support" >&2
exit 1
fi
if [ "$supported" -eq 0 ]; then
echo "SST-TF is not supported"
exit 0
fi
# Is SST-TF enabled?
if ! enabled=$(pcm-tpmi 5 0x78 -d -b 9:9 -i 0 -e 0 | tail -n 2 | head -n 1 | awk '{print $5}'); then
echo "Error: Failed to check if SST-TF is enabled" >&2
exit 1
fi
if [[ ! "$enabled" =~ ^[0-9]+$ ]]; then
echo "Error: Invalid output from pcm-tpmi when checking enabled status" >&2
exit 1
fi
if [ "$enabled" -eq 0 ]; then
echo "SST-TF is not enabled"
exit 0
fi
echo "AVX,AVX2,AVX-512,AVX-512 heavy,AMX"
# Get the low priority core clip ratios (frequencies)
for((j=0; j<5; j++))
do
bithigh=$((j*8+23))
bitlow=$((j*8+16))
if ! freq=$(pcm-tpmi 5 0xF8 -d -b $bithigh:$bitlow -i 0 -e 0 | tail -n 2 | head -n 1 | awk '{print $5}'); then
echo "Error: Failed to get frequency for instruction set $j" >&2
exit 1
fi
if [[ ! "$freq" =~ ^[0-9]+$ ]]; then
echo "Error: Invalid frequency value for instruction set $j" >&2
exit 1
fi
echo -n "$freq"
if [ $j -ne 4 ]; then
echo -n ","
fi
done
echo "" # finish the line
`,
MicroArchitectures: []string{cpus.UarchGNR, cpus.UarchGNR_D, cpus.UarchDMR},
Depends: []string{"pcm-tpmi"},
Superuser: true,
},
ChaCountScriptName: {
Name: ChaCountScriptName,
ScriptTemplate: `rdmsr 0x396
rdmsr 0x702
rdmsr 0x2FFE
`, // uncore client cha count, uncore cha count, uncore cha count spr
Vendors: []string{cpus.IntelVendor},
Lkms: []string{"msr"},
Depends: []string{"rdmsr"},
Superuser: true,
},
IaaDevicesScriptName: {
Name: IaaDevicesScriptName,
ScriptTemplate: "ls -1 /dev/iax",
},
DsaDevicesScriptName: {
Name: DsaDevicesScriptName,
ScriptTemplate: "ls -1 /dev/dsa",
},
LshwScriptName: {
Name: LshwScriptName,
ScriptTemplate: "timeout 30 lshw -businfo -numeric",
Depends: []string{"lshw"},
Superuser: true,
},
MeminfoScriptName: {
Name: MeminfoScriptName,
ScriptTemplate: "cat /proc/meminfo",
},
TransparentHugePagesScriptName: {
Name: TransparentHugePagesScriptName,
ScriptTemplate: "cat /sys/kernel/mm/transparent_hugepage/enabled",
},
NumaBalancingScriptName: {
Name: NumaBalancingScriptName,
ScriptTemplate: "cat /proc/sys/kernel/numa_balancing",
},
NicInfoScriptName: {
Name: NicInfoScriptName,
ScriptTemplate: `for ifc_path in /sys/class/net/*; do
ifc=$(basename "$ifc_path")
if [ "$ifc" = "lo" ]; then
continue
fi
if ! ethtool_out=$(ethtool "$ifc" 2>/dev/null); then
continue
fi
if ! ethtool_i_out=$(ethtool -i "$ifc" 2>/dev/null); then
continue
fi
echo "Interface: $ifc"
udevadm_out=$(udevadm info --query=all --path=/sys/class/net/"$ifc")
echo "Vendor ID: $(echo "$udevadm_out" | grep ID_VENDOR_ID= | cut -d'=' -f2)"
echo "Model ID: $(echo "$udevadm_out" | grep ID_MODEL_ID= | cut -d'=' -f2)"
vendor=$(echo "$udevadm_out" | grep ID_VENDOR_FROM_DATABASE= | cut -d'=' -f2)
echo "Vendor: $vendor"
model=$(echo "$udevadm_out" | grep ID_MODEL_FROM_DATABASE= | cut -d'=' -f2)
# fall back to lspci if model is not available from udevadm, and trim vendor prefix if present (e.g. "Intel Ethernet Controller" -> "Ethernet Controller")
if [ -z "$model" ]; then
id_path=$(echo "$udevadm_out" | grep ID_PATH= | cut -d'=' -f2)
bdf=${id_path##*-}
# ID_PATH may include the domain (0000:49:00.0); lspci typically prints 49:00.0.
if [[ "$bdf" == *:*:* ]]; then
bdf=${bdf#*:}
fi
if [ -n "$bdf" ] && command -v lspci >/dev/null 2>&1; then
model=$(lspci -s "$bdf" -i pci.ids.gz | awk 'NR == 1 { pos = index($0, ": "); if (pos > 0) print substr($0, pos + 2); exit }')
if [ -n "$model" ] && [ -n "$vendor" ]; then
model=$(awk -v vendor="$vendor" -v model="$model" 'BEGIN {
v = tolower(vendor)
m = tolower(model)
out = model
if (v != "" && substr(m, 1, length(v)) == v) {
out = substr(model, length(v) + 1)
sub(/^[[:space:]]+/, "", out)
}
print out
}')
fi
fi
fi
echo "Model: $model"
echo "MTU: $(cat /sys/class/net/"$ifc"/mtu 2>/dev/null)"
echo "$ethtool_out"
echo "$ethtool_i_out"
if ethtool_c_out=$(ethtool -c "$ifc" 2>/dev/null); then
echo "$ethtool_c_out"
fi
echo "MAC Address: $(cat /sys/class/net/"$ifc"/address 2>/dev/null)"
echo "NUMA Node: $(cat /sys/class/net/"$ifc"/device/numa_node 2>/dev/null)"
# Check if this is a virtual function
if [ -L /sys/class/net/"$ifc"/device/physfn ]; then
echo "Virtual Function: yes"
else
echo "Virtual Function: no"
fi
echo -n "CPU Affinity: "
intlist=$( grep -e "$ifc" /proc/interrupts | cut -d':' -f1 | sed -e 's/^[[:space:]]*//' )
for int in $intlist; do
cpu=$( cat /proc/irq/"$int"/smp_affinity_list 2>/dev/null)
printf "%s:%s;" "$int" "$cpu"
done
printf "\n"
echo "TX Queues: $(ls -d /sys/class/net/"$ifc"/queues/tx-* | wc -l)"
echo "RX Queues: $(ls -d /sys/class/net/"$ifc"/queues/rx-* | wc -l)"
for q in /sys/class/net/"$ifc"/queues/tx-*; do
if [ -f "$q/xps_cpus" ]; then
echo "xps_cpus $(basename "$q"): $(cat "$q/xps_cpus")"
fi
done
for q in /sys/class/net/"$ifc"/queues/rx-*; do
if [ -f "$q/rps_cpus" ]; then
echo "rps_cpus $(basename "$q"): $(cat "$q/rps_cpus")"
fi
done
echo "----------------------------------------"
done
`,
Depends: []string{"ethtool", "lspci", "pci.ids.gz"},
Superuser: true,
},
IRQBalanceScriptName: {
Name: IRQBalanceScriptName,
ScriptTemplate: "pgrep irqbalance >/dev/null 2>&1 && echo 'Enabled' || echo 'Disabled'",
},
DiskInfoScriptName: {
Name: DiskInfoScriptName,
ScriptTemplate: `echo "NAME|MODEL|SIZE|MOUNTPOINT|FSTYPE|RQ-SIZE|MIN-IO|FIRMWARE|ADDR|NUMA|LINKSPEED|LINKWIDTH|MAXLINKSPEED|MAXLINKWIDTH"
lsblk -r -o NAME,MODEL,SIZE,MOUNTPOINT,FSTYPE,RQ-SIZE,MIN-IO -e7 -e1 \
| cut -d' ' -f1,2,3,4,5,6,7 --output-delimiter='|' \
| while IFS='|' read -r name model size mountpoint fstype rqsize minio ;
do
# skip the lsblk output header
if [ "$name" = "NAME" ] ; then
continue
fi
fw=""
addr=""
numa=""
curlinkspeed=""
curlinkwidth=""
maxlinkspeed=""
maxlinkwidth=""
# replace \x20 with space in model
model=${model//\\x20/ }
# if name refers to an NVMe device e.g, nvme0n1 - nvme99n99
if [[ $name =~ ^(nvme[0-9]+)n[0-9]+$ ]]; then
# get the name without the namespace
nvme=${BASH_REMATCH[1]}
if [ -f /sys/block/"$name"/device/firmware_rev ] ; then
fw=$( cat /sys/block/"$name"/device/firmware_rev )
fi
if [ -f /sys/block/"$name"/device/address ] ; then
addr=$( cat /sys/block/"$name"/device/address )
fi
if [ -d "/sys/block/$name/device/${nvme}" ]; then
numa=$( cat /sys/block/"$name"/device/"${nvme}"/numa_node )
curlinkspeed=$( cat /sys/block/"$name"/device/"${nvme}"/device/current_link_speed )
curlinkwidth=$( cat /sys/block/"$name"/device/"${nvme}"/device/current_link_width )
maxlinkspeed=$( cat /sys/block/"$name"/device/"${nvme}"/device/max_link_speed )
maxlinkwidth=$( cat /sys/block/"$name"/device/"${nvme}"/device/max_link_width )
elif [ -d "/sys/block/$name/device/device" ]; then
numa=$( cat /sys/block/"$name"/device/device/numa_node )
curlinkspeed=$( cat /sys/block/"$name"/device/device/current_link_speed )
curlinkwidth=$( cat /sys/block/"$name"/device/device/current_link_width )
maxlinkspeed=$( cat /sys/block/"$name"/device/device/max_link_speed )
maxlinkwidth=$( cat /sys/block/"$name"/device/device/max_link_width )
fi
fi
echo "$name|$model|$size|$mountpoint|$fstype|$rqsize|$minio|$fw|$addr|$numa|$curlinkspeed|$curlinkwidth|$maxlinkspeed|$maxlinkwidth"
done
`,
},
HdparmScriptName: {
Name: HdparmScriptName,
ScriptTemplate: `lsblk -d -r -o NAME -e7 -e1 -n | while read -r device ; do
hdparm -i /dev/"$device"
done
`,
Superuser: true,
},
DfScriptName: {
Name: DfScriptName,
ScriptTemplate: `df -h`,
},
FindMntScriptName: {
Name: FindMntScriptName,
ScriptTemplate: `findmnt -r`,
Superuser: true,
},
CveScriptName: {
Name: CveScriptName,
ScriptTemplate: "timeout 90 spectre-meltdown-checker.sh --batch text",
Superuser: true,
Lkms: []string{"msr"},
Depends: []string{"spectre-meltdown-checker.sh", "rdmsr"},
},
ProcessListScriptName: {
Name: ProcessListScriptName,
ScriptTemplate: `ps -eo pid,ppid,%cpu,%mem,rss,command --sort=-%cpu,-pid | grep -v "]" | head -n 20`,
Sequential: true,
},
IpmitoolSensorsScriptName: {
Name: IpmitoolSensorsScriptName,
ScriptTemplate: "LC_ALL=C timeout 30 ipmitool sdr list full",
Superuser: true,
Depends: []string{"ipmitool"},