root / plugins / omreport / omreport_pwrmon_power @ e08a6448
Historique | Voir | Annoter | Télécharger (3,53 ko)
| 1 |
#!/usr/bin/perl |
|---|---|
| 2 |
# |
| 3 |
# Copyright (C) 2009 Andrew Chadwick, University of Oxford <andrew.chadwick@ceu.ox.ac.uk> |
| 4 |
# Based on work by Rackspace US, Inc. <http://www.rackspace.com>, (C) 2008. |
| 5 |
# |
| 6 |
# This program is free software; you can redistribute it and/or |
| 7 |
# modify it under the terms of the GNU General Public License |
| 8 |
# as published by the Free Software Foundation; version 2 dated June, |
| 9 |
# 1991. |
| 10 |
# |
| 11 |
# This program is distributed in the hope that it will be useful, |
| 12 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
# GNU General Public License for more details. |
| 15 |
# |
| 16 |
# You should have received a copy of the GNU General Public License |
| 17 |
# along with this program; if not, see http://www.gnu.org/licenses/gpl.txt |
| 18 |
# |
| 19 |
# |
| 20 |
# This plugin will graph the power consumption of a Dell PowerEdge Server |
| 21 |
# via the omreport tool. It has been tested on the following chassis: |
| 22 |
# |
| 23 |
# PowerEdge R905 |
| 24 |
# |
| 25 |
# To enable, create a link in your plugins directory to wherever you |
| 26 |
# installed this file, e.g.: |
| 27 |
# |
| 28 |
# cd /etc/munin/plugins |
| 29 |
# ln -s /usr/share/munin/plugins/omreport_pwrmon_power |
| 30 |
# |
| 31 |
# Configuration parameters for /etc/munin/plugin-conf.d/munin-node |
| 32 |
# |
| 33 |
# [omreport_*] |
| 34 |
# user - User that has permissions to run the omreport binary |
| 35 |
# env.omreport - Path to the omreport binary |
| 36 |
# |
| 37 |
# Parameters: |
| 38 |
# |
| 39 |
# config |
| 40 |
# autoconf |
| 41 |
# |
| 42 |
# Author: Andrew Chadwick <andrew.chadwick@ceu.ox.ac.uk> |
| 43 |
# Revision: 0.1 2008-01-28 |
| 44 |
# |
| 45 |
#%# family=auto |
| 46 |
#%# capabilities=autoconf |
| 47 |
|
| 48 |
|
| 49 |
use strict; |
| 50 |
my $omreport = $ENV{"omreport"} || "/usr/bin/omreport";
|
| 51 |
|
| 52 |
if ($ARGV[0] && $ARGV[0] eq "autoconf") {
|
| 53 |
if (-f $omreport) {
|
| 54 |
print "yes\n"; |
| 55 |
} |
| 56 |
else {
|
| 57 |
print "no ($omreport does not exist)\n"; |
| 58 |
exit(1); |
| 59 |
} |
| 60 |
} |
| 61 |
else {
|
| 62 |
my @cmd = ($omreport, qw{chassis pwrmonitoring});
|
| 63 |
my ($index, %val); |
| 64 |
my $pid = open(my $cmd_out, '-|', @cmd) or die "@cmd: $!\n"; |
| 65 |
defined $pid or die "fork() failed: $!\n"; |
| 66 |
my $amperage_idx = 0; |
| 67 |
while (<$cmd_out>) {
|
| 68 |
s/\s+/\040/g; |
| 69 |
s/\s+$//; |
| 70 |
s/^\s+//; |
| 71 |
|
| 72 |
/^Power\s+Consumption\b/ .. /^Amperage\b/ or next; |
| 73 |
|
| 74 |
my ($field, $value) = split(/\s+\:\s+/, $_); |
| 75 |
if ($field eq 'Index') {
|
| 76 |
$index = "power_${value}";
|
| 77 |
$val{$index} = {};
|
| 78 |
} |
| 79 |
elsif ($field eq 'Probe Name') {
|
| 80 |
$val{$index}{label} = $value;
|
| 81 |
} |
| 82 |
elsif ($field eq 'Reading') {
|
| 83 |
$value =~ s{\s+W$}{};
|
| 84 |
$value =~ s{\[N/A\]}{}g;
|
| 85 |
$val{$index}{value} = $value;
|
| 86 |
} |
| 87 |
elsif ($field eq 'Warning Threshold') {
|
| 88 |
$value =~ s{\s+W$}{};
|
| 89 |
$value =~ s{\[N/A\]}{}g;
|
| 90 |
$val{$index}{warning} = $value;
|
| 91 |
} |
| 92 |
elsif ($field eq 'Failure Threshold') {
|
| 93 |
$value =~ s{\s+W$}{};
|
| 94 |
$value =~ s{\[N/A\]}{}g;
|
| 95 |
$val{$index}{critical} = $value;
|
| 96 |
} |
| 97 |
} |
| 98 |
close $cmd_out; |
| 99 |
|
| 100 |
if ($ARGV[0] && $ARGV[0] eq "config") {
|
| 101 |
print "graph_title OpenManage - Power Monitoring - Power\n"; |
| 102 |
print "graph_args --base 1000 -l 0\n"; |
| 103 |
print "graph_vlabel Watts\n"; |
| 104 |
print "graph_category Sensors\n"; |
| 105 |
foreach my $j (sort keys %val) {
|
| 106 |
print "$j.label $val{$j}{label}\n";
|
| 107 |
if ($val{$j}{warning}) {
|
| 108 |
print "$j.warning $val{$j}{warning}\n";
|
| 109 |
} |
| 110 |
if ($val{$j}{critical}) {
|
| 111 |
print "$j.critical $val{$j}{critical}\n";
|
| 112 |
} |
| 113 |
} |
| 114 |
} |
| 115 |
else {
|
| 116 |
foreach my $j (sort keys %val) {
|
| 117 |
print "$j.value $val{$j}{value}\n";
|
| 118 |
} |
| 119 |
} |
| 120 |
} |
| 121 |
exit(0); |
