#! /usr/bin/perl use strict ; use warnings ; my $OMREPORT = '/opt/dell/srvadmin/bin/omreport' ; my $prog = substr $0, rindex ( $0, '/' ) + 1 ; my $Usage = <>/tmp/omreport' ) { printf LOG "%s\n", scalar localtime ; printf LOG "$prog [%s]\n", join ',', @ARGV ; printf LOG "running [%s] ...\n", join ',', @OMREPORT ; close LOG ; } open REP, '-|', @OMREPORT or Error "can't popen [@OMREPORT] ($!)" ; my @lines = ; close REP ; # Controller PERC 6/i Integrated (Embedded) # ID : 0:0:0 # Status : Ok # Name : Physical Disk 0:0:0 # State : Online # Power Status : Not Applicable # Bus Protocol : SATA # Media : HDD my $ids = 0 ; my $onl = 0 ; for my $line ( @lines ) { chomp $line ; if ( $line =~ /^\w+\s+:\s+\S+/ ) { my ( $key, $val ) = split /\s+:\s+/, $line, 2 ; if ( $key eq 'ID' ) { print $line, "\n" if $opt{d} ; $ids ++ ; } elsif ( $key eq 'Status' ) { print $line, "\n" if $opt{d} ; $onl ++ if $val eq 'Ok' ; } } } if ( $opt{v} ) { printf "run : @OMREPORT\n" ; printf "found id's : %d\n", $ids ; printf "found online : %d\n", $onl ; } printf "bad %d\n", $ids - $onl ;