Добрый день. Я применяю вот такой (немножко допиленный) скрипт для nagios: #!/usr/bin/perl # Nagios plugin for IPMI sensors status checking. # Especially useful on Dell Poweredge servers, and others that # implement the Intelligent Platform Management Interface (IPMI) # interface. # Tested against the 1850, 1950, 2850, 2950, SC1420, PE830 BMCs # # (C) Chris Wilson , 2005-06-04 # Released under the GNU General Public License (GPL) # Re-written by Bill Moran # and Brian Seklecki # 06/20/06 # $Id: check_ipmi.pl 192 2007-04-11 19:51:33Z seklecki $ #/* # * Copyright (c) 2006-2007 Collaborative Fusion, Inc. All rights reserved. # * # * Developed by: Collaborative Fusion, Inc. # * http://www.collaborativefusion.com # * # * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL # * COLLABORATIVE FUSION, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, # * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; # * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, # * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR # * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # */ # #/* # * This code was written under funding by Collaborative Fusion, Inc.. # */ # Strategy: # Take a hostname (or IP) on the command line argv[1] # e.g. check_ipmi.pl 10.1.1.1 # Look for a file in directory that matches the name # i.e. ipmi_credentials_${1/hostname} # # Format of said file would be the username/password to use (syntax as passed # on the command line of ipmitool(1) ) : $ "-U username -P password" # NOTE: If not found, look for a generic "ipmi_credientials" file before failing #use warnings; use strict; use lib "/usr/lib/nagios/plugins/"; use utils qw(%ERRORS $TIMEOUT); # Watch your permissions here (because you know IPMI uses high encryption) my $pwfile_prefix = '/etc/check_ipmi/passwd.'; my $monfile_prefix = '/etc/check_ipmi/mon.'; my $ipmitool = '/usr/bin/ipmitool'; my $command; my %NAGIOS_API_ECODES = ( 'OK' => 0, 'WARNING' => 1, 'CRITICAL' => 2, 'UNKNOWN' => 3); # default my $USAGE="Usage Syntax: $0 [remoteHost]"; # define globally #$nagios_ecode=$NAGIOS_API_ECODES{UNKNOWN}; my $nagios_ecode="NONE"; my $nagios_prefdata=""; my $nagios_retdata=""; $NAGIOS_API_ECODES{$nagios_ecode} = -1; sub nagios_diode ($ $) { (my $new_ecode, my $prefdata) = @_; # This fucntion is a one-way transition for the return code # it allow the global error code to increment upward only # it also concatenates the performance data # The tricky part is that we want to default to sane "3" uknown # but instead we'll have to default to -1 (out of bounds, coach) #print "DEBUG: new error code: " . $new_ecode . "\n"; #print "DEBUG: new error code #: " . $NAGIOS_API_ECODES{$new_ecode} . "\n"; #print "DEBUG: previous error code: " . $nagios_ecode . "\n"; #print "DEBUG: previous error code #: " . $NAGIOS_API_ECODES{$nagios_ecode} . "\n"; if ( $NAGIOS_API_ECODES{$new_ecode} gt $NAGIOS_API_ECODES{$nagios_ecode} ) { #print "DEBUG: transitioning from: " . $nagios_ecode . " -> " . $new_ecode . "\n"; $nagios_ecode = $new_ecode; } #print "DEBUG: Appending pref data: " . $prefdata . "\n"; $nagios_prefdata = $nagios_prefdata . "|" . $prefdata; } sub cane_one() { print $nagios_retdata; print $nagios_prefdata; exit $NAGIOS_API_ECODES{$nagios_ecode}; } if ( scalar(@ARGV) < 1 || scalar(@ARGV) > 2 || $ARGV[0] !~ m/^[a-z0-9\.\-]+$/ ) { nagios_diode('UNKNOWN', $USAGE); cane_one; } else { my $passwdfile; my $username="ADMIN"; $passwdfile = "${pwfile_prefix}$ARGV[0]"; if (! -r $passwdfile) { $passwdfile = "${pwfile_prefix}default"; # set code to warning because using default passwd file nagios_diode('WARNING', "WARNING: No credentials found for $ARGV[0] - trying to use default!"); } $command = "$ipmitool -H $ARGV[0] -U $username -f $passwdfile sdr 2>&1 | grep -f $monfile_prefix$ARGV[0]"; # $command = "cat /badvals 2>&1 | grep -f $monfile_prefix$ARGV[0]"; } if (! open(IPMI, "$command |") ) { nagios_diode('UNKNOWN', "Unable to exec ipmitool(8)"); cane_one; } #print("DEBUG:".$command."\r\n"); my %found; my %bad; sub trim ($) { my ($v) = @_; $v =~ s/^ +//; $v =~ s/ +$//; return $v; } while (my $line = ) { chomp $line; unless ($line =~ m'^(.*) \| (.*) \| (\w+)$') { nagios_diode('CRITICAL', "Unrecognized response from ipmitool: $line"); cane_one; } my $name = trim $1; my $value = trim $2; my $state = trim $3; $name =~ tr| |_|; my $counter = 1; my $uname = "$name"; while ($found{$uname}) { $uname = $name . $counter++; } next if $state eq "ns"; if ($state ne "ok") { $bad{$uname} = $state; } $found{$uname} = $value; } if (keys %bad) { my @bad; foreach my $name (sort keys %bad) { push @bad, "$name is $bad{$name}"; } $nagios_retdata = "CRITICAL:" . "(" . join(", ", @bad) . ") "; nagios_diode('CRITICAL', "IPMI Critical Value: "); } else { $nagios_retdata = "OK."; nagios_diode('OK', "IPMI OK: "); } my @out; # Directly toch pref_data - assume that iit is safe to foreach my $name (sort keys %found) { next unless $name =~ m|Fan| or $name =~ m|Temp|; #print "DEBUG: $name = $found{$name}\n"; #$nagios_prefdata = $nagios_prefdata. "$name = $found{$name},"; push @out, "$name = $found{$name}"; } $nagios_prefdata = $nagios_prefdata . "(" . join(", ", @out) . ") "; cane_one;