mirror of
https://github.com/munin-monitoring/contrib.git
synced 2018-11-08 00:59:34 +01:00
ups: remove two older PDU plugins.
My plugin uses the same SNMP framework as the official plugins in munin; these use either sh and net-snmp commands, or Net::SNMP directly, and neither seems to be generic enough.
This commit is contained in:
parent
d9533d6190
commit
2fc9c2400b
@ -1,79 +0,0 @@
|
||||
#!/bin/sh
|
||||
# -*- sh -*-
|
||||
|
||||
: << =cut
|
||||
=head1 NAME
|
||||
|
||||
apc_pdu_load = plugin to show load in Ampere for an apc pdu
|
||||
|
||||
=head1 NOTES
|
||||
|
||||
This is a Munin plugin that shows the load in Ampere for an apc pdu
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Contributed by Alexander Swen
|
||||
|
||||
=head1 LICENSE
|
||||
|
||||
Copyright (c) 2011 Alexander Swen
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; version 2 dated June,
|
||||
1991.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
=head1 CONFIGURATION
|
||||
[apc_pdu_load]
|
||||
env.pdu <host or ip of your pdu>
|
||||
env.snmp_community public
|
||||
env.snmp_version 1
|
||||
env.load_oid .1.3.6.1.4.1.318.1.1.12.2.3.1.1.2.1
|
||||
|
||||
=head1 MAGIC MARKERS
|
||||
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
=cut
|
||||
|
||||
snmp_version=${snmp_version:-1}
|
||||
snmp_community=${snmp_community:-public}
|
||||
load_oid=${load_iod:-.1.3.6.1.4.1.318.1.1.12.2.3.1.1.2.1}
|
||||
|
||||
#. $MUNIN_LIBDIR/plugins/plugin.sh
|
||||
|
||||
if [ -z "${pdu}" ]; then
|
||||
echo "pdu variable not set"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
[ -n "$1" ] && case $1 in
|
||||
autoconf)
|
||||
echo yes
|
||||
exit 0
|
||||
;;
|
||||
config)
|
||||
cat << EOF
|
||||
graph_title PDU load ${pdu}
|
||||
graph_args -l 0
|
||||
graph_scale yes
|
||||
graph_vlabel Ampere
|
||||
graph_category ups
|
||||
load.label load
|
||||
EOF
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
|
||||
/usr/bin/snmpget -v ${snmp_version} -c ${snmp_community} ${pdu} ${load_oid}|awk '{sub (/.*: /, "load.value ");print $1" "$2/10}'
|
@ -1,128 +0,0 @@
|
||||
#!/usr/bin/perl
|
||||
#
|
||||
# Copyright (c) 2009 - Rune Nordbøe Skillingstad
|
||||
# Copyright (c) 2009 - Kai Ove Gran
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; version 2 dated June,
|
||||
# 1991.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
|
||||
# snmp_host_apcpdu - For APC PDUs. Graphs total current throughput.
|
||||
#
|
||||
#%# family=snmpauto
|
||||
#%# capabilities=snmpconf
|
||||
|
||||
use strict;
|
||||
use Net::SNMP;
|
||||
|
||||
my $DEBUG = $ENV{DEBUG} || 0;
|
||||
my $host = $ENV{host} || undef;
|
||||
my $port = $ENV{port} || 161;
|
||||
my $community = $ENV{community} || "public";
|
||||
my $iface = $ENV{interface} || undef;
|
||||
my $timeout = $ENV{timeout} || 1;
|
||||
my $snmp_ver = $ENV{version} || 1;
|
||||
|
||||
if($0 =~ /^(?:|.*\/)snmp_([^_]+)_apcpdu$/) {
|
||||
$host = $1;
|
||||
if($host =~ /^([^:]+):(\d+)$/) {
|
||||
$host = $1;
|
||||
$port = $2;
|
||||
}
|
||||
} elsif(!defined($host)) {
|
||||
die "# Error: couldn't understand what I'm supposed to monitor.";
|
||||
}
|
||||
|
||||
my @oidsList = (
|
||||
'1.3.6.1.4.1.318.1.1.12.2.3.1.1.2.1',
|
||||
'1.3.6.1.4.1.318.1.1.12.2.2.1.1.3.1',
|
||||
'1.3.6.1.4.1.318.1.1.12.1.7.0'
|
||||
);
|
||||
|
||||
if(defined $ARGV[0] and $ARGV[0] eq "snmpconf") {
|
||||
for(my $i = 0; $i < @oidsList; $i++) {
|
||||
print "require " . $oidsList[$i] . "[0-9]\n";
|
||||
}
|
||||
exit 0;
|
||||
}
|
||||
|
||||
my ($session, $error) = Net::SNMP->session(
|
||||
-hostname => $host,
|
||||
-community => $community,
|
||||
-port => $port,
|
||||
-timeout => $timeout,
|
||||
-version => $snmp_ver,
|
||||
);
|
||||
|
||||
if(!defined ($session)) {
|
||||
die "# Croaking: $error";
|
||||
}
|
||||
|
||||
if($ARGV[0] and $ARGV[0] eq "config") {
|
||||
my $modell = &get_single($session, '1.3.6.1.4.1.318.1.1.4.1.4.0');
|
||||
if($modell) {
|
||||
print "host_name $host\n" unless $host eq 'localhost';
|
||||
print "graph_title Current, $modell\n";
|
||||
print "graph_args --base 1000 -l 0\n";
|
||||
print "graph_vlabel Amps\n";
|
||||
print "graph_category Ups\n";
|
||||
print "graph_info This graph shows the total throughput of the PDU";
|
||||
print "graph_order load threshold rating\n";
|
||||
print "load.label Load\n";
|
||||
print "load.type GAUGE\n";
|
||||
print "load.info Current load in amps.\n";
|
||||
print "load.draw LINE2\n";
|
||||
print "threshold.label Threshold\n";
|
||||
print "threshold.type GAUGE\n";
|
||||
print "threshold.info Near overload threshold.\n";
|
||||
print "threshold.draw LINE2\n";
|
||||
print "rating.label Rating\n";
|
||||
print "rating.type GAUGE\n";
|
||||
print "rating.info Rating (Max amps).\n";
|
||||
print "rating.draw LINE2\n";
|
||||
}
|
||||
exit 0;
|
||||
}
|
||||
|
||||
my @response = &get_multiple($session, @oidsList);
|
||||
|
||||
printf "load.value %.02f\n", $response[0] / 10;
|
||||
printf "threshold.value %d\n", $response[1];
|
||||
printf "rating.value %d\n", $response[2];
|
||||
|
||||
|
||||
sub get_multiple {
|
||||
my $handle = shift;
|
||||
my @oids = @_;
|
||||
|
||||
my @result;
|
||||
foreach my $oid (@oids) {
|
||||
push(@result, &get_single($handle,$oid));
|
||||
}
|
||||
chomp @result;
|
||||
return @result;
|
||||
}
|
||||
|
||||
sub get_single {
|
||||
my ($handle, $oid) = @_;
|
||||
|
||||
my $response = $handle->get_request ($oid);
|
||||
if(!defined $response->{$oid}) {
|
||||
print "# No response\n" if $DEBUG;
|
||||
return "";
|
||||
} else {
|
||||
print "# Got response \"".$response->{$oid}."\"\n" if $DEBUG;
|
||||
return $response->{$oid};
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user