Interface to smbios using dmidecode
use strict; use Parse::DMIDecode (); my $decoder = new Parse::DMIDecode; $decoder->probe; # Actively probe using dmidecode # Manually supply your own dmidecode output to be parsed # $decoder->parse(qx(sudo /usr/sbin/dmidecode)); printf("System: %s, %s", $decoder->keyword("system-manufacturer"), $decoder->keyword("system-product-name"), );
This module provides an \s-1OO\s0 interface to \s-1SMBIOS\s0 information through the dmidecode command which is known to work under a number of Linux, \s-1BSD\s0 and BeOS variants.
my $decoder = Parse::DMIDecode->new( dmidecode => "/usr/sbin/dmidecode", nowarnings => 1, );
This is the constructor method to create a Parse::DMIDeocde object. It accepts two optional arguments; \*(C`dmidecode\*(C' and \*(C`nowarnings\*(C'.
The \*(C`dmidecode\*(C' argument specifies the full path and filename of the dmodecode command that should used by the \*(C`probe\*(C' method.
The \*(C`nowarnings\*(C' argument instructs Parse::DMIDecode not to emit any parser warnings.
$decoder->probe;
This method executes an active probe to gather information using the dmidecode command. It does not accept any arguments.
my $raw = qx(sudo /usr/sbin/dmidecode); $decoder->prase($raw);
This method is a passive alternative to the \*(C`probe\*(C' method. It accepts a single string argument which should contain output from the dmidecode command, which it will parse.
my $serial_number = $decoder->keyword("system-serial-number");
my @keywords = $decoder->keywords; my @bios_keywords = $decoder->keywords("bios");
for my $keyword (@bios_keywords) { printf("%s => %s\n", $keyword, $decoder->keyword($keyword) ); }
my @addresses = $decoder->handle_addresses;
use Parse::DMIDecode::Constants qw(@TYPES);
# Available groups to query: bios, system, baseboard, # chassis, processor, memory, cache, connector, slot for my $handle ($decoder->get_handles( group => "memory" )) { printf(">> Found handle at %s (%s):\n%s\n", $handle->address, $TYPES[$handle->dmitype], $handle->raw ); }
See Parse::DMIDecode::Handle for accessor method documentation for handle objects.
my $smbios_version = $decoder->smbios_version;
Returns the \s-1SMBIOS\s0 version number.
my $dmidecode_version = $decoder->dmidecode_version;
Returns the version number of the copy of dmidecode that was used to create the source data that was parsed. This value may not be available when using older versions of dmidecode.
my $memory_address = $decoder->table_location;
my $total_structures = $decoder->structures;
Parse::DMIDecode::Handle, Parse::DMIDecode::Constants, Parse::DMIDecode::Examples, examples/*.pl, <http://search.cpan.org/src/NICOLAW/Parse-DMIDecode-0.03/examples/>, <http://www.nongnu.org/dmidecode/>, <http://linux.dell.com/libsmbios/>, <http://sourceforge.net/projects/x86info/>, <http://www.dmtf.org/standards/smbios>, biosdecode\|(8), dmidecode\|(8), vpddecode\|(8)
$Id: DMIDecode.pm 1004 2007-03-11 12:43:25Z nicolaw $
Nicola Worthington <[email protected]>
<http://perlgirl.org.uk>
If you like this software, why not show your appreciation by sending the author something nice from her Amazon wishlist ?
<http://www.amazon.co.uk/gp/registry/1VZXC59ESWYK0?sort=priority>
Copyright 2006,2007 Nicola Worthington.
This software is licensed under The Apache Software License, Version 2.0.
<http://www.apache.org/licenses/LICENSE-2.0>