#!/usr/bin/perl # # This is a wrapper for dmidecode that will return the configured UUID # when 'dmidecode -s system-uuid' is called. Otherwise, it will call dmidecode # and return as appropriate. # use strict; use warnings; use IO::Handle; # Desired System UUID my $uuid; my $exit=0; my $sub=0; my $core_count = 4; my $core_enabled = 4; my $core_threads = 4; # Read command line. my $cla=""; foreach my $arg (@ARGV) { $cla.=$arg." "; } $cla=~s/\s+$//; #if ($cla eq "-q -t 0,1,4,17") if ($cla eq "-t 4,16,17") { $sub = 1; } # Call the real dmidecode my $sc = "/usr/sbin/dmidecode.orig $cla 2>&1 |"; my $fh = IO::Handle->new(); open ($fh, $sc) or die $!; while (<$fh>) { chomp; my $line=$_; # If I found a UUID, this line is the UUID and I am doing a # substitution, well, do it already. if (($core_count) && ($line =~ /(\s+)Core Count: /) && ($sub)) { my $space = $1; print "${space}Core Count: $core_count\n"; } elsif (($core_enabled) && ($line =~ /(\s+)Core Enabled: /) && ($sub)) { my $space = $1; print "${space}Core Enabled: $core_enabled\n"; } elsif (($core_threads) && ($line =~ /(\s+)Thread Count: /) && ($sub)) { my $space = $1; print "${space}Thread Count: $core_threads\n"; } else { print $line, "\n"; } } $fh->close(); $exit = $?; exit($exit);