~ K A L I ~
UNAME : Linux web63.extendcp.co.uk 4.18.0-553.56.1.el8_10.x86_64 #1 SMP Tue Jun 10 05:00:59 EDT 2025 x86_64SERVER IP : 10.0.187.63 -________-
CLIENT IP : 216.73.216.210 MINI SHELL D ZAB '
Current File : //sbin/check_raid_health.plx |
#!/usr/bin/perl
use strict;
use warnings;
open(SCSIINFO, "/proc/scsi/scsi") or die $!;
my $controller_type = '';
while(<SCSIINFO>) {
$controller_type='perc56_H700' if (/Model: PERC [56]|Model: PERC H7\d0/);
$controller_type='perc4' if /MegaRAID/;
$controller_type='sas6' if /Vendor: Dell\s+Model: VIRTUAL DISK/;
$controller_type='perc_H200' if /Vendor: Dell\s+Model: Virtual Disk/;
}
close(SCSIINFO);
my $optimal = 1;
if( $controller_type eq 'perc56_H700' ) {
# PERC 5/6 tests
open(CLIOUTPUT, "-|", "/usr/sbin/MegaCli -CfgDsply -a0 -NoLog") or die $!;
while(<CLIOUTPUT>) {
chomp;
if( /^State\s*: (.+)/ ) {
$optimal = 0 if $1 ne "Optimal";
}
if( /^Current Cache Policy\s*: (.+?),/ ) {
$optimal = 0 if $1 ne "WriteBack";
}
}
close(CLIOUTPUT) or warn $!;
} elsif( $controller_type eq 'perc4' ) {
# MegaRAID (PERC 4) tests
# This is more complicated as we need to make sure that /dev/megadev0 under the correct major device id.
# This can be determined from /proc/devices
unless( -c "/dev/megadev0" ) {
# We need to create the character special device
my $major_device_id;
open(PROCDEV, "<", "/proc/devices") or die $!;
while(<PROCDEV>) {
$major_device_id = $1 if /(\d+) megadev/;
}
close(PROCDEV) or die $!;
die "Failed to determine major device id" unless $major_device_id;
system("/bin/mknod /dev/megadev0 c $major_device_id 0");
# warn "Found device id: $major_device_id";
}
open(CLIOUTPUT, "-|", "/usr/sbin/megarc.bin -ldInfo -a0 -Lall") or die $!;
while(<CLIOUTPUT>) {
chomp;
s/\r$//;
if( /Status\s*: (.+)/ ) {
$optimal = 0 if $1 ne "OPTIMAL";
}
}
close(CLIOUTPUT) or warn $!;
} elsif( $controller_type eq 'sas6' ) {
open(CLIOUTPUT, "-|", "/usr/sbin/lsiutil -p 1 -a 21,01,0,0") or die $!;
while(<CLIOUTPUT>) {
chomp;
# Volume State: optimal, enabled
if( /Volume State/ ) {
$optimal = 0 if not ($_ =~ /optimal/);
}
}
close(CLIOUTPUT);
} elsif ( $controller_type eq 'perc_H200' ) {
open(CLIOUTPUT, "-|", "/usr/sbin/sas2ircu 0 STATUS") or die $!;
while(<CLIOUTPUT>) {
chomp;
# Volume State: Optimal
if( /Volume State/ ) {
$optimal = 0 if not ($_ =~ /Optimal/);
}
}
close(CLIOUTPUT);
} else {
# Unknown
$optimal = 0;
warn "Unknown controller type, please check /proc/scsi/scsi";
}
print "$optimal\n";
Coded by KALI :v Greetz to DR HARD ../ kali.zbi@hotmail.com