summaryrefslogtreecommitdiffstats
path: root/web/attachments/137235-check_ipmi
diff options
context:
space:
mode:
Diffstat (limited to 'web/attachments/137235-check_ipmi')
-rw-r--r--web/attachments/137235-check_ipmi75
1 files changed, 75 insertions, 0 deletions
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 @@
1#!/usr/bin/perl
2
3# Nagios plugin for IPMI sensors status checking.
4#
5# Especially useful on Dell Poweredge servers, and others that
6# implement the Intelligent Platform Management Interface (IPMI)
7# interface.
8#
9# (C) Chris Wilson <check_ipmi@qwirx.com>, 2005-06-04
10# Released under the GNU General Public License (GPL)
11
12use warnings;
13use strict;
14
15open IPMI, "ipmitool sdr |" or die "ipmitool: $!";
16
17my %found;
18my %bad;
19
20sub trim ($) {
21 my ($v) = @_;
22 $v =~ s/^ +//;
23 $v =~ s/ +$//;
24 return $v;
25}
26
27while (my $line = <IPMI>)
28{
29 chomp $line;
30 unless ($line =~ m'^(.*) \| (.*) \| (\w+)$')
31 {
32 die "Bad format in ipmitool output: $line";
33 }
34
35 my $name = trim $1;
36 my $value = trim $2;
37 my $state = trim $3;
38 $name =~ tr| |_|;
39
40 my $counter = 1;
41 my $uname = "$name";
42 while ($found{$uname}) {
43 $uname = $name . $counter++;
44 }
45
46 next if $state eq "ns";
47
48 if ($state ne "ok") {
49 $bad{$uname} = $state;
50 }
51
52 $found{$uname} = $value;
53}
54
55if (keys %bad) {
56 print "IPMI critical: ";
57 my @bad;
58 foreach my $name (sort keys %bad) {
59 push @bad, "$name is $bad{$name}";
60 }
61 print join(", ", @bad) . " ";
62} else {
63 print "IPMI ok ";
64}
65
66my @out;
67
68foreach my $name (sort keys %found) {
69 next unless $name =~ m|Fan| or $name =~ m|Temp|;
70 push @out, "$name = $found{$name}";
71}
72
73print "(" . join(", ", @out) . ")\n";
74
75if (%bad) { exit 2 } else { exit 0 }