|
ru.linux- RU.LINUX --------------------------------------------------------------------- From : Igor O. Ladygin 2:5020/400 14 May 2007 04:42:19 To : Andrey Slusar Subject : Re: nagios и софтварный raid -------------------------------------------------------------------------------- "Andrey Slusar" <Andrey.Slusar@f1003.n5080.z2.fidonet.org> wrote in message news:r6pnkbef.fsf@dc.hosting.ua... > Здравствуйте. > > Существует или может кто-то делал плагин для мониторинга > софтварного > рейда для nagios'а? Если не найдешь авторитетного, попробуй мой. Сразу предупреждаю, что я не спец в perl, да и плагин лепил на скорую руку по образу и подобию. За одно может и отладится :) =========================================================== #!/usr/bin/perl -w # # Check Raid module for Nagios (C) ASSA, December 2004 # $Id: check_soft_raid.pl,v 1.2 2006/10/30 05:16:07 uid1101 Exp $ my $VER='$Revision: 1.2 $'; my $DATE_VER='$Date: 2006/10/30 05:16:07 $'; ### Modules use strict; use Getopt::Std; ### System variables my $debug=0; # Check file my $infile = "/proc/mdstat"; # Nagios codes my %code=('Ok'=>0,'Warning'=>1,'Critical'=>2,'Unknown'=>3); # Init Options Hash Table my %opts; ### Function # Usage function sub usage { print "Check Raid module for Nagios. $VER\n"; print "Usage : $0 -w <warning level> -c <critical level>\n"; exit $code{'Unknown'}; } ### Code # Parse command line getopt('wch',\%opts); &usage if exists $opts{"h"}; $opts{"w"}=1 unless (exists($opts{"w"})); $opts{"c"}=1 unless (exists($opts{"c"})); my $warning_level=$opts{"w"}; my $critical_level=$opts{"c"}; # Tests unless (-e $infile) { print "File $infile not exist\n"; exit $code{'Unknown'}; } unless (-r $infile) { print "Not enough rights on file $infile\n"; exit $code{'Unknown'}; } # Opening of infile my $infile_test=open (INFILE, "$infile"); unless ($infile_test) { print "Can't open $infile for reading\n"; exit $code{'Unknown'}; } # Normal: #Personalities : [raid1] #read_ahead 1024 sectors # #md2 : active raid1 ida/disc0/part6[0] ida/disc1/part6[1] # 979072 blocks [2/2] [UU] # #md1 : active raid1 ida/disc0/part5[0] ida/disc1/part5[1] # 10746624 blocks [2/2] [UU] # #md0 : active raid1 ida/disc1/part1[0] ida/disc0/part1[1] # 2003200 blocks [2/2] [UU] # #unused devices: <none> # Error: #Personalities : [raid1] #read_ahead 1024 sectors #md2 : active raid1 ida/disc0/part6[0] ida/disc1/part6[1](F) # 979072 blocks [2/1] [U_] # #md1 : active raid1 ida/disc0/part5[0] ida/disc1/part5[1] # 10746624 blocks [2/2] [UU] # #md0 : active raid1 ida/disc1/part1[0] ida/disc0/part1[1] # 2003200 blocks [2/2] [UU] # #unused devices: <none> # Repare: #Personalities : [raid1] #read_ahead 1024 sectors #md2 : active raid1 ida/disc1/part6[2] ida/disc0/part6[0] # 979072 blocks [2/1] [U_] # [====>................] recovery = 20.6% (203360/979072) finish=0.8min speed=14525K/sec #md1 : active raid1 ida/disc0/part5[0] ida/disc1/part5[1] # 10746624 blocks [2/2] [UU] # #md0 : active raid1 ida/disc1/part1[0] ida/disc0/part1[1] # 2003200 blocks [2/2] [UU] # #unused devices: <none> my @md; my @md_fail; my $flag_md=0; my $i=0; my $j=0; # Parsing infile while(<INFILE>) { if(/^md\d+ : .*/) { ++$i; $flag_md=1; $md_fail[$i]=( / active / )?0:1; $md[$i][0]=$_; $j=1; } elsif ($flag_md == 1) { $md[$i][$j]=$_; if(/\[[_U]*_[_U]*\]/) { $md_fail[$i]=1; } ++$j; } if (/^ *$/) { $flag_md=0; } } # Close the infile close INFILE; #print "Size md: $#md"; #print "Size md1: $#{$md[1]}"; my $disks_error=0; for ($i=1 ; $i<=$#md ; $i++) { if($md_fail[$i]!=0) { print @{$md[$i]}; $disks_error++ } } # Exit with Nagios Code exit $code{'Critical'} if ($disks_error >= $critical_level); exit $code{'Warning'} if ($disks_error >= $warning_level); exit $code{'Ok'}; =========================================================== Sent by ASSA --- ifmail v.2.15dev5.3 * Origin: Zabaykal Computer Networks (2:5020/400) Вернуться к списку тем, сортированных по: возрастание даты уменьшение даты тема автор
Архивное /ru.linux/154533f4bc69e.html, оценка из 5, голосов 10
|