How do you determine the amount of system memory?

Frank DiPrete fdiprete at comcast.net
Sun Aug 3 16:47:32 EDT 2008



Bill McGonigle wrote:
> On Aug 3, 2008, at 13:50, Ben Scott wrote:
> 
>>   Situation seems to be getting murkier by the minute.  :)
> 
> The difference in Memtotal?  This can at least be affected by shared  
> RAM, etc.
> 
> I found a few (older) machines that needed -t 6 and some (newer)  
> servers that needed -t 17.
> 
> Here's a quick script that seems to work on both types:
> 
> #-------- BEGIN realmem.pl -----------
> #!/usr/bin/perl -w
> use strict;
> use warnings FATAL => 'all';
> 
> my $sudo = '/usr/bin/sudo';
> my $dmidecode = '/usr/sbin/dmidecode';
> my @types = (6,17);
> 
> my (%t, at size_lines);
> foreach my $type (@types) {
>      $t{$type} = `$sudo $dmidecode -t $type`;
>      my @lines = split("\n",$t{$type});
>      my @this_size_lines = grep(/Size:/, at lines);
>      @this_size_lines = grep(!/Installed/, at this_size_lines);
>      push(@size_lines, at this_size_lines);
> }
> 
> my (@sizes);
> foreach my $line (@size_lines) {
>      $line =~ m/(\d*) (\w)B/;
>      $1 *= 1024 if ($2 eq 'G'); # GB to MB
>      push(@sizes,$1);
> }
> 
> my $total_size = 0;
> foreach my $size (@sizes) {
>      $total_size += $size
> }
> 
> my $prefix = 'M';
> if ($total_size >= 1024) {
>      $total_size = $total_size / 1024;
>      $prefix = 'G';
> }
> 
> print "Total Memory Size: $total_size $prefix" . 'B' . "\n";
> #-------- END realmem.pl -----------
> 

nice one.
love the use of dmidecode.
I saved this puppy.


> -Bill
> 
> -----
> Bill McGonigle, Owner           Work: 603.448.4440
> BFC Computing, LLC              Home: 603.448.1668
> bill at bfccomputing.com		Cell: 603.252.2606
> http://www.bfccomputing.com/    Page: 603.442.1833
> Blog: http://blog.bfccomputing.com/
> VCard: http://bfccomputing.com/vcard/bill.vcf
> 
> _______________________________________________
> gnhlug-discuss mailing list
> gnhlug-discuss at mail.gnhlug.org
> http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/
> 
> 


More information about the gnhlug-discuss mailing list