File: Memory.pm

package info (click to toggle)
ocsinventory-agent 2%3A2.10.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,424 kB
  • sloc: perl: 26,492; xml: 773; objc: 528; sh: 386; ansic: 333; makefile: 12
file content (626 lines) | stat: -rw-r--r-- 22,851 bytes parent folder | download | duplicates (4)
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
package Ocsinventory::Agent::Backend::OS::Solaris::Memory;
use strict;

sub check { 
    my $params = shift;
    my $common = $params->{common};
    $common->can_run ("memconf") 
}

sub run {
    my $model;
    my $params = shift;
    my $common = $params->{common};
    my $logger = $params->{logger};
    my $capacity;
    my $description;
    my $numslots;
    my $speed = undef;
    my $type = undef;
    my $banksize;
    my $module_count=0;
    my $empty_slots;
    my $flag=0;
    my $flag_mt=0;
    my $caption;
    my $sun_class=0;
    my $OSLevel;
    my $zone;
    my $aarch;
    # for debug only
    my $j=0;

    # first, we need determinate on which model of sun server we run,
    # because prtdiags output (and with that memconfs output) is differend
    # from server model to server model
    # we try to classified our box in one of the known classes

    chomp($OSLevel = `uname -r`);
    chomp($aarch = `uname -p`);
    
    if ( !$common->can_run("zonename") || `zonename` =~ /global/ ) {
    # Either pre Sol10 or in Sol10/Sol11 global zone 
    $zone = "global";
    }else{
    # Sol10/Sol11 local zone
    $zone = "";
    }
      
    #print "Nom :".$zone."*************************\n";
    
    if ($zone)
    {  
      if ( $aarch =~ /sparc/ && $common->can_run("virtinfo") && `virtinfo -t` =~ /.*LDoms guest.*/ ) {
	$model = "Solaris Ldom";
      }else{
	chomp($model = `uname -i`);
      }
    }else{
    $model="Solaris Containers";
    }
    
    #print "Memory Model: $model\n";
    
    
    #$model=`uname -i`;
    # debug print model
    #print "Model: '$model'";
    # cut the CR from string model
    #$model = substr($model, 0, length($model)-1);
    # we map (hopfully) our server model to a known class 
    #if ($model eq "SUNW,Sun-Fire-280R") { $sun_class = 1; }
    #if ($model eq "SUNW,Sun-Fire-480R") { $sun_class = 1; }
    #if ($model eq "SUNW,Sun-Fire-V490") { $sun_class = 1; }
    #if ($model eq "SUNW,Sun-Fire-880")  { $sun_class = 1; }
    #if ($model eq "SUNW,Sun-Fire-V240") { $sun_class = 2; }
    #if ($model eq "SUNW,Sun-Fire-V440") { $sun_class = 2; }
    #if ($model eq "SUNW,Sun-Fire-V250") { $sun_class = 2; }
    #if ($model eq "SUNW,Sun-Fire-T200") { $sun_class = 3; }
    #if ($model eq "SUNW,Sun-Fire-T1000") { $sun_class = 3; }
    #if ($model eq "SUNW,SPARC-Enterprise-T5220") { $sun_class = 4; }
    #if ($model eq "SUNW,SPARC-Enterprise") { $sun_class = 5; } # for M5000 && M4000
    
    if ($model  =~ /SUNW,SPARC-Enterprise/) { $sun_class = 5; } # for M5000 && M4000
    if ($model  =~ /SUNW,SPARC-Enterprise-T\d/){ $sun_class = 4; }
    if ($model  =~ /SUNW,Netra-T/){ $sun_class = 2; }
    if ($model  =~ /SUNW,Sun-Fire-\d/){ $sun_class = 1; }
    if ($model  =~ /SUNW,Sun-Fire-V/){ $sun_class = 2; }  
    if ($model  =~ /SUNW,Sun-Fire-V490/) { $sun_class = 1; }
    if ($model  =~ /SUNW,Sun-Fire-T\d/) { $sun_class = 3; }
    if ($model  =~ /SUNW,SPARCstation/) { $sun_class = 3; }
    if ($model  =~ /SUNW,Ultra-/) { $sun_class = 3; }
    if ($model  =~ /SUNW,Sun-Blade-100/) { $sun_class = 8; }
    if ($model  =~ /SUNW,Sun-Blade-1500/) { $sun_class = 8; }
    if ($model  =~ /SUNW,T\d/) { $sun_class = 3; }
    if ($model  =~ /Solaris Containers/){ $sun_class = 7; } 
    if ($model  =~ /Solaris Ldom/) { $sun_class = 7; }
    if ($model  =~ /i86pc/) { $sun_class = 6; }
    if ($model  =~ /sun4v/) { $sun_class = 3; }
 
  
    # debug print model
    #print "Sunclass: $sun_class\n";
    # now we can look at memory information, depending from our class

    if($sun_class == 0) 
    {
      $logger->debug("sorry, unknown model, could not detect memory configuration");
    }

    if($sun_class == 1)
    {
      foreach(`memconf 2>&1`) 
      {
        # debug
        #print "count: " .$j++ . " " . $flag_mt . " : " . "$_";
        # if we find "empty groups:", we have reached the end and indicate that by setting flag = 0
        if(/^empty \w+:\s(\S+)/)
        {
          $flag = 0;
          if($1 eq "None"){$empty_slots = 0;}
        }
        # grep the type of memory modules from heading
        if($flag_mt && /^\s*\S+\s+\S+\s+\S+\s+\S+\s+(\S+)/) {$flag_mt=0; $description = $1;}

        # only grap for information if flag = 1
        if ($flag && /^\s*(\S+)\s+(\S+)/) { $caption = "Board " . $1 . " MemCtl " . $2; }
        if ($flag && /^\s*\S+\s+\S+\s+(\S+)/) { $numslots = $1; }
        if ($flag && /^\s*\S+\s+\S+\s+\S+\s+(\d+)/) { $banksize = $1; }
        if ($flag && /^\s*\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+(\d+)/) { $capacity = $1; }
        if ($flag) 
        {
          for (my $i = 1; $i <= ($banksize / $capacity); $i++)
          {
            #print "Caption: " . $caption . " Description: " . $description . " Bank Number: " . $numslots . " DIMM Capacity: " .  $capacity . "MB\n";
            $module_count++;
            $common->addMemory({
              CAPACITY => $capacity,
              DESCRIPTION => $description,
              CAPTION => $caption,
              SPEED => $speed,
              TYPE => $type,
              NUMSLOTS => $numslots
            })
          }
        }
        # this is the caption line 
        if(/^\s+Logical  Logical  Logical/) { $flag_mt = 1; }
        # if we find "---", we set flag = 1, and in next line, we start to look for information
        if(/^-+/){ $flag = 1; }
      }
    #print "# of RAM Modules: " . $module_count . "\n";
    #print "# of empty slots: " . $empty_slots . "\n";
    }
    if($sun_class == 2)
    {
      foreach(`memconf 2>&1`) 
      {
        # debug
        #print "line: " .$j++ . " " . $flag_mt . "/" . $flag ." : " . "$_";
        # if we find "empty sockets:", we have reached the end and indicate that by resetting flag = 0
        # emtpy sockets is follow by a list of emtpy slots, where we extract the slot names
        if(/^empty sockets:\s*(\S+)/)
        {
          $flag = 0;
          # cut of first 15 char containing the string empty sockets:
          substr ($_,0,15) = "";
          $capacity = "empty";
          $numslots = 0;
          foreach $caption (split)
          {
            if ($caption eq "None") 
            {
              $empty_slots = 0;
              # no empty slots -> exit loop
              last;
            }
            # debug
            #print "Caption: " . $caption . " Description: " . $description . " Bank Number: " . $numslots . " DIMM Capacity: " .  $capacity . "MB\n";
            $empty_slots++;
            $common->addMemory({
              CAPACITY => $capacity,
              DESCRIPTION => $description,
              CAPTION => $caption,
              SPEED => $speed,
              TYPE => $type,
              NUMSLOTS => $numslots
            })
          }
        }
    if(/.*Memory Module Groups.*/)
    {
        $flag = 0;
        $flag_mt = 0;
    }    
        # we only grap for information if flag = 1
        if($flag && /^\s*\S+\s+\S+\s+(\S+)/){ $caption = $1; }
        if($flag && /^\s*(\S+)/){ $numslots = $1; }
        if($flag && /^\s*\S+\s+\S+\s+\S+\s+(\d+)/){ $capacity = $1; }
        if($flag)
        {
          # debug
          #print "Caption: " . $caption . " Description: " . $description . " Bank Number: " . $numslots . " DIMM Capacity: " .  $capacity . "MB\n";
          $module_count++;
          $common->addMemory({
            CAPACITY => $capacity,
            DESCRIPTION => "DIMM",
            CAPTION => "Ram slot ".$numslots,
            SPEED => $speed,
            TYPE => $type,
            NUMSLOTS => $numslots
          })
        }
          # this is the caption line 
        if(/^ID       ControllerID/) { $flag_mt = 1; $description = $1;}
        # if we find "---", we set flag = 1, and in next line, we start to look for information
            if($flag_mt && /^-+/){ $flag = 1;}
      }
      # debug: show number of modules found and number of empty slots
    }
   
    if($sun_class == 3)
    {
      # socket MB/MEM3/CMP3/BR1/CH1/D2 has a Micron Technology 36HTF51272F80EE1D4 4GB FB-DIMM
      foreach(`memconf 2>&1`) 
      {
        # debug
        if(/^empty sockets:\s*(\S+)/)
        {
          # cut of first 15 char containing the string empty sockets:
          substr ($_,0,15) = "";
          $description = "";
          $type = "";
          $capacity = "empty";
          $numslots = 0;
          foreach $caption (split)
          {
            if ($caption eq "None") 
            {
              $empty_slots = 0;
              # no empty slots -> exit loop
              last;
            }
            # debug
            #print "Caption: " . $caption . " Description: " . $description . " Bank Number: " . $numslots . " DIMM Capacity: " .  $capacity . "MB\n";
            $empty_slots++;
            $common->addMemory({
              CAPACITY => $capacity,
              DESCRIPTION => $description,
              CAPTION => $caption,
              SPEED => $speed,
              TYPE => $type,
              NUMSLOTS => $numslots
            })
          }
        }
        # socket MB/MEM3/CMP3/BR1/CH1/D2 has a Micron Technology 36HTF51272F80EE1D4 4GB FB-DIMM
        if(/^socket\s+(\S+) has a (.+) (\d+)GB (\S+)/) 
        {
    $caption = $1;
          $description = $2;
          $type = $4;
          $numslots = 0;
          $capacity = $3 * 1024;
          # debug
          #print "Caption: " . $caption . " Description: " . $description . " Bank Number: " . $numslots . " DIMM Capacity: " .  $capacity . "MB\n";
          $module_count++;
          $common->addMemory({
            CAPACITY => $capacity,
            DESCRIPTION => $description,
            CAPTION => $caption,
            SPEED => $speed,
            TYPE => $type,
            NUMSLOTS => $numslots
          })
        }
	# socket P1C1/B31/C1/D0 (LUN 0 ID 124): Samsung 32768MB DDR4 SDRAM DIMM, M393A4K40BB1-CRC
	if(/^socket\s+(\S+) \(LUN \d+ ID \d+\): (.+) (\d+)MB (\S+) (\S+) DIMM, (\S+)/)
	{
	  $caption = $1;
	  $description = "$2 $6";
	  $type = "$4 $5";
	  $numslots = 0;
	  $capacity = $3;
	  $module_count++;
          $common->addMemory({
            CAPACITY => $capacity,
            DESCRIPTION => $description,
            CAPTION => $caption,
            SPEED => $speed,
            TYPE => $type,
            NUMSLOTS => $numslots
          })
	}
      }
      # debug: show number of modules found and number of empty slots
      #print "# of RAM Modules: " . $module_count . "\n";
      #print "# of empty slots: " . $empty_slots . "\n";
    }

    if($sun_class == 4)
    {
      foreach(`memconf 2>&1`) 
      {
        # debug
        #print "line: " .$j++ . " " . $flag_mt . "/" . $flag ." : " . "$_";
        # if we find "empty sockets:", we have reached the end and indicate that by resetting flag = 0
        # emtpy sockets is follow by a list of emtpy slots, where we extract the slot names
        if(/^empty sockets:\s*(\S+)/)
        {
          $flag = 0;
          # cut of first 15 char containing the string empty sockets:
          substr ($_,0,15) = "";
          $capacity = "empty";
          $numslots = 0;
          foreach $caption (split)
          {
            if ($caption eq "None") 
            {
              $empty_slots = 0;
              # no empty slots -> exit loop
              last;
            }
            # debug
            print "Caption: " . $caption . " Description: " . $description . " Bank Number: " . $numslots . " DIMM Capacity: " .  $capacity . "MB\n";
            $empty_slots++;
            $common->addMemory({
              CAPACITY => $capacity,
              DESCRIPTION => $description,
              CAPTION => $caption,
              SPEED => $speed,
              TYPE => $type,
              NUMSLOTS => $numslots
            })
          }
        }
    
        # we only grap for information if flag = 1
        # socket MB/CMP0/BR0/CH0/D0 has a Samsung 501-7953-01 Rev 05 2GB FB-DIMM
        if(/^socket\s+(\S+) has a (.+)\s+(\S+)GB\s+(\S+)$/i)
        {
    $caption = $1;
          $description = $2;
          $type = $4;
          $numslots = 0;
          $capacity = $3 * 1024;
          # debug
          #print "Caption: " . $caption . " Description: " . $description . " Bank Number: " . $numslots . " DIMM Capacity: " .  $capacity . "MB\n";
          $module_count++;
          $common->addMemory({
            CAPACITY => $capacity,
            DESCRIPTION => $description,
            CAPTION => $caption,
            SPEED => $speed,
            TYPE => $type,
            NUMSLOTS => $numslots
          })
        }
      }
      # debug: show number of modules found and number of empty slots
      #print "# of RAM Modules: " . $module_count . "\n";
      #print "# of empty slots: " . $empty_slots . "\n";
    }

    if ($sun_class ==  5 )
    {
      foreach(`memconf 2>&1`)
      {
          # debug
          #print "line: " .$j++ . " " . $flag_mt . "/" . $flag ." : " . "$_";
          # if we find "empty sockets:", we have reached the end and indicate that by resetting flag = 0
          # emtpy sockets is follow by a list of emtpy slots, where we extract the slot names
          if(/^total memory.*(\S+)/) { $flag = 0;}

          #print "flag : $flag\n";
          if($flag_mt && /^\s+\S+\s+\S+\s+\S+\s+(\S+)/) {$flag_mt=0;  $type = $1;}
          #print "description : $description\n";

          if ($flag && /^\s(\S+)\s+(\S+)/) { $numslots = "LSB " . $1 . " Group " . $2; }
          if ($flag && /^\s(\S+)\s+(\S+)/) { $caption = "LSB " . $1 . " Group " . $2; }
          if ($flag && /^\s+\S+\s+\S\s+\S+\s+\S+\s+(\d+)/) { $capacity = $1; }
          if ($flag && /^\s+\S+\s+\S\s+(\d+)/) { $banksize = $1; }
          #print "Num slot ". $numslots  . " Bank Number: " . $numslots . " Bank size " .  $banksize . " DIMM Capacity: " .  $capacity . "MB\n";
          if ($flag && $capacity > 1 )
          {
                  for (my $i = 1; $i <= ($banksize / $capacity); $i++)
                  {
                  #print "caption ". $caption  . " Bank Number: " . $numslots . " Bank size " .  $banksize . " DIMM Capacity: " .  $capacity . "MB\n";
                  $common->addMemory({
                  CAPACITY => $capacity,
                  DESCRIPTION => $description,
                  CAPTION => $caption,
                  SPEED => $speed,
                  TYPE => $type,
                  NUMSLOTS => $module_count
                  })
                  }
                  $module_count++;
          }
          #Caption Line
          if (/^Sun Microsystems/) { $flag_mt=1; $flag=1; }
      }
    }
    if($sun_class == 6)
    {
      #CPU1_D2 BANK2: 4096MB DDR3 DIMM, Samsung M393B5170EH1-CH9	(SUN FIRE X4270)
      #DIMM 1A: 4096MB Synchronous DDR2 FBDIMM	(ProLiant DL380 G5)
      #Board 1, DIMM 1A: 8192MB Synchronous DDR3			(ProLiant DL580 G7)
      #PROC  1 DIMM 12: 16384MB Synchronous DDR3 DIMM, HP		(ProLiant DL380p Gen8)
      #PROC 1 DIMM 12: 32768MB Synchronous DIMM, HP 752372-081	(ProLiant DL380 Gen9)
      #XMM1: 2048MB Synchronous DDR2 DIMM, Elpida EBE21UE8AEFA-8G-E	(HP Desktop PC)
      #DIMM_1: 1024MB Synchronous DDR2 DIMM, Kingston KCM633-ELC	(Dell Desktop PC)
      foreach(`memconf 2>&1`)
      {
        # debug
        #print "line: " .$j++ . " " . $flag_mt . "/" . $flag ." : " . "$_";
        if(/^empty memory sockets:\s*(\S+)/)
        {
          # cut of first 22 char containing the string empty sockets:
          substr ($_,0,22) = "";
          chomp();
	  $capacity = "0";
          $numslots = 0;
          foreach $caption (split(/, /,$_))
          {
            if ($caption eq "None")
            {
              $empty_slots = 0;
              # no empty slots -> exit loop
              last;
            }
            # debug
            #print "Caption: " . $caption . " Description: " . $description . " Bank Number: " . $numslots . " DIMM Capacity: " .  $capacity . "MB\n";
            $empty_slots++;
            if ($caption =~ /.* (\d+)$/) { $numslots = $1; }
            $common->addMemory({
              CAPACITY => $capacity,
              DESCRIPTION => "empty",
              CAPTION => $caption,
              SPEED => 'n/a',
              TYPE => 'n/a',
              NUMSLOTS => $numslots
            })
          }
        }
        # These are the non-emtpy sockets in various formats
        #DIMM 1A: 4096MB Synchronous DDR2 FBDIMM				(ProLiant DL380 G5)
        #Board 1, DIMM 1A: 8192MB Synchronous DDR3			(ProLiant DL580 G7)
        #PROC  1 DIMM 12: 16384MB Synchronous DDR3 DIMM, HP		(ProLiant DL380p Gen8)
        if(/^(.*DIMM) (\S+):\s+(\d+)MB\s(\S+ DDR\d+)\s*(\w*)?(,?.*)/)
        {
          $caption = "$1 $2";
          $description = "$4 $5$6";
          $numslots = $2;
          $capacity = $3;
	  $type = $5;
	  unless ($type) { $type = "DIMM" };  # Default if nothing else found
          # debug
          #print "Caption: " . $caption . " Description: " . $description . " Bank Number: " . $numslots . " DIMM Capacity: " .  $capacity . "MB\n";
          $module_count++;
          $common->addMemory({
            CAPACITY => $capacity,
            DESCRIPTION => $description,
            CAPTION => $caption,
            SPEED => $speed,
            TYPE => $type,
            NUMSLOTS => $numslots
          })
        }
        #CPU1_D2 BANK2: 4096MB DDR3 DIMM, Samsung M393B5170EH1-CH9	(SUN FIRE X4270)
        if(/^(.*BANK)(\S+):\s+(\d+)MB\s(\S*DDR\d+)\s*(\w+)?(,?.*)/)
        {
          $caption = "$1 $2";
          $description = "$4 $5$6";
          $numslots = $2;
          $capacity = $3;
	  $type = $5;
          # debug
          #print "Caption: " . $caption . " Description: " . $description . " Bank Number: " . $numslots . " DIMM Capacity: " .  $capacity . "MB\n";
          $module_count++;
          $common->addMemory({
            CAPACITY => $capacity,
            DESCRIPTION => $description,
            CAPTION => $caption,
            SPEED => $speed,
            TYPE => $type,
            NUMSLOTS => $numslots
          })
        }
        #PROC 1 DIMM 12: 32768MB Synchronous DIMM, HP 752372-081		(ProLiant DL380 Gen9)
        if(/^(.*DIMM) (\S+):\s+(\d+)MB\s(\S+)\s+(DIMM\w*)(,?.*)/)
	{
          $caption = "$1 $2";
          $description = "$4 $5$6";
          $numslots = $2;
          $capacity = $3;
	  $type = $5;
          # debug
          #print "Caption: " . $caption . " Description: " . $description . " Bank Number: " . $numslots . " DIMM Capacity: " .  $capacity . "MB\n";
          $module_count++;
          $common->addMemory({
            CAPACITY => $capacity,
            DESCRIPTION => $description,
            CAPTION => $caption,
            SPEED => $speed,
            TYPE => $type,
            NUMSLOTS => $numslots
          })
        }
        #XMM1: 2048MB Synchronous DDR2 DIMM, Elpida EBE21UE8AEFA-8G-E	(HP Desktop PC)
        #DIMM_1: 1024MB Synchronous DDR2 DIMM, Kingston KCM633-ELC	(Dell Desktop PC)
        if(/^(\S+):\s+(\d+)MB\s(.+)\s+(DIMM\w*)(,?.*)/)
        {
          $caption = "$1";
          $description = "$3 $4$5";
          $numslots = $1;
          $capacity = $2;
    $type = $4;
          # debug
          #print "Caption: " . $caption . " Description: " . $description . " Bank Number: " . $numslots . " DIMM Capacity: " .  $capacity . "MB\n";
          $module_count++;
          $common->addMemory({
            CAPACITY => $capacity,
            DESCRIPTION => $description,
            CAPTION => $caption,
            SPEED => $speed,
            TYPE => $type,
            NUMSLOTS => $numslots
          })
        }
      }
      # debug: show number of modules found and number of empty slots
      #print "# of RAM Modules: " . $module_count . "\n";
      #print "# of empty slots: " . $empty_slots . "\n";
    }

    if ($sun_class == 7)
    {
    foreach (`prctl -n project.max-shm-memory $$ 2>&1`)
    {
        
        $description = $1 if /^project.(\S+)$/;        
        $capacity = $1 if /^\s*system+\s*(\d+).*$/;        
        if(($description && $capacity)){
            $capacity = $capacity * 1024;
            $numslots = 1 ;
            $description = "Memory Allocated";
            $caption = "Memory Share";
            #print $description."_".$capacity."***\n";
            $common->addMemory({
              CAPACITY => $capacity,
              DESCRIPTION => $description,
              CAPTION => $caption,
              SPEED => $speed,
              TYPE => $type,
              NUMSLOTS => $numslots
            })
        }
    }
    }    
    

    if($sun_class == 8) {
      # example output of a Sun Blade 100 Workstation

      #Sun Microsystems, Inc. Sun Blade 100 (UltraSPARC-IIe 502MHz)
      #Memory Segment Table:
      #-----------------------------------------------------------------------
      #Base Address       Size       Interleave Factor  Contains
      #-----------------------------------------------------------------------
      #0x0                256MB             1           chassis/system-board/DIMM0
      #empty sockets: DIMM1 DIMM2 DIMM3
      #total memory = 256MB

      #Sun Microsystems, Inc. Sun Blade 100 (UltraSPARC-IIe 502MHz)
      #Memory Segment Table:
      #-----------------------------------------------------------------------
      #Base Address       Size       Interleave Factor  Contains
      #-----------------------------------------------------------------------
      #0x0                256MB             1           Label DIMM0
      #0x20000000         256MB             1           Label DIMM1
      #empty sockets: DIMM2 DIMM3
      #total memory = 512MB

      foreach(`memconf 2>&1`) {
        if (/^empty sockets:\s*(.+)/) {
          foreach $caption (split(/ /, $1)) {
            if ($caption eq "None") {
              $empty_slots = 0;
              last;
            }
            $empty_slots++;
   #         print "empty slot\n";
            $common->addMemory({
              CAPACITY => "empty",
              DESCRIPTION => '',
              CAPTION => $caption,
              SPEED => '',
              TYPE => '',
              NUMSLOTS => $numslots
            })
          }
         }
        if (/^0x(\d+)\s+(\d+)(\S)B\s+(\S+)\s+(.+)/) {
          $caption = "$5";
          $description = "";
          $numslots = 0;
          $capacity = $2 if ( $3 eq "M" );
          $capacity = $2 * 1024 if ( $3 eq "G" );
          $type = "";
          # debug
#        print "Caption: " . $caption . " Description: " . $description . " Bank Number: " . $numslots . " DIMM Capacity: " .  $capacity . "MB\n";
          $module_count++;
          $common->addMemory({
            CAPACITY => $capacity,
            DESCRIPTION => $description,
            CAPTION => $caption,
            SPEED => $speed,
            TYPE => $type,
            NUMSLOTS => $numslots
          })
        }
      }
    }
}
#run();
1;