File: //var/opt/OV/bin/instrumentation/OvVirtual.pm
###############################
#
# Version : 11.11.025
#
###############################
package OvVirtual;
#######################################################################
#Generic utility functions...
#######################################################################
require Exporter;
use vars qw($VERSION @ISA @EXPORT);
use POSIX;
use Config;
# set the version for version checking
$VERSION = 0.01;
@ISA = qw(Exporter);
sub new {
my $receiver = shift;
my $class = (ref $receiver or $receiver);
my $self = bless {}, $class;
return $self;
}
# Get Frame name given a LPAR, check if data is logged in class VISPI and return
sub GetLPARFrameHMCDetails
{
my $arg = shift;
{
# Set === as record separator
local $/ = "===";
my $foundLPARFrame=0;
open (OVCODADUMP, "ovcodautil -ds VISPI -o LPAR_CONFIGURATION -flat -last|") or return -1;
while (<OVCODADUMP>)
{
chomp;
my %cur_hash = {};
my @lines = split (/\n/, $_);
if ( !scalar(@lines) )
{
next;
}
foreach my $line (@lines)
{
chomp;
my @fields = split (/\s*\:\s*/, $line);
$cur_hash{$fields[0]} = (($fields[1])? $fields[1]: "na");
}
if ( exists($cur_hash{"LPAR_NAME"}) )
{
my ($thisLPAR, @other) = split/\./, $arg;
if ($cur_hash{"LPAR_NAME"} =~ /$thisLPAR/ )
{
$foundLPARFrame = $cur_hash{"FRAME_NAME"}.":".$cur_hash{"HMC_NAME"};
last;
}
}
}
close (OVCODADUMP);
return $foundLPARFrame;
}
}
sub GetLPARFrameCPUCount
{
open(LPARSTATINFO,"lparstat -i |");
my $LPARFrameCPUNo;
my @Fileinfo = <LPARSTATINFO>;
foreach $line(@Fileinfo)
{
chomp;
@lineInfo=split(/:/,$line);
$lineInfo[0]=~ s/^\s+//;
$lineInfo[0]=~ s/\s+$//;
if($lineInfo[0] eq "Active Physical CPUs in system")
{
$LPARFrameCPUNo= $lineInfo[1];
last;
}
}
close(LPARSTATINFO);
if(!$LPARFrameCPUNo)
{
return -1;
}
else
{
return $LPARFrameCPUNo;
}
}
sub GetLPARFrameID
{
{
# Set \n as record separator
local $/ = "\n";
open(LPARSTATINFO,"prtconf |");
my $key, $LPARFrameSerialNo;
foreach $line(<LPARSTATINFO>)
{
chomp($line);
if ( $line =~ "Machine Serial Number" )
{
($key, $LPARFrameSerialNo)=split(/: /,$line);
last;
}
}
close(LPARSTATINFO);
if(!$LPARFrameSerialNo)
{
return -1;
}
else
{
return $LPARFrameSerialNo;
}
}
}
1;