2007년 02월 07일
nagios plugin for IPMI sensor status checking
Nagios plugin for IPMI sensor status checking

필요하신 분들은 알아서 잘 가져다가 쓰시면 되겠습니다.

파일 이름 기본은 check_ipmi로 되어있군요.

OpenNMS에는 IPMI 플러그인 어떻게 못 붙이겠니? ㅠ.ㅠ

#!/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.
#
# (C) Chris Wilson <check_ipmi@qwirx.com>, 2005-06-04
# Released under the GNU General Public License (GPL)

use warnings;
use strict;

open IPMI, "ipmitool sdr |" or die "ipmitool: $!";

my %found;
my %bad;

sub trim ($) {
my ($v) = @_;
$v =~ s/^ +//;
$v =~ s/ +$//;
return $v;
}

while (my $line = <IPMI>)
{
chomp $line;
unless ($line =~ m'^(.*) \| (.*) \| (\w+)$')
{
die "Bad format in ipmitool output: $line";
}

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) {
print "IPMI critical: ";
my @bad;
foreach my $name (sort keys %bad) {
push @bad, "$name is $bad{$name}";
}
print join(", ", @bad) . " ";
} else {
print "IPMI ok ";
}

my @out;

foreach my $name (sort keys %found) {
next unless $name =~ m|Fan| or $name =~ m|Temp|;
push @out, "$name = $found{$name}";
}

print "(" . join(", ", @out) . ")\n";

if (%bad) { exit 2 } else { exit 0 }
by ydhoney | 2007/02/07 15:02 | IT&Linux | 트랙백 | 덧글(0)
트랙백 주소 : http://ydhoney.egloos.com/tb/2983965
☞ 내 이글루에 이 글과 관련된 글 쓰기 (트랙백 보내기) [도움말]

:         :

:

비공개 덧글



<< 이전 페이지 | 다음 페이지 >>