Parse::DMIDecode::Examples(3pm)

Parse::DMIDecode::Examples3pm

Examples using parse::dmidecode::examples

Examples

Example 1: Find the Number of Physical CPUs

 use strict;
 use Parse::DMIDecode qw();
 
 my $dmi = Parse::DMIDecode->new( nowarnings => 1 );
 $dmi->probe;
 
 my $physical_cpus = 0;
 for my $handle ($dmi->get_handles(group => "processor")) {
     my $type = ($handle->keyword("processor-type") or "");
     next unless $type =~ /Central Processor/i;
 
     # Check the status of the cpu
     my $status = ($handle->keyword("processor-status") or "");
     if ($status !~ /Unpopulated/i) {
         $physical_cpus++;
     }
 }
 
 printf("There %s %d physical %s in this machine.\n",
         ($physical_cpus == 1 ? "is" : "are"),
         $physical_cpus,
         ($physical_cpus == 1 ? "CPU" : "CPUs"),
     );

Releases

8 releases since Debian 6.0 (Squeeze); the text changed 3 times.

  1. 6.0–8
  2. 9–10
  3. 11
  4. 12–13

From libparse-dmidecode-perl 0.03-4 in Debian 13 (Trixie). Parsed by carta from the page's man source.