From 0b6423f9c99d9edf8c96fefd0f6c453859395aa1 Mon Sep 17 00:00:00 2001 From: Holger Weiss Date: Mon, 30 Sep 2013 00:03:24 +0200 Subject: Import Nagios Plugins site Import the Nagios Plugins web site, Cronjobs, infrastructure scripts, and configuration files. --- web/attachments/137235-check_ipmi | 75 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 web/attachments/137235-check_ipmi (limited to 'web/attachments/137235-check_ipmi') diff --git a/web/attachments/137235-check_ipmi b/web/attachments/137235-check_ipmi new file mode 100644 index 0000000..1d2a5bd --- /dev/null +++ b/web/attachments/137235-check_ipmi @@ -0,0 +1,75 @@ +#!/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 , 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 = ) +{ + 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 } -- cgit v1.2.3-74-g34f1