/
usr
/
lib
/
raider
/
Raider
/
Jobs
/
File Upload :
llllll
Current File: //usr/lib/raider/Raider/Jobs/MegaraidSATA.pm
use strict; use warnings; package Raider::Jobs::MegaraidSATA; use base qw( Raider::Jobs ); use Raider::Notification::API; use Raider::Notification::Email; =head1 NAME Raider::Jobs::MegaraidSATA - MegaraidSATA specific tasks for checking raid health =head1 DESCRIPTION Checks raid health for MegaraidSATA cards. =head1 USAGE use Raider::Jobs::MegaraidSATA; my jobsMegaraidSATA = Raider::Jobs::MegaraidSATA->new(); =head1 METHODS =head2 run_job Takes all needed actions for checking raid health. =head2 get_controller_list() Returns a list of controllers. =head2 get_array_list(\%args) Returns a list of arrays. =head2 array_is_ok(\%args) Returns true if array is healthy. =cut # There are quite a few "bashisms" left in this file, making it a tad uglier I # know. However, this is one old controller, and there aren't that many around # anymore. Haven't yet taken the time to clean this up, but its working fine.. # TODO: Cleanup this file :EDT ssullivan Apr 16th, 2014 my $icmd = '/usr/local/bin/megarc'; sub run_job { my $self = shift; $self->icmd_in_path({ icmd => "$icmd" }); my $output; my $raid_bad = 0; my $controller_list_ref = $self->get_controller_list(); my @controller_list = @$controller_list_ref; for my $controller ( @controller_list ) { my $array_list_ref = $self->get_array_list({ controller => "$controller" }); my @array_list = @$array_list_ref; for my $u ( @array_list ) { unless ( $self->array_is_ok({ controller => "$controller", u => "$u" }) ) { $output .= `$icmd -ldInfo -a$controller -L$u | col`; ## Remove vt100 escape sequences megarc generates. $raid_bad = 1; } }; }; my $notIfAPI = Raider::Notification::API->new(); my $notIfEmail = Raider::Notification::Email->new(); if ( $raid_bad ) { if ( $notIfAPI->can_alert({ notify_type => 'MegaraidSATA' }) ) { $self->logger({ cat => 'w', msg => 'MegaraidSATA Hardware RAID Alarm Detected' }); my $notify_msg = "MegaraidSATA Hardware RAID Alarm Detected on [$Raider::Base::base_conf{'hostname'}] at [$self->{uniq_id}]\nDetails:\n $output"; if ( $notIfAPI->can_api() ) { $notIfAPI->send_notification({ message => $notify_msg }); } else { $notIfEmail->send_notification({ subject => "RAID Controller Alarm on $Raider::Base::base_conf{'hostname'}", message => $notify_msg }); } $notIfAPI->place_alert({notify_type => 'MegaraidSATA'}); } else { $self->logger({ cat => 'w', msg => 'Notification for MegaraidSATA suppressed, alert file for today already exists.' }); } } else { # health is ok, clear alerts for device $notIfAPI->clear_alerts_for_device('MegaraidSATA'); } } sub get_controller_list { my $self = shift; my $mark = `$icmd -allAdpInfo | grep -n "AdapterNo" | cut -d : -f 1`; my $end = `$icmd -allAdpInfo | wc -l`; chomp($mark,$end); my $ctotal = $end - $mark; $ctotal--; my @ctotal_final = ( `seq 0 $ctotal` ); chomp(@ctotal_final); return \@ctotal_final; } sub get_array_list { my $self = shift; my $opts = shift; my $utotal = `$icmd -ldInfo -a$opts->{controller} -Lall | egrep '^[[:space:]]+\\*\\*\\*\\*\\*\\*\\*Information Of Logical Drive[[:space:]]+[[:digit:]]+\\*\\*\\*\\*\\*\\*\\*' | wc -l`; $utotal = $self->strip_whitespace({ string => $utotal }); $utotal--; my @array_list = ( `seq 0 $utotal` ); chomp(@array_list); return \@array_list; } sub array_is_ok { my $self = shift; my $opts = shift; my $check = `$icmd -ldInfo -a$opts->{controller} -L$opts->{u} | grep "Status: "| awk -F: '{print \$NF}'`; $check = $self->strip_whitespace({ string => $check }); if ( $check eq 'OPTIMAL' ) { return 1; } return 0; } 1;
Copyright ©2k19 -
Hexid
|
Tex7ure