Build precise queries to find exactly what you need
Press ESC to close
I changed a code for receiving more information: Current out: “Ctrl 1: Volume 0 State: degraded, enabled, resync in progress” New version out: “Ctrl 1: Vol 0 (0:4), IM, 285558 MB, degraded, enabled, resync in progress; Ctrl 1: Vol 1 (0:0), IM, 953674 MB, optimal, enabled”
?hanged code of a plug-in: # Nagios plugin that checks LSI controllers RAID status via lsiutil program # lsiutil may be found at ftp://ftp.lsil.com/HostAdapterDrivers/linux/lsiutil/
# Copyright (C) 2011 Emmanuel Lacour # # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 2, or (at your option) any # later version. # # This file is distributed in the hope that it will be # useful, but WITHOUT ANY WARRANTY; without even the implied warranty # of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this file; see the file COPYING. If not, write to the Free # Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA # 02110-1301, USA.
use strict; use lib qw(/usr/local/lib/nagios/plugins /usr/lib/nagios/plugins); use utils qw(%ERRORS);
my $lsiutil = ‘/usr/sbin/lsiutil’; my $status = $ERRORS{‘OK’}; my $output; my @controllers;
my $vol_id; my $vol_bus; my $vol_target; my $vol_type; my $vol_state; my $vol_size; my @words;
unless ( -x $lsiutil ) { print “$lsiutil not found or not executablen”; exit ($ERRORS{‘UNKNOWN’}); }
unless ( $> == 0 ) { print “This program must be run as root. You may use wrappers like sudo to do this.n”; exit ($ERRORS{‘UNKNOWN’}); }
$output = `$lsiutil -p 0 -a 0`; for (split /^/, $output) { if ( m|^s*(d+)..*/proc/mpt/ioc| ) { push @controllers, $1; } }
unless ( scalar @controllers ) { print “No controller foundn”; exit ($ERRORS{‘UNKNOWN’}); }
foreach my $controller ( @controllers ) { my @vol_stats; $output = `$lsiutil -p $controller -a 21,1,0,0,0`;
for (split “nn”, $output) { if (index($_, ‘Volume ‘) == 0) {
# print “———————–“.”n”; # print $_.”n”; # print “———————–“.”n”;
my @lines = split /n/, $_; foreach my $line (@lines) { if (index($line, ‘Volume ‘) == 0) { @words = split ” “, $line; $vol_id = $words[1]; $vol_bus = $words[4]; $vol_target = (split “,”, $words[6])[0]; $vol_type = $words[8]; } else { @words = split ” “, $line; if ($words[0] eq “Volume”) { if ($words[1] eq “State:”) { $vol_state = (split “: “, $line)[1]; } if ($words[1] eq “Size”) { $vol_size = (split ” “, $line)[2].” “.(split ” “, $line)[3]; $vol_size = (split “,”, $vol_size)[0]; } } }
} if (@vol_stats > 0) { print “; “; } print “Ctrl $controller: “; print “Vol “.$vol_id.” (“.$vol_bus.”:”.$vol_target.”), “.$vol_type.”, “.$vol_size.”, “.$vol_state; push @vol_stats, $vol_state;
} }
# 0 – OK # 1 – Warning # 2 – CRITICAL my $tmp_stat = 0; foreach $vol_state (@vol_stats) { if ((index($vol_state, ‘degraded’) != -1) and ($tmp_stat
We’ve completely redesigned the world’s largest repository of Nagios plugins and monitoring tools. Join thousands of users sharing monitoring solutions for servers, applications, and everything in between.
Due to our redesign, all existing accounts require a password reset to access your account again.
Ready to explore 6,100+ projects and contribute to the community?
Reset Password Create Account
Happy Monitoring!