#!/usr/local/bin/perl $scsi_cmd = "./g_scsi"; $main = "/damon/main.html"; $img = "/damon/"; $myself = "/cgi-bin/dm.pl"; $ENV{'PATH'} = '/bin:/usr/bin'; $ENV{'SHELL'} = '/bin/sh' if $ENV{'SHELL'} ne ''; $ENV{'IFS'} = '' if $ENV{'IFS'} ne ''; &Get_Para; # Get & setup Input parameters # Print out a content-type for HTTP/1.0 compatibility print "Content-type: text/html\n\n"; print " DA Monitor Temp "; print " "; print "

TEXA Disk Array Monitor


"; &Get_RAID_Mode; # get status $er0 = $max+1; # dummy for no error $er1 = $max+1; # dummy for no error for( $i = 0; $i <= $max; $i++ ){ &Disp_disk; # display disk mark } print "

"; &Status_Display; # display current status &Mode_Table; # display operation mode table print "

To Main Menu
"; exit; # # Get RAID mode # sub Get_RAID_Mode { open(SCSI, "$scsi_cmd $port $id 2|"); # RAID sense page 1 read(SCSI, $buf, 1024); @nums = split(/ /, $buf); if ($nums[0] != 0) { print "SCSI access Error
\n"; } else { $raid=hex($nums[7]); # RAID Number $max = hex($nums[8])-1; # maximum drive number if ($max == -1) {$max = 2;} # old version so default=3 drives $spare = hex($nums[9]); # spare drive count } close(SCSI); open(SCSI, "$scsi_cmd $port $id 3|"); # RAID sense page 2 read(SCSI, $buf, 1024); @nums = split(/ /, $buf); if ($nums[0] != 0) { print "SCSI access Error
\n"; } else { $stat = hex($nums[7]); for ($i=0; $i <= $max; $i++){ $dvm[$i] = hex($nums[$i+8]); # get each drive status } } close(SCSI); } # # Display Disk Mark # $er= error drive number # $drmod=0:no disk 1:down 2:replaced # sub Disp_disk{ print " $i $max) { # first down $drmod0 = $dvm[$i]; $er0 = $i;} else { # second down or more $drmod1 = $dvm[$i]; $er1 = $i;} if ($dvm[$i] == 3) {print "day.gif";} elsif ($dvm[$i] > 3) {print "dan.gif";} else {print "dar.gif";}} print "\" WIDTH=\"32\" HEIGHT=\"32\" NATURALSIZEFLAG=\"0\" ALIGN=\"TOP\"> "; } # # Display Status # $stat= 0:normal 1:one down # 2:reduced 3:recovering # 4:rebuilding 5:copy back # >5:system down # sub Status_Display { print "

"; if ($stat == 0) {print "NORMAL

ALL DRIVES OK

";} else { if($stat==1){print "ONE DOWN";} if($stat==2){print "REDUCED";} if($stat==3){print "RECOVERING";} if($stat==4){print "REBUILDING";} if($stat==5){print "COPY BACK";} if($stat >5){print "SYSTEM DOWN";} print "

"; &Down_Drive; print "

";} } # # Display Down Drive Mode # $drmod= 0:no drive 1:with down dirve 2:replaced # sub Down_Drive { if ( $stat >5 ){ if ($er1 <= $max){ print "Down Drives are ",$er0," and ",$er1; print " or more.";} else{print "Down Drive is $er0.";} } else{ if ( $drmod0 > 3 ){ $drmod0 =0 } if ( $drmod0 == 3 ){print "DRIVE $er0 Replaced";} elsif($drmod0 == 1){print "DRIVE $er0 Down";} else { print "DRIVE $er0 No Drive";} if ( $er1 <= $max){ print "
"; if( $drmod1 > 3 ){ $drmod1 =0 } if( $drmod1 == 3 ){print "DRIVE $er1 Replaced";} elsif($drmod1 == 1){print "DRIVE $er1 Down";} else { print "DRIVE $er1 No Drive";} } } } # # Display operating mode # sub Mode_Table { print "
"; print "
Current Operating Mode
RAID ModeRAID-",$raid,"
Total Drives",$max+1,"
With Spare Drive"; if ($spare == 0) {print "No";} else {print "Yes";} print "
"; } # # Get input parameters # sub Get_Para{ #read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); #POST $buffer=$ENV{'QUERY_STRING'}; #GET @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); # Un-Webify plus signs and %-encoding $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $FORM{$name} = $value; } $port = $FORM{'port'}; # SCSI card port number if ($port == "") {$port = 0;} $id = $FORM{'id'}; # SCSI ID number if ($id == "") {$id = 0;} $time = $FORM{'int'}; # SCSI ID number if ($time == 0) {$time = 10;} }