~ K    A     L    I ~
UNAME : Linux web65.extendcp.co.uk 4.18.0-553.56.1.el8_10.x86_64 #1 SMP Tue Jun 10 05:00:59 EDT 2025 x86_64
SERVER IP : 10.0.187.65 -________- CLIENT IP : 216.73.216.254
PATH :/usr/share/perl5/vendor_perl/HI/Hardware/
UP FILE :
MINI SHELL D ZAB '
Current File : //usr/share/perl5/vendor_perl/HI/Hardware/Dell.pm
package HI::Hardware::Dell;

use strict;
use warnings;

use XML::Simple;

sub new {
	my $class = shift;
	my $self = {
		summary => ''
	};
	bless $self, $class;
	$self->{summary} = $self->get_xml( "system summary" );
	$| = 1;
	return $self;
}

sub memory {
	my $self = shift;
	my @sticks;
	my $memory_sticks = $self->find_and_get_key( $self->{summary}, "MemPortConnList" )->{PortGeneric};
	for my $mem ( @{ $memory_sticks } ) {
		next unless exists $mem->{MemoryDevice}->{SizeMB}->{content};
		push @sticks, $mem->{MemoryDevice}->{SizeMB}->{content};
	}
	return @sticks;
}

sub vds {
	my $self = shift;
	my $vdisk = $self->get_xml( "storage vdisk" );
	my $vdisks = $self->find_and_get_key( $vdisk, "VirtualDisks" )->{DCStorageObject}; #arrayref ->{Layout} ->{Length}
	$vdisks = ( $vdisks =~ m/ARRAY/ ) ? $vdisks : [ $vdisks ] ;
	my @vds;
	for my $vd ( @{ $vdisks } ) {
		next unless exists $vd->{Layout} and exists $vd->{Layout}->{content};
		next unless exists $vd->{DeviceName}->{content};
		my $partition = $vd->{DeviceName}->{content};
		$partition =~ s#.*/##;
		my $level = $self->get_raid_layout($vd->{Layout}->{content});
		my $size_mb = int ($vd->{Length}->{content} / 1024 / 1024 );
		push @vds, {level => $level, size_mb => $size_mb, partition => $partition};
	}
	return @vds;
}

sub pds {
	my $self = shift;
	my $pdisk = $self->get_xml( "storage pdisk controller=0" );
	my $pdisks = $self->find_and_get_key( $pdisk, "ArrayDisks" )->{DCStorageObject}; #arrayref ->{Vendor}/{ProductID} ->{DeviceSerialNumber} ->{Length} ->{
	my @pds;
	# physical disks
	for my $pd ( @{ $pdisks } ) {
		push @pds, {size_mb => int($pd->{Length}->{content}/1024/1024), model => $pd->{ProductID}->{content}, serial => $pd->{DeviceSerialNumber}->{content}};
	}
	return @pds;
}

sub cpus {
	my $self = shift;
	my @cpus;

	my $cpu_count = $self->find_and_get_key( $self->{summary}, "ProcessorList" )->{count};
	my $cpu_model = $self->find_and_get_key( $self->{summary}, "DevProcessor" );
	$cpu_model = $cpu_model =~ m/ARRAY/ ? $cpu_model->[0]->{Version} : $cpu_model->{Version} ;
	$cpu_model =~ s#\s+# #mg;

	for ( 1 .. $cpu_count ) {
		push @cpus, $cpu_model;
	}
	return @cpus;
}

sub chassis {
	my $self = shift;
	my $model = $self->find_and_get_key( $self->{summary}, "ChassModel" );
	my $ss_tag = $self->find_and_get_key( $self->{summary}, "ServiceTag" );
	if(defined($ss_tag)) {
		$ss_tag = $ss_tag =~ m/HASH/ ? $ss_tag->{content} : $ss_tag ;
	}
	return $model, $ss_tag;
}

sub controllers {
	my $self = shift;
	return $self->find_and_get_key( $self->{summary}, "ControllerName" );
}

# raid lookup
sub get_raid_layout {
	my $self = shift;
	my $int = shift;
	chomp ( my $xml = qx( cat /opt/dell/srvadmin/var/lib/openmanage/xslroot/sm/template/common/Utils.xsl ) );
	my $obj = XMLin $xml;
	my $raids = $self->find_and_get_key( $obj, "GetRaidLayout" )->{"xsl:choose"}->{"xsl:when"};
	for my $r ( @{ $raids } ) {
		my $test = $r->{test};
		$test =~ m/(\d+)/ or next;
		my $match = $1;
		if ( $int == $match ) {
			$r->{"xsl:value-of"}->{"select"} =~ m/RAID(\d+)/ and return $1;
		}
	}
}

# key finder
sub find_and_get_key {
	my $self = shift;
	my ( $tree, $wanted_key ) = @_;
	my $ret;

	if ( $tree =~ m/ARRAY/ ) {
		for my $item ( @{ $tree } ) {
			return $ret if $ret = $self->find_and_get_key( $item, $wanted_key );
		}
	} elsif ( $tree =~ m/HASH/ ) {
		for my $key ( keys %{ $tree } ) {
			return $tree->{$key} if $key eq $wanted_key;
			return $ret if $ret = $self->find_and_get_key( $tree->{$key}, $wanted_key );
		}
	}

	return undef;
}

sub get_xml {
	my $self = shift;
	my $sub_system = shift;
	$SIG{ALRM} = sub { warn "omreport didn't complete before timeout"; exit 1; };
	alarm(60);
	chomp ( my $xml = qx( /opt/dell/srvadmin/bin/omreport $sub_system -fmt xml ) );
	alarm(0);
	die "omreport failed: $?" if ( $? >> 8 );
	return XMLin( $xml );
}

1
Coded by KALI :v Greetz to DR HARD ../ kali.zbi@hotmail.com