forked from OCSInventory-NG/UnixAgent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
memconf
11415 lines (11255 loc) · 387 KB
/
memconf
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
#!/usr/bin/env perl
#
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# MODIFY THE LOCATION TO THE FULL PATH TO PERL ABOVE IF NECESSARY
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#
# @(#) memconf - Identify sizes of memory modules installed on a
# @(#) Solaris, Linux, FreeBSD or HP-UX workstation or server.
# @(#) Micron Technology, Inc. - Tom Schmidt 16-Nov-2017 V3.14
#
# Maintained by Tom Schmidt ([email protected])
#
# Check http://sourceforge.net/projects/memconf/ or my website at
# http://www.4schmidts.com/unix.html to get the latest version of memconf.
#
# If memconf does not recognize a system, then please run 'memconf -D' to
# have it automatically E-mail me the information I need to enhanced to
# recognize it. If the unrecognized system is a Sun clone, please also send
# any hardware documentation on the memory layout that you may have.
#
# Usage: memconf [ -v | -D | -h ] [explorer_dir]
# -v verbose mode
# -D E-mail results to memconf maintainer
# -h print help
# explorer_dir Sun/Oracle Explorer output directory
#
# memconf reports the size of each SIMM/DIMM memory module installed in a
# system. It also reports the system type and any empty memory sockets.
# In verbose mode, it also reports the following information if available:
# - banner name, model and CPU/system frequencies
# - address range and bank numbers for each module
#
# memconf is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 2 of the License, or (at your option)
# any later version.
#
# Original version based on SunManagers SUMMARY by Howard Modell
# ([email protected]) on 29-Jan-1997.
#
# Tested to work on 32-bit and 64-bit kernels on:
# - Solaris 10 6/06 or later on x86 with /usr/platform/i86pc/sbin/prtdiag
# - Linux on SPARC with sparc-utils and /dev/openprom
# - Linux on x86 and x86_64 with kernel-utils or pmtools for dmidecode
# - FreeBSD on x86 and x86_64 with dmidecode
# - Most HP-UX systems with SysMgmtPlus (cprop) or Support Tools Manager (cstm)
# - Solaris (SunOS 4.X or 5.X) on the following SPARC systems
# - sun4c Sun SS1, SS2, IPC, IPX, ELC with Open Boot PROM V2.X
# - sun4m Sun 4/6x0, SS4, SS5, SS10, SS20, LX/ZX, Classic, Voyager, JavaEngine1
# - sun4d Sun SPARCserver-1000, 1000E, SPARCcenter-2000, 2000E
# - sun4u Sun Ultra 1, 2, 5, 10, 30, 60, 450
# - sun4u Sun Ultra 80, Ultra Enterprise 420R, and Netra t1400/1405.
# - sun4u Sun Ultra Enterprise 220R, 250, 450
# - sun4u Sun Ultra Enterprise 3000, 3500, 4000/5000, 4500/5500, 6000, 6500
# - sun4u1 Sun Ultra Enterprise 10000
# - sun4u Sun StorEdge N8400 and N8600 Filer
# - sun4u Sun SPARCengine Ultra AX, AXi, AXmp, AXmp+, AXe
# - sun4u Sun SPARCengine CP 1400, CP 1500, CP2140
# - sun4u Sun Netra t1 100/105, t1120/1125, ft1800, X1, T1 200, AX1105-500, 120
# - sun4u Sun Netra 20 (Netra T4)
# - sun4u Sun Netra ct800
# - sun4u Sun Blade 100, 150, 1000, 1500, 2000, 2500
# - sun4u Sun Fire 280R
# - sun4u Sun Fire 3800, 4800, 4810, 6800
# - sun4u Sun Fire V100, V120, V210, V240, V250, V440
# - sun4u Sun Netra 210, 240, 440
# - sun4u Sun Fire V125, V215, V245, V445
# - sun4u Sun Fire V480, V490, V880, V880z, V890
# - sun4u Sun Fire 12000, 15000, E20K, E25K
# - sun4u Sun Fire V1280, Netra 1280 (Netra T12)
# - sun4u Sun Fire E2900, E4900, E6900
# - sun4u Sun Fire B100s Blade Server
# - sun4u Sun Ultra 25 Workstation
# - sun4u Sun Ultra 45 Workstation
# - sun4u Sun/Fujitsu Siemens SPARC Enterprise M3000, M4000, M5000, M8000,
# and M9000 Server
# - sun4v Sun Fire T2000, T1000, Netra T2000
# - sun4v Sun Blade T6300, T6320, T6340
# - sun4v Sun SPARC Enterprise T2000, T1000 Server
# - sun4v Sun SPARC Enterprise T5120, T5140, T5220, T5240 Server, Netra T5220
# - sun4v Sun SPARC Enterprise T5440 Server, Netra T5440
# - sun4v Oracle SPARC T3-1, T3-1B, T3-2, T4-1, T4-2, T4-4, T5-2, T5-4, T7-4
# - sun4v Oracle SPARC S7-2, S7-2L
# - sun4v Fujitsu SPARC M10-1, M10-4
# - sun4m Tatung COMPstation 5, 10, 20AL, 20S and 20SL clones
# - sun4m transtec SPARCstation 20I clone
# - sun4m Rave Axil-255 SPARCstation 5 clone
# - sun4m Rave Axil-245, 311 and 320 clones (no verbose output)
# - sun4u AXUS Ultra 250
# - sun4u Tatung COMPstation U2, U60 and U80D clones
# - Force Computers SPARC clones (no verbose output)
# - Tadpole SPARCbook 3 and RDI PowerLite-170 (no verbose output)
# - Tadpole VoyagerIIi
# - Tadpole (Cycle) 3200 CycleQUAD Ultra 2 upgrade motherboard
# - Tadpole (Cycle) UP-520-IIi SPARCstation 5/20 upgrade motherboard
# - Tadpole SPARCle
# - Auspex 7000/650 (no verbose output)
# - Fujitsu S-4/10H, S-4/20L and S-4/20H clones (no verbose output)
# - Fujitsu GP7000, GP7000F
# - Fujitsu Siemens PrimePower 200, 400, 600, 800, 1000, 2000
# - Fujitsu Siemens PrimePower 250, 450, 650, 850
# - Fujitsu Siemens PrimePower 900, 1500, 2500, HPC2500
# - Twinhead TWINstation 5G, 20G
# - Detects VSIMMs for SX graphics on SS10SX/SS20 (1st VSIMM only)
# - Detects Prestoserve NVSIMMs on SS10/SS20/SS1000/SC2000
#
# Untested systems that should work:
# - sun4c Sun SS1+ with Open Boot PROM V2.X
# - sun4m Tatung COMPstation 20A clone
# - sun4u Sun Netra ct400, ct410, ct810
# - sun4u Sun SPARCengine CP2040, CP2060, CP2080, CP2160
# - sun4v Sun Netra CP3260
# - sun4v Oracle SPARC T3-1BA, T3-4, T4-1B, T4-2B, T5-8, T5-1B, T7-1, T7-2
# - sun4v Oracle SPARC M5-32, M6-32, M7-8, M7-16
# - sun4v Oracle Netra SPARC T3 systems
# - sun4v Fujitsu SPARC M10-4S
# - May not work properly on Sun clones
#
# Won't work on:
# - SPARC systems without /dev/openprom
# - sun4c Sun SS1, SS1+, SLC, IPC with Open Boot PROM V1.X (no 'memory' lines
# in devinfo/prtconf output)
# - sun4 kernel architecture, and sun3 and older systems
# - Perl 5.001 is known to have problems with hex number conversions
# - Does not detect unused VSIMMs (another FB installed) or second VSIMM
#
# To Do list and Revision History can be found on the maintainers web site at
# http://www.4schmidts.com/unix.html
# Uncomment for debugging (perl 5 only)
#use diagnostics;
$^W=1; # Enables -w warning switch, put here for SunOS4 compatibility.
$starttime=(times)[0];
$version="V3.14";
$version_date="16-Nov-2017";
$URL="http://sourceforge.net/projects/memconf/";
$newpath="/usr/sbin:/sbin:/bin:/usr/bin:/usr/ucb:/usr/local/bin:/var/local/bin";
$ENV{PATH}=(defined($ENV{PATH})) ? "$newpath:$ENV{PATH}" : $newpath;
# Force C locale so that output is in English
$ENV{LC_ALL}="C";
$_=$];
($PERL_VERSION_MAJOR)=/(\d).*/;
if ($PERL_VERSION_MAJOR < 5) {
($PERL_VERS)=/(\d\.\d)/;
($PERL_PATCH)=/(\d*)$/;
$PERL_PATCH="0$PERL_PATCH" if ($PERL_PATCH < 10);
$PERL_VERSION="$PERL_VERS$PERL_PATCH";
} else {
($PERL_VERSION)=/(\d\.\d{3}).*/;
}
$uname="/usr/bin/uname";
$uname="/bin/uname" if (-x '/bin/uname');
$running_on="";
if (-x $uname) {
$os=&mychomp(`$uname`);
$os="FreeBSD-based $os" if ($os ne "FreeBSD" && -f '/etc/freebsd-update.conf');
$running_on=$os;
$hostname=&mychomp(`$uname -n`);
if ($os eq "AIX") {
$machine=&mychomp(`$uname -M`);
# oslevel command can return stderr output, so use uname instead
$osmajor=&mychomp(`$uname -v`);
$osminor=&mychomp(`$uname -r`);
$osrel="$osmajor.$osminor";
$kernver="";
$platform=&mychomp(`$uname -p`);
} else {
$machine=&mychomp(`$uname -m`);
$osrel=&mychomp(`$uname -r`);
$kernver=&mychomp(`$uname -v`);
$platform=$machine;
}
} else {
$hostname="";
$machine="";
$os="this unsupported";
$osrel="";
$kernver="";
}
$osrelease="";
$prtdiag_cmd="";
$prtdiag_exec="";
$have_prtdiag_data=0;
$prtdiag_checked=0;
$prtdiag_memory=0;
$prtfru_cmd="";
$have_prtfru_data=0;
$have_prtfru_details=0;
$missing_prtfru_details=" ";
$prtpicl_cmd="";
$have_prtpicl_data=0;
$psrinfo_cmd="";
$have_psrinfo_data=0;
$use_psrinfo_data=1;
$psrinfo_checked=0;
$virtinfo_cmd="";
$have_virtinfo_data=0;
$virtinfoLDOMcontrolfound=0;
$cfgadm_cmd="";
$have_cfgadm_data=0;
$ipmitool_cmd="";
$have_ipmitool_data=0;
$ipmi_cpucnt=0;
$ipmi_cputype="";
@ipmi_mem=("");
$ipmi_memory=0;
$smbios_cmd="";
$have_smbios_data=0;
@smbios_mem=("");
$smbios_memory=0;
$kstat_cmd="";
$have_kstat_data=0;
@kstat_brand=();
@kstat_MHz=();
$kstat_cpubanner="";
@kstat_core_id=("");
@kstat_core=("");
@kstat_ncore_per_chip=("");
@kstat_ncpu_per_chip=("");
$kstat_checked=0;
$ldm_cmd="";
$have_ldm_data=0;
$ldm_memory=0;
$free_cmd="";
$free_checked="";
$have_free_data=0;
$meminfo_cmd="";
$have_meminfo_data=0;
$modprobe_eeprom_cmd="";
$decodedimms_cmd="";
$decodedimms_checked="";
$have_decodedimms_data=0;
@reorder_decodedimms=();
$topology_cmd="";
@topology_header=();
@topology_data=();
$topology_mfg="";
$maxmembusspeed="";
$foundspeed=0;
$mixedspeeds=0;
$have_x86_devname=0;
$manufacturer="";
$systemmanufacturer="";
$boardmanufacturer="";
$baseboard="";
$biosvendor="";
if (-d '/usr/platform') {
$platform=&mychomp(`$uname -i`);
if (-x "/usr/platform/$platform/sbin/prtdiag") {
$prtdiag_cmd="/usr/platform/$platform/sbin/prtdiag";
} elsif (-x "/usr/platform/$machine/sbin/prtdiag") {
$prtdiag_cmd="/usr/platform/$machine/sbin/prtdiag";
} elsif (-x '/usr/sbin/prtdiag') {
$prtdiag_cmd="/usr/sbin/prtdiag";
}
} elsif (-x '/usr/kvm/prtdiag') {
$platform=$machine;
$prtdiag_cmd='/usr/kvm/prtdiag';
} elsif (-x '/usr/sbin/prtdiag') {
$platform=&mychomp(`$uname -i`);
$prtdiag_cmd="/usr/sbin/prtdiag";
}
if ($prtdiag_cmd) {
if (-x $prtdiag_cmd) {
$prtdiag_exec="$prtdiag_cmd";
}
}
$buffer="";
$filename="";
$installed_memory=0;
$failed_memory=0;
$spare_memory=0;
$failing_memory=0;
$memory_error_logged=0;
$failed_fru="";
$ultra=0;
$simmbanks=0;
$bankcnt=0;
$slot0=0;
$smallestsimm=16777216;
$largestsimm=0;
$found8mb=0;
$found16mb=0;
$found32mb=0;
$found10bit=0;
$found11bit=0;
$foundbank1or3=0;
$sxmem=0;
$nvmem=0;
$nvmem1=0;
$nvmem2=0;
$memtype="SIMM";
$sockettype="socket";
$verbose=0;
$debug=0;
$recognized=1;
$untested=1;
$untested_type="";
$perlhexbug=0;
$exitstatus=0;
$meg=1048576;
@socketstr=("");
@socketlabelstr=("");
@orderstr=("");
@groupstr=("");
@bankstr=("");
@banksstr=("");
$bankname="banks";
@bytestr=("");
@slotstr=("");
$simmrangex=0;
$simmrange=1;
$showrange=1;
$start1x="";
$stop1x="";
@simmsizes=(0,16777216);
@simmsizesfound=();
@memorylines=("");
$socket="";
$socketlabel="";
$order="";
$group="";
$slotnum="";
$bank="";
$dualbank=0;
$byte="";
$gotmemory="";
$gotmodule="";
$gotmodulenames="";
$gotcpunames="";
$gotcpuboards="";
$slotname0="";
@boards_cpu="";
@boards_mem="";
$empty_banks="";
$banks_used="";
$nvsimm_banks="";
$boardslot_cpu=" ";
$boardslot_cpus=" ";
@boardslot_cpus=();
$boardslot_mem=" ";
$boardslot_mems=" ";
@boardslot_mems=();
$boardfound_cpu=0;
$boardfound_mem=0;
$prtdiag_has_mem=0;
$prtdiag_banktable_has_dimms=0;
$prtdiag_failed=0;
$prtconf_warn="";
$flag_cpu=0;
$flag_mem=0;
$flag_rewrite_prtdiag_mem=0;
$format_cpu=0;
$format_mem=0;
$foundname=0;
$sockets_used="";
$sockets_empty="";
$sortslots=1;
$devtype="";
$interleave=0;
$stacked=0;
$freq=0;
$sysfreq=0;
$cpufreq=0;
$cputype="";
$cputype_prtconf="";
$cputype_psrinfo="";
$cpuinfo_cputype="";
@cpucnt=();
$cpucntfrom="";
$cpucntflag=0;
$cpuinfo_cpucnt=0;
$have_cpuinfo_data=0;
$cpuinfo_coreidcnt=0;
$cpuinfo_cpucores=0;
@cpuinfo_physicalid=();
$cpuinfo_physicalidcnt=0;
$cpuinfo_siblings=0;
$cpuinfo_checked=0;
$xm_info_cmd="";
$have_xm_info_data=0;
$xen_ncpu=0;
$xen_nr_nodes=0;
$xen_sockets_per_node=0;
$xen_cores_per_socket=0;
$foundGenuineIntel=0;
@diagcpucnt=();
$diagthreadcnt=0;
$psrcpucnt=0;
$foundpsrinfocpu=0;
$ncpu=0; # remains 0 if using prtdiag output only
$ndcpu=0; # prtdiag cpu count
$npcpu=0; # physical cpu count
$nvcpu=0; # virtual cpu count
$necpu=0; # empty cpu socket count
$threadcnt=0;
$corecnt=1;
$hyperthread=0;
$hyperthreadcapable=0;
$header_shown=0;
$romver="";
$romvernum="";
$SUNWexplo=0;
$banner="";
$bannermore="";
$cpubanner="";
$diagbanner="";
$model="";
$systemmodel="";
$boardmodel="";
$modelmore="";
$model_checked=0;
$BSD=0; # Initially assume SunOS 5.X
$config_cmd="/usr/sbin/prtconf -vp";
$config_command="prtconf";
$config_permission=0;
$permission_error="";
$dmidecode_error="";
$freephys=0;
$isX86=0;
$HPUX=0;
$devname=""; # Sun internal development code name
$familypn=""; # Sun family part number (system code)
$clone=0;
$totmem=0;
$latest_dmidecode_ver="2.12";
$minimum_dmidecode_ver="2.8";
$dmidecode_ver="0";
$dmidecodeURL="http://www.nongnu.org/dmidecode/";
$have_dmidecode=0;
$cpuarr=-1;
$memarr=-1;
$release="";
$waitshown=0;
$totalmemshown=0;
$vmshown=0;
$controlLDOMshown=0;
$helpers_defined=0;
$picl_foundmemory=0;
@picl_mem_pn=();
@picl_mem_bank=();
@picl_mem_dimm=();
if (-x '/usr/bin/id') {
$uid=&mychomp(`/usr/bin/id`);
$uid=~s/uid=//;
$uid=~s/\(.*//;
} else {
$uid=0; # assume super-user
}
$empty_memory_printed=0;
@filelist=();
#
# Parse options
#
foreach $name (@ARGV) {
if ($name eq "-v") {
# verbose mode
$verbose=1;
} elsif ($name eq "-d") {
# more verbose debug mode
$verbose=2;
} elsif ($name eq "-debug") {
# most verbose debug mode
$debug=1;
} elsif ($name eq "-debugtime") {
# most verbose debug mode with timestamps
$debug=2;
} elsif ($name eq "-D") {
# E-mail information of system to maintainer
$verbose=3;
open(MAILFILE, ">/tmp/memconf.output") || die "can't open /tmp/memconf.output: $!";
print MAILFILE "Output from 'memconf -d' on $hostname\n";
print MAILFILE "----------------------------------------------------\n";
close(MAILFILE);
*STDERR = *STDOUT; # Redirect stderr to stdout
open(STDOUT, "| tee -a /tmp/memconf.output") || die "can't open /tmp/memconf.output: $!";
print "Gathering memconf data to E-mail to maintainer. This may take a few minutes.\nPlease wait...\n";
} elsif (-f "$name/sysconfig/prtconf-vp.out") {
# Sun/Oracle Explorer output
$SUNWexplo=1;
# Special case for regression testing Sun/Oracle Explorer data
$os="SunOS";
open(FILE, "<$name/sysconfig/prtconf-vp.out");
@config=<FILE>;
close(FILE);
if (-f "$name/sysconfig/prtdiag-v.out") {
open(FILE, "<$name/sysconfig/prtdiag-v.out");
@prtdiag=<FILE>;
$have_prtdiag_data=1;
$prtdiag_cmd="/usr/platform/$platform/sbin/prtdiag";
$prtdiag_exec="$prtdiag_cmd";
close(FILE);
}
if (-f "$name/fru/prtfru_-x.out") {
open(FILE, "<$name/fru/prtfru_-x.out");
@prtfru=<FILE>;
$have_prtfru_data=1;
$prtfru_cmd='/usr/sbin/prtfru';
close(FILE);
}
if (-f "$name/sysconfig/prtpicl-v.out") {
open(FILE, "<$name/sysconfig/prtpicl-v.out");
@prtpicl=<FILE>;
$have_prtpicl_data=1;
$prtpicl_cmd='/usr/sbin/prtpicl';
close(FILE);
}
if (-f "$name/sysconfig/psrinfo-v.out") {
open(FILE, "<$name/sysconfig/psrinfo-v.out");
@psrinfo=<FILE>;
$have_psrinfo_data=1;
$psrinfo_cmd='/usr/sbin/psrinfo';
close(FILE);
}
# Sun/Oracle Explorer does not include "psrinfo -p" or
# "psrinfo -p -v" data yet.
# Is virtinfo output available in Oracle Explorer?
if (-f "$name/sysconfig/cfgadm-alv.out") {
open(FILE, "<$name/sysconfig/cfgadm-alv.out");
@cfgadm=<FILE>;
$have_cfgadm_data=1;
$cfgadm_cmd='/usr/sbin/cfgadm';
close(FILE);
}
if (-f "$name/sysconfig/uname-a.out") {
open(FILE, "<$name/sysconfig/uname-a.out");
$uname=&mychomp(<FILE>);
close(FILE);
@unamearr=split(/\s/, $uname);
$hostname=$unamearr[1];
$machine=$unamearr[4];
$osrel=$unamearr[2];
$platform=$unamearr[6];
$prtdiag_cmd="/usr/platform/$platform/sbin/prtdiag";
$prtdiag_exec="$prtdiag_cmd";
} else {
if ($config[0] =~ /System Configuration:/) {
@machinearr=split(/\s+/, $config[0]);
$machine=$machinearr[4];
}
$osrel="";
$hostname="";
}
if (-f "$name/sysconfig/prtconf-V.out") {
open(FILE, "<$name/sysconfig/prtconf-V.out");
$romver=&mychomp(<FILE>);
close(FILE);
}
$filename="$name";
} elsif (-f $name) {
# Regression test file with prtconf/dmidecode output
open(FILE, "<$name");
@config=<FILE>;
close(FILE);
# Regression test file may also have prtdiag, etc.
@prtdiag=@config;
@prtfru=@config;
$have_prtfru_data=1;
@prtpicl=@config;
$have_prtpicl_data=1;
@psrinfo=@config;
$have_psrinfo_data=1;
@virtinfo=@config;
$have_virtinfo_data=1;
@cfgadm=@config;
$have_cfgadm_data=1;
@ipmitool=@config;
$have_ipmitool_data=1;
@ldm=@config;
$have_ldm_data=1;
@cpuinfo=@config;
$have_cpuinfo_data=1;
@meminfo=@config;
$have_meminfo_data=1;
@free=@config;
$have_free_data=1;
@xm_info=@config;
$have_xm_info_data=1;
@decodedimms=@config;
@smbios=@config;
$have_smbios_data=1;
@kstat=@config;
$have_kstat_data=1;
@machinfo=@config;
$hostname="";
$osrel="";
# Check test file to determine OS and machine
for ($val=0; $val <= $#config; $val++) {
if ($config[$val]) {
if ($config[$val] =~ /System Configuration:/) {
@machinearr=split(/\s+/, $config[$val]);
$machine=$machinearr[4];
$machine="" if (! defined($machine));
$platform=$machine;
# Special case for regression testing SunOS prtconf files
$os="SunOS";
last;
} elsif ($config[$val] =~ / dmidecode |DMI .* present/) {
$have_dmidecode=1;
if ($config[$val] =~ / dmidecode /) {
$dmidecode_ver=&mychomp($config[$val]);
$dmidecode_ver=~s/.* dmidecode //;
}
$machine="";
$platform="";
# Special case for regression testing Linux dmidecode files
$os="Linux";
last;
}
}
}
$filename="$name";
} else {
&show_help;
}
}
&pdebug("starting");
print "memconf: $version $version_date $URL\n" if (-t STDOUT || $verbose);
&find_helpers;
if (! $filename && -r '/proc/cpuinfo') {
open(FILE, "/proc/cpuinfo");
@cpuinfo=<FILE>;
close(FILE);
$have_cpuinfo_data=1;
}
if (! $filename && $xm_info_cmd) {
@xm_info=&run("$xm_info_cmd");
$have_xm_info_data=1;
}
# Check cpuinfo now on unsupported machines (arm, mips, etc.)
&check_cpuinfo if (! $filename && $machine !~ /.86|ia64|amd64|sparc/);
&check_free;
&check_dmidecode if ($have_dmidecode);
if (! $filename) {
if ($os eq "HP-UX") {
&hpux_check;
if (-x '/opt/propplus/bin/cprop') {
&hpux_cprop;
} elsif (-x '/usr/sbin/cstm') {
&hpux_cstm;
} else {
&show_header;
&show_supported;
}
} elsif ($os =~ /Linux|FreeBSD/) {
&linux_distro if (! $release);
if ($machine =~ /arm/i) {
if (-f '/etc/Alt-F' && -f '/tmp/board') {
# NAS model
open(FILE, "</tmp/board");
$model=&mychomp(<FILE>);
close(FILE);
} elsif (-f '/etc/model') {
# DLink NAS model
open(FILE, "</etc/model");
$model=&mychomp(<FILE>);
close(FILE);
}
}
# Use dmidecode for Linux x86, not for Linux SPARC
&check_dmidecode if ($config_cmd =~ /dmidecode/ && -x "$config_cmd" && ($machine =~ /.86/ || ! -x '/usr/sbin/prtconf'));
if ($machine =~ /.86/ || ! -e '/dev/openprom') {
&show_header;
&show_supported;
}
} elsif ($os ne "SunOS") {
&show_header;
&show_supported;
}
if (-f '/vmunix') {
# SunOS 4.X (Solaris 1.X)
$BSD=1;
if (! -x '/usr/etc/devinfo') {
print "ERROR: no 'devinfo' command. Aborting.\n";
&pdebug("exit 1");
exit 1;
}
$config_cmd="/usr/etc/devinfo -pv";
$config_command="devinfo";
} else {
# Solaris 2.X or later
$BSD=0;
if (! -x '/usr/sbin/prtconf') {
print "ERROR: no 'prtconf' command. Aborting.\n";
&pdebug("exit 1");
exit 1;
}
$config_cmd="/usr/sbin/prtconf -vp";
$config_command="prtconf";
}
} else {
# Special case for regression testing SunOS4 and SunOS5 files
if ($filename =~ /\bdevinfo\./) {
$os="SunOS";
$BSD=1;
} elsif ($filename =~ /\bprtconf\./) {
$os="SunOS";
$BSD=0;
}
# Special case for regression testing Linux files
$os="Linux" if ($filename =~ /Linux/);
# Special case for regression testing HP-UX files
if ($filename =~ /\bcprop[\.+]/) {
&hpux_check;
&hpux_cprop;
} elsif ($filename =~ /\b(cstm|machinfo)[\.+]/) {
&hpux_check;
&hpux_cstm;
}
}
$kernbit="";
$hasprtconfV=0;
$solaris="";
$solaris="1.0" if ($osrel eq "4.1.1");
$solaris="1.0.1" if ($osrel eq "4.1.2");
$solaris="1.1" if ($osrel =~ /4.1.3/);
$solaris="1.1.1" if ($osrel eq "4.1.3_U1");
$solaris="1.1.2" if ($osrel eq "4.1.4");
if ($osrel =~ /^5./) {
$osminor=$osrel;
$osminor=~s/^5.//;
if ($SUNWexplo) {
if (-f "$filename/etc/release") {
open(FILE, "<$filename/etc/release");
$release=<FILE>;
close(FILE);
}
} else {
if (-f '/etc/release') {
open(FILE, "</etc/release");
$release=<FILE>;
close(FILE);
}
}
if ($release =~ "Solaris") {
$release=~s/\s+//;
$release=&mychomp($release);
$solaris="$release";
}
if ($release =~ "OmniOS") {
$release=~s/\s+//;
$release=&mychomp($release);
$solaris="$release";
}
if ($osminor =~ /^[7-9]$|^1[0-9]$/) {
$hasprtconfV=1;
$solaris=$osminor if (! $solaris);
$kernbit=32;
if ($SUNWexplo) {
$cpuarch="";
if (-f "$filename/sysconfig/isainfo.out") {
open(FILE, "<$filename/sysconfig/isainfo.out");
$cpuarch=<FILE>;
close(FILE);
} elsif (-f "$filename/sysconfig/isainfo-kv.out") {
open(FILE, "<$filename/sysconfig/isainfo-kv.out");
$cpuarch=<FILE>;
close(FILE);
}
$kernbit=64 if ($cpuarch =~ /sparcv9|ia64|amd64/);
} elsif (-x '/bin/isainfo') {
$kernbit=&mychomp(`/bin/isainfo -b`);
}
} elsif ($osminor =~ /^[4-6]$/) {
$hasprtconfV=1;
$solaris="2.$osminor" if (! $solaris);
} else {
$solaris="2.$osminor";
}
# x86 Solaris 2.1 through 2.5.1 has different syntax than SPARC
$config_cmd="/usr/sbin/prtconf -v" if ($machine eq "i86pc" && $osminor =~ /^[1-5]$/);
# Solaris x86 returns booting system rather than PROM version
$hasprtconfV=0 if ($machine eq "i86pc");
}
if (! $filename) {
@config=&run("$config_cmd");
if ($hasprtconfV) {
# SPARC Solaris 2.4 or later
$romver=&mychomp(`/usr/sbin/prtconf -V 2>&1`);
if ($romver eq "Cannot open openprom device") {
$prtconf_warn="ERROR: $romver";
$romver="";
} else {
@romverarr=split(/\s/, $romver);
$romvernum=$romverarr[1];
}
} else {
# SPARC Solaris 2.3 or older, or Solaris x86
# Try to use sysinfo if installed to determine the OBP version.
# sysinfo is available from http://www.MagniComp.com/sysinfo/
close(STDERR) if ($verbose != 3);
$romver=`sysinfo -show romver 2>/dev/null | tail -1`;
open(STDERR) if ($verbose != 3);
if ($romver) {
$romver=&mychomp($romver);
@romverarr=split(/\s/, $romver);
$romver=$romverarr[$#romverarr];
} else {
# Assume it is old
$romver="2.X" if ($machine =~ /sun4/);
}
$romvernum=$romver;
}
}
if ($filename && $have_prtpicl_data && ! $SUNWexplo) {
foreach $line (@prtpicl) {
$line=&dos2unix($line);
$line=&mychomp($line);
$line=~s/\s+$//;
# Parse osrel and hostname from prtpicl data
if ($line =~ /\s+:OS-Release\s/) {
$osrel=$line;
$osrel=~s/^.*:OS-Release\s+(.*)$/$1/;
if ($osrel =~ /^5./) {
$osminor=$osrel;
$osminor=~s/^5.//;
if ($osminor =~ /^[7-9]$|^1[0-9]$/) {
$solaris=$osminor;
# Solaris 10 SPARC and later is 64-bit
$kernbit=64 if ($osminor =~ /^1[0-9]$/ && $machine =~ /sun4/);
} else {
# Solaris 2.6 and earlier is 32-bit
$solaris="2.$osminor";
$kernbit=32;
}
if ($machine =~ /86/) {
$solaris .= " X86" if ($solaris !~ / X86/);
# Solaris 9 X86 and earlier is 32-bit
$kernbit=32 if ($osminor =~ /^[7-9]$/);
} elsif ($machine =~ /sun4/) {
$solaris .= " SPARC" if ($solaris !~ / SPARC/);
$kernbit=32 if ($machine =~ /sun4[cdm\b]/);
}
}
}
if ($line =~ /\s+:HostName\s/) {
$hostname=$line;
$hostname=~s/^.*:HostName\s+(.*)$/$1/;
}
}
}
sub please_wait {
return if ($waitshown);
$waitshown=1;
print "Gathering data for memconf. This may take over a minute. Please wait...\n" if (-t STDOUT);
}
sub find_helpers {
return if ($helpers_defined);
$helpers_defined=1;
if ($os eq "HP-UX") {
$config_cmd="echo 'selclass qualifier cpu;info;wait;selclass qualifier memory;info;wait;infolog'|/usr/sbin/cstm";
} elsif ($os =~ /Linux|FreeBSD/) {
if (defined($ENV{DMIDECODE}) && -x $ENV{DMIDECODE}) {
# this may be a setuid-root version of dmidecode
$config_cmd=$ENV{DMIDECODE};
} else {
foreach $bin ('/usr/local/sbin','/usr/local/bin','/usr/sbin','/usr/bin','/bin') {
if (-x "$bin/dmidecode") {
$config_cmd="$bin/dmidecode";
last;
}
}
}
} elsif (-x '/usr/sbin/prtconf') {
# Solaris 2.X or later
$config_cmd="/usr/sbin/prtconf -vp";
$prtfru_cmd='/usr/sbin/prtfru' if (-x '/usr/sbin/prtfru');
$prtpicl_cmd='/usr/sbin/prtpicl' if (-x '/usr/sbin/prtpicl');
$psrinfo_cmd='/usr/sbin/psrinfo' if (-x '/usr/sbin/psrinfo');
$virtinfo_cmd='/usr/sbin/virtinfo' if (-x '/usr/sbin/virtinfo');
$cfgadm_cmd='/usr/sbin/cfgadm' if (-x '/usr/sbin/cfgadm');
$smbios_cmd='/usr/sbin/smbios' if (-x '/usr/sbin/smbios');
$kstat_cmd='/usr/bin/kstat -m cpu_info' if (-x '/usr/bin/kstat');
$ldm_cmd='/opt/SUNWldm/bin/ldm' if (-x '/opt/SUNWldm/bin/ldm');
}
if ($os =~ /Linux|FreeBSD/) {
$free_cmd='/usr/bin/free -m' if (-x '/usr/bin/free');
$meminfo_cmd='cat /proc/meminfo' if (-r '/proc/meminfo' || $running_on !~ /Linux|FreeBSD/);
$topology_cmd='/usr/bin/topology --summary --nodes --cpus --io --routers' if (-x '/usr/bin/topology' || $running_on !~ /Linux|FreeBSD/);
if (&is_xen_hv) {
$xm_info_cmd='/usr/sbin/xm info';
$xm_info_cmd='/usr/bin/xm info' if (-x '/usr/bin/xm');
}
if (-x '/usr/bin/decode-dimms.pl' || $running_on !~ /Linux|FreeBSD/) {
$modprobe_eeprom_cmd='/sbin/modprobe eeprom';
$decodedimms_cmd='/usr/bin/decode-dimms.pl';
}
}
if ($os =~ /SunOS|Linux|FreeBSD/) {
if (defined($ENV{IPMITOOL}) && -x $ENV{IPMITOOL}) {
# this may be a setuid-root version of ipmitool
$ipmitool_cmd=$ENV{IPMITOOL};
} else {
foreach $bin ('/usr/sfw/bin','/usr/local/sbin','/usr/local/bin','/usr/sbin','/usr/bin','/bin') {
if (-x "$bin/ipmitool") {
$ipmitool_cmd="$bin/ipmitool";
last;
}
}
}
}
}
sub show_helpers {
$s=shift;
# Prefer prtconf for Linux SPARC
if ($machine =~ /sun|sparc/i || $filename =~ /LinuxSPARC/) {
print "$s/usr/sbin/prtconf -vp\n";
print "$s$config_cmd\n" if ($config_cmd =~ /dmidecode/ && -x "$config_cmd");
} else {
print "$s$config_cmd\n" if ($config_cmd);
}
if ($os eq "SunOS") {
print "$s$prtdiag_cmd -v\n" if ($prtdiag_exec);
print "$s$prtfru_cmd -x\n" if ($prtfru_cmd);
print "$s$prtpicl_cmd -v\n" if ($prtpicl_cmd);
if ($psrinfo_cmd) {
print "$s$psrinfo_cmd -v\n";
$tmp=&mychomp(`$psrinfo_cmd -p 2>/dev/null`);
if ($tmp ne "") {
print "$s$psrinfo_cmd -p\n";
print "$s$psrinfo_cmd -p -v\n";
}
}
print "$s$virtinfo_cmd -pa\n" if ($virtinfo_cmd);
print "$s$cfgadm_cmd -al\n" if ($cfgadm_cmd);
print "$s$smbios_cmd\n" if ($smbios_cmd);
print "$s$kstat_cmd\n" if ($kstat_cmd);
print "$s$ldm_cmd list-devices -a -p\n" if ($ldm_cmd);
}
if ($os =~ /Linux|FreeBSD/) {
print "${s}cat /proc/cpuinfo\n" if (-r '/proc/cpuinfo' || $running_on !~ /Linux|FreeBSD/);
print "${s}cat /proc/meminfo\n" if (-r '/proc/meminfo' || $running_on !~ /Linux|FreeBSD/);
print "$s$free_cmd\n" if ($free_cmd);
print "${s}/usr/bin/topology\n" if (-x '/usr/bin/topology' || $running_on !~ /Linux|FreeBSD/);
print "$s$xm_info_cmd\n" if ($xm_info_cmd);
print "${s}/usr/bin/xenstore-ls /local/domain/DOMID\n" if (-x '/usr/bin/xenstore-ls' || $running_on !~ /Linux|FreeBSD/);
print "$s$modprobe_eeprom_cmd; $decodedimms_cmd\n" if ($decodedimms_cmd);
}
if ($os =~ /SunOS|Linux|FreeBSD/) {
print "$s$ipmitool_cmd fru\n" if ($ipmitool_cmd && $running_on eq $os);
}
if ($os eq "HP-UX") {
print "$s/usr/contrib/bin/machinfo\n" if (-x '/usr/contrib/bin/machinfo');
}
}
sub show_help {
&find_helpers;
if ($os =~ /Linux|FreeBSD/ && $config_cmd =~ /prtconf/) {
if ($machine =~ /.86|ia64|amd64|sparc/) {
$config_cmd="dmidecode";
} else {
$config_cmd="";
}
}
print "Usage: memconf [ -v | -D | -h ] [explorer_dir]\n";
print " -v verbose mode\n";
print " -D E-mail results to memconf maintainer\n";
print " -h print help\n";
print " explorer_dir Sun/Oracle Explorer output directory\n";
print "\nThis is memconf, $version $version_date\n\nCheck my website ";
print "at $URL to get the latest\nversion of memconf.\n\n";
&show_supported if ($os !~ /SunOS|HP-UX|Linux|FreeBSD/);
print "Please send bug reports and enhancement requests along with ";
print "the output of the\nfollowing commands to tschmidt\@micron.com ";
print "as E-mail attachments so that memconf\nmay be enhanced. ";
print "You can do this using the 'memconf -D' command if this system\n";
print "can E-mail to the Internet.\n";
&show_helpers(" ");
&pdebug("exit");
exit;
}
sub check_hyperthread {
&pdebug("in check_hyperthread: corecnt=$corecnt");
if ($cputype =~ /Intel.*\sXeon.*\s(E5540|E5620|L5520|X5560|X5570)\b/ && (($corecnt == 8 && ! &is_xen_hv) || &is_xen_hv)) {
&pdebug("hyperthread=1: hack in cpubanner, cputype=$cputype") if (! $hyperthread);
$hyperthread=1;
$corecnt=4;
$cputype=~s/Eight.Core //ig;
$cputype=&multicore_cputype($cputype,$corecnt);
}
if ($cputype =~ /Intel.*\sXeon.*\s(L5640|X5670|X5675)\b/ && (($corecnt == 12 && ! &is_xen_hv) || &is_xen_hv)) {
&pdebug("hyperthread=1: hack in cpubanner, cputype=$cputype") if (! $hyperthread);
$hyperthread=1;
$corecnt=6;
$cputype=~s/Twelve.Core //ig;
$cputype=&multicore_cputype($cputype,$corecnt);
}
}
sub show_hyperthreadcapable {
if ($hyperthreadcapable && ! $hyperthread) {