mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-25 02:18:08 +00:00
- have some dirs
This commit is contained in:
parent
0b089ea777
commit
08346aac58
687 changed files with 0 additions and 0 deletions
316
plugins/ups/apc__snmp_
Executable file
316
plugins/ups/apc__snmp_
Executable file
|
@ -0,0 +1,316 @@
|
|||
#!/usr/bin/perl
|
||||
#
|
||||
# Copyright (C) 2008 Gorlow Maxim [Sheridan]
|
||||
# Copyright (C) 2009 Andrey Yakovlev [Freedom]
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
# apc_host_snmp_volt - IO voltage (volt)
|
||||
# apc_host_snmp_freq - IO frequency (hz)
|
||||
# apc_host_snmp_status - UPS status (online, off....)
|
||||
# apc_host_snmp_temp - Temperature (c)
|
||||
# apc_host_snmp_load - UPS and Battery load (%)
|
||||
# apc_host_snmp_curr - Current (ampers)
|
||||
|
||||
|
||||
|
||||
|
||||
#
|
||||
#%# family=snmpauto
|
||||
#
|
||||
|
||||
use strict;
|
||||
no strict 'refs';
|
||||
|
||||
my $host = $ENV{host} || undef;
|
||||
my $community = $ENV{community} || "public";
|
||||
my $type = "volt";
|
||||
my $response;
|
||||
|
||||
if ($0 =~ /^(?:|.*\/)apc_([^_]*)_snmp_(.+)$/)
|
||||
{
|
||||
$host = $1 until ($1 eq "");
|
||||
$type = $2;
|
||||
if ($host =~ /^([^:]+):(\d+)$/)
|
||||
{
|
||||
$host = $1;
|
||||
7 #$port = $2;
|
||||
}
|
||||
}
|
||||
elsif (!defined($host)) {
|
||||
die "# Error: couldn't understand what I'm supposed to monitor."; }
|
||||
|
||||
my @snmpParam = ($community,$host);
|
||||
my @oidsList;
|
||||
my @modelList = ('1.3.6.1.4.1.318.1.1.1.1.1.1.0','1.3.6.1.4.1.318.1.1.1.1.2.3.0','1.3.6.1.4.1.318.1.1.1.2.2.3.0');
|
||||
|
||||
if ($type eq "volt")
|
||||
{
|
||||
@oidsList = ('1.3.6.1.4.1.318.1.1.1.4.2.1.0',
|
||||
'1.3.6.1.4.1.318.1.1.1.3.2.1.0',
|
||||
'1.3.6.1.4.1.318.1.1.1.3.2.2.0',
|
||||
'1.3.6.1.4.1.318.1.1.1.3.2.3.0');
|
||||
}
|
||||
elsif ($type eq "freq")
|
||||
{
|
||||
@oidsList = ['upsAdvOutputFrequency'],
|
||||
['upsAdvInputFrequency'];
|
||||
}
|
||||
elsif ($type eq "status")
|
||||
{
|
||||
@oidsList = ('1.3.6.1.4.1.318.1.1.1.4.1.1.0 ');
|
||||
}
|
||||
elsif ($type eq "temp")
|
||||
{
|
||||
@oidsList = ('1.3.6.1.4.1.318.1.1.1.2.2.2.0',
|
||||
'1.3.6.1.4.1.318.1.1.10.2.3.2.1.4.1');
|
||||
}
|
||||
elsif ($type eq "load")
|
||||
{
|
||||
@oidsList = ('1.3.6.1.4.1.318.1.1.1.4.2.3.0',
|
||||
'1.3.6.1.4.1.318.1.1.1.2.2.1.0');
|
||||
}
|
||||
elsif ($type eq "curr")
|
||||
{
|
||||
@oidsList = ('upsAdvOutputCurrent');
|
||||
}
|
||||
#if (defined $ARGV[0] and $ARGV[0] eq "snmpconf")
|
||||
#{}
|
||||
|
||||
if ($ARGV[0] and $ARGV[0] eq "config")
|
||||
{
|
||||
|
||||
my $model;
|
||||
my $vLabel;
|
||||
my $hLabel;
|
||||
my $graph_args;
|
||||
|
||||
if ($type eq "volt")
|
||||
{
|
||||
$vLabel = "Voltage";
|
||||
$hLabel = "IO Voltage";
|
||||
print "graph_order out in inmax inmin\n";
|
||||
print "in.label Input\n";
|
||||
print "in.type GAUGE\n";
|
||||
print "in.info Input voltage.\n";
|
||||
print "in.colour FFCC99\n";
|
||||
print "in.draw AREA\n";
|
||||
print "out.label Output\n";
|
||||
print "out.type GAUGE\n";
|
||||
print "out.info Output voltage.\n";
|
||||
print "out.colour 009BCC\n";
|
||||
print "out.draw AREA\n";
|
||||
print "inmax.label Input max\n";
|
||||
print "inmax.type GAUGE\n";
|
||||
print "inmax.info Input voltage maximum.\n";
|
||||
print "inmax.colour FF0033\n";
|
||||
print "inmax.draw LINE1\n";
|
||||
print "inmin.label Input min\n";
|
||||
print "inmin.type GAUGE\n";
|
||||
print "inmin.info Input voltage minimum.\n";
|
||||
print "inmin.colour 66FF00\n";
|
||||
print "inmin.draw LINE1\n";
|
||||
|
||||
}
|
||||
elsif ($type eq "freq")
|
||||
{
|
||||
$vLabel = "Frequency";
|
||||
$hLabel = "IO Frequency";
|
||||
print "graph_order in out\n";
|
||||
print "out.label Output\n";
|
||||
print "out.type GAUGE\n";
|
||||
print "out.info Output frequency.\n";
|
||||
print "out.draw LINE2\n";
|
||||
print "in.label Input\n";
|
||||
print "in.type GAUGE\n";
|
||||
print "in.info Input frequency.\n";
|
||||
print "in.draw LINE2\n";
|
||||
}
|
||||
elsif ($type eq "status")
|
||||
{
|
||||
$vLabel = "Status";
|
||||
$hLabel = "Status";
|
||||
print "state.label Status\n";
|
||||
print "state.type GAUGE\n";
|
||||
print "state.draw AREA\n";
|
||||
print "state.min 1\n";
|
||||
print "state.max 12\n";
|
||||
print "unknown.label Unknown\n";
|
||||
print "unknown.type GAUGE\n";
|
||||
print "unknown.draw LINE3\n";
|
||||
print "onLine.label Online\n";
|
||||
print "onLine.type GAUGE\n";
|
||||
print "onLine.draw LINE4\n";
|
||||
print "onLine.min 0\n";
|
||||
print "onLine.max 1\n";
|
||||
print "onLine.warning 1:\n";
|
||||
print "onBattery.label On Battery\n";
|
||||
print "onBattery.type GAUGE\n";
|
||||
print "onBattery.draw LINE4\n";
|
||||
print "onBattery.min 0\n";
|
||||
print "onBattery.max 1\n";
|
||||
print "softwareBypass.label Software Bypass\n";
|
||||
print "softwareBypass.type GAUGE\n";
|
||||
print "softwareBypass.draw LINE3\n";
|
||||
print "off.label Off\n";
|
||||
print "off.type GAUGE\n";
|
||||
print "off.draw LINE3\n";
|
||||
print "rebooting.label Rebooting\n";
|
||||
print "rebooting.type GAUGE\n";
|
||||
print "rebooting.draw LINE3\n";
|
||||
print "switchedBypass.label Switched Bypass\n";
|
||||
print "switchedBypass.type GAUGE\n";
|
||||
print "switchedBypass.draw LINE3\n";
|
||||
print "hardwareFailureBypass.label HW Failure Bypass\n";
|
||||
print "hardwareFailureBypass.type GAUGE\n";
|
||||
print "hardwareFailureBypass.draw LINE3\n";
|
||||
}
|
||||
elsif ($type eq "temp")
|
||||
{
|
||||
$vLabel = "Temperature, C";
|
||||
$hLabel = "Temperature";
|
||||
$graph_args = "--upper-limit 35 -l 15";
|
||||
print "graph_order batt sens1\n";
|
||||
print "batt.label Battery temperature\n";
|
||||
print "batt.type GAUGE\n";
|
||||
print "batt.info Battery temperature.\n";
|
||||
print "batt.draw LINE2\n";
|
||||
print "batt.warning 15:30\n";
|
||||
print "sens1.label Sensor temperature\n";
|
||||
print "sens1.type GAUGE\n";
|
||||
print "sens1.info Sensor temperature.\n";
|
||||
print "sens1.draw LINE2\n";
|
||||
print "sens1.warning 15:30\n";
|
||||
print "sens1.critical 10:40\n";
|
||||
}
|
||||
elsif ($type eq "load")
|
||||
{
|
||||
$vLabel = "Percent";
|
||||
$hLabel = "UPS load and Batt. capacity ";
|
||||
$graph_args = "--upper-limit 110 -l 0"; # --rigid
|
||||
print "graph_order load bcap\n";
|
||||
print "load.label UPS load\n";
|
||||
print "load.type GAUGE\n";
|
||||
print "load.info UPS load.\n";
|
||||
print "load.draw AREA\n";
|
||||
print "load.warning 85\n";
|
||||
print "load.critical 95\n";
|
||||
print "bcap.label Battery capacity\n";
|
||||
print "bcap.type GAUGE\n";
|
||||
print "bcap.info Battery capacity.\n";
|
||||
print "bcap.draw LINE2\n";
|
||||
print "bcap.warning 20:\n";
|
||||
print "bcap.critical 10:\n";
|
||||
}
|
||||
elsif ($type eq "curr")
|
||||
{
|
||||
$vLabel = "Ampers";
|
||||
$hLabel = "Current";
|
||||
print "out.label Output\n";
|
||||
print "out.type GAUGE\n";
|
||||
print "out.info Output current\n";
|
||||
print "out.draw LINE2\n";
|
||||
}
|
||||
|
||||
## common part
|
||||
print "host_name $host\n" unless $host eq 'localhost';
|
||||
my @response = getSnmpValueArr (\@snmpParam,\@modelList);
|
||||
$response[0] =~ s/[\" ]//g; # Ditch the quotes.
|
||||
$response[1] =~ s/[\" ]//g;
|
||||
my $rest = $response[2] /6000;
|
||||
$model = "$response[0] [$response[1]] ";
|
||||
print "graph_title $hLabel, $response[0]\n";
|
||||
print "graph_args --base 1000 $graph_args\n";
|
||||
print "graph_vlabel $vLabel\n";
|
||||
print "graph_category Ups\n";
|
||||
print "graph_info This graph shows the $hLabel ($vLabel) of $model <br> Onbattery remaining runtime <b>$rest</b> minutes.\n";
|
||||
|
||||
#all ok
|
||||
exit 0;
|
||||
}
|
||||
|
||||
# Get results
|
||||
my @response = getSnmpValueArr (\@snmpParam,\@oidsList);
|
||||
|
||||
if ($type eq "volt")
|
||||
{
|
||||
print "out.value $response[0]\n";
|
||||
print "in.value $response[1]\n";
|
||||
print "inmax.value $response[2]\n";
|
||||
print "inmin.value $response[3]\n";
|
||||
}
|
||||
elsif ($type eq "freq")
|
||||
{
|
||||
print "out.value $response[0]\n";
|
||||
print "in.value $response[1]\n";
|
||||
}
|
||||
elsif ($type eq "status")
|
||||
{
|
||||
my $unknown = $response[0]==1 || 0;
|
||||
my $onLine = $response[0]==2 || 0;
|
||||
my $onBattery = $response[0]==3 || 0;
|
||||
my $softwareBypass = $response[0]==6 || 0;
|
||||
my $off = $response[0]==7 || 0;
|
||||
my $rebooting = $response[0]==8 || 0;
|
||||
my $switchedBypass = $response[0]==9 || 0;
|
||||
my $hardwareFailureBypass = $response[0]==10 || 0;
|
||||
|
||||
print "state.value $response[0]\n";
|
||||
print "unknown.value $unknown\n";
|
||||
print "onLine.value $onLine\n";
|
||||
print "onBattery.value $onBattery\n";
|
||||
print "softwareBypass.value $softwareBypass\n";
|
||||
print "off.value $off\n";
|
||||
print "rebooting.value $rebooting\n";
|
||||
print "switchedBypass.value $switchedBypass\n";
|
||||
print "hardwareFailureBypass.value $hardwareFailureBypass\n";
|
||||
}
|
||||
elsif ($type eq "temp")
|
||||
{
|
||||
print "batt.value $response[0]\n";
|
||||
print "sens1.value $response[1]\n";
|
||||
}
|
||||
elsif ($type eq "load")
|
||||
{
|
||||
print "load.value $response[0]\n";
|
||||
print "bcap.value $response[1]\n";
|
||||
}
|
||||
elsif ($type eq "curr")
|
||||
{
|
||||
print "out.value $response[0]\n";
|
||||
}
|
||||
|
||||
sub getSnmpValueArr
|
||||
{
|
||||
my ($param, $oidlist ) = @_;
|
||||
my @result;
|
||||
|
||||
foreach my $oid (@$oidlist) {
|
||||
push ( @result, getSnmpValue($param,$oid) );
|
||||
}
|
||||
chomp @result;
|
||||
return @result;
|
||||
}
|
||||
|
||||
#
|
||||
# (\(community,IP),OID)
|
||||
sub getSnmpValue
|
||||
{
|
||||
my ($param, $oid) = @_;
|
||||
my ($comm, $ip) = @$param;
|
||||
return `/usr/local/bin/bsnmpget -n -o quiet -s ${comm}\@${ip} -v 1 $oid`;
|
||||
}
|
||||
__END__
|
79
plugins/ups/apc_pdu_load
Executable file
79
plugins/ups/apc_pdu_load
Executable file
|
@ -0,0 +1,79 @@
|
|||
#!/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}'
|
259
plugins/ups/apcupsd_pct
Executable file
259
plugins/ups/apcupsd_pct
Executable file
|
@ -0,0 +1,259 @@
|
|||
#!/usr/bin/env perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Carp;
|
||||
use Pod::Usage;
|
||||
|
||||
our $APCACCESS = $ENV{apcaccess} || "/sbin/apcaccess";
|
||||
our $UPS_MODEL = $ENV{ups_model} || "ES 725";
|
||||
our $VERSION = 1.0;
|
||||
my %Graph;
|
||||
my %Metric;
|
||||
|
||||
MAIN: {
|
||||
decide_monitor_type();
|
||||
|
||||
my $mode = $ARGV[0] || "fetch";
|
||||
$mode =~ /^-/ && pod2usage();
|
||||
|
||||
### $mode
|
||||
eval "do_${mode}();"
|
||||
or croak "do_${mode}: $@";
|
||||
|
||||
### end
|
||||
exit 0;
|
||||
}
|
||||
|
||||
=begin comment
|
||||
|
||||
pct
|
||||
LOADPCT is the percentage of load capacity as estimated by the UPS.
|
||||
15.0 Percent Load Capacity
|
||||
BCHARGE is the percentage charge on the batteries.
|
||||
100.0 Percent
|
||||
|
||||
volt
|
||||
LINEV is the current line voltage as returned by the UPS.
|
||||
102.0 Volts
|
||||
BATTV is the battery voltage as supplied by the UPS.
|
||||
13.5 Volts
|
||||
|
||||
time
|
||||
TIMELEFT is the remaining runtime left on batteries as estimated by the UPS.
|
||||
38.4 Minutes
|
||||
|
||||
pwr
|
||||
LOADPCT is the percentage of load capacity as estimated by the UPS.
|
||||
15.0 Percent Load Capacity
|
||||
NOMPOWER
|
||||
330 Watts
|
||||
LOADMETRIC=LOADPCT/100*NOMPOWER gives realtime power consumption in WATTS
|
||||
|
||||
=end comment
|
||||
|
||||
=cut
|
||||
|
||||
sub decide_monitor_type {
|
||||
my $type = $0 =~ /_pct/ ? "pct" :
|
||||
$0 =~ /_volt/ ? "volt" :
|
||||
$0 =~ /_time/ ? "time" :
|
||||
$0 =~ /_pwr/ ? "pwr" : undef
|
||||
or croak "unknown monitor type: $0";
|
||||
|
||||
# common
|
||||
%Graph = (
|
||||
graph_title => "APC Status".($UPS_MODEL?" ($UPS_MODEL)":"")." - ",
|
||||
graph_category => "ups",
|
||||
graph_info => "This graph shows information about your APC UPS",
|
||||
graph_args => "--base 1000 --lower-limit 0",
|
||||
);
|
||||
|
||||
if ($type eq "pct") {
|
||||
$Graph{graph_title} .= "Percentage";
|
||||
$Graph{graph_vlabel} = "%";
|
||||
%Metric =(
|
||||
LOADPCT => {
|
||||
label => "load capacity pct",
|
||||
},
|
||||
BCHARGE => {
|
||||
label => "charge on the batteries pct",
|
||||
},
|
||||
);
|
||||
} elsif ($type eq "volt") {
|
||||
$Graph{graph_title} .= "Voltage";
|
||||
$Graph{graph_vlabel} = "Volts";
|
||||
%Metric =(
|
||||
LINEV => {
|
||||
label => "line voltage as returned by the UPS",
|
||||
},
|
||||
BATTV => {
|
||||
label => "battery voltage as supplied by the UPS",
|
||||
},
|
||||
);
|
||||
} elsif ($type eq "time") {
|
||||
$Graph{graph_title} .= "Time";
|
||||
$Graph{graph_vlabel} = "minutes";
|
||||
%Metric =(
|
||||
TIMELEFT => {
|
||||
label => "remaining runtime left on batteries",
|
||||
},
|
||||
);
|
||||
} elsif ($type eq "pwr") {
|
||||
$Graph{graph_title} .= "Power";
|
||||
$Graph{graph_vlabel} = "watts";
|
||||
%Metric =(
|
||||
LOADMETRIC => {
|
||||
label => "absolute power consumption",
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
sub do_fetch {
|
||||
### do_fetch
|
||||
|
||||
my @status_data = retrieve_apcupsd_status()
|
||||
or croak "failed: retrieve_apcupsd_status";
|
||||
### status_data: \@status_data
|
||||
|
||||
my $status = parse_status_data(@status_data);
|
||||
### status: $status
|
||||
my $prod_status = proccess_status($status);
|
||||
|
||||
my $FIELD;
|
||||
while (my($field,$attr) = each %Metric) {
|
||||
$field = lc $field;
|
||||
$FIELD = uc $field;
|
||||
printf "%s.value %.1f\n", $field, (exists $status->{$FIELD} ? ($status->{$FIELD} =~ /([\d]+\.?[\d]*)/) : ( exists $prod_status->{$FIELD} ? ( $prod_status->{$FIELD} =~ /([\d]+\.?[\d]*)/) : 0 ) );
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
sub do_config {
|
||||
### do_config
|
||||
|
||||
while (my($k,$v) = each %Graph) {
|
||||
printf "%s %s\n", $k, $v;
|
||||
}
|
||||
while (my($field,$attr) = each %Metric) {
|
||||
$field = lc $field;
|
||||
while (my($k,$v) = each %$attr) {
|
||||
printf "%s.%s %s\n", $field, $k, $v;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
sub do_autoconf {
|
||||
### do_config
|
||||
print "yes\n";
|
||||
}
|
||||
|
||||
sub retrieve_apcupsd_status {
|
||||
open my $apc, '-|', $APCACCESS
|
||||
or croak $!;
|
||||
my @status_data = <$apc>;
|
||||
close $apc;
|
||||
chomp @status_data;
|
||||
return @status_data;
|
||||
}
|
||||
|
||||
sub proccess_status {
|
||||
my $prod = {};
|
||||
my($status) = @_;
|
||||
|
||||
if (exists $status->{NOMPOWER} && exists $status->{LOADPCT}) {
|
||||
my $pwr_pct = sprintf "%.1f", ($status->{LOADPCT} =~ /([\d]+\.?[\d]*)/) ;
|
||||
my $nom_pwr = sprintf "%.1f", ($status->{NOMPOWER} =~ /([\d]+\.?[\d]*)/) ;
|
||||
$prod->{LOADMETRIC} = $pwr_pct/100 * $nom_pwr ;
|
||||
}
|
||||
|
||||
return $prod;
|
||||
}
|
||||
|
||||
sub parse_status_data {
|
||||
my $status = {};
|
||||
my($k,$v);
|
||||
for (@_) {
|
||||
($k,$v) = split /\s*:\s*/, $_, 2;
|
||||
$status->{$k} = $v;
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
B<apcupsd_pct>, B<apcupsd_volt>, B<apcupsd_time>, B<apcupsd_pwr>- munin plugin for APC UPS
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
B<apcupsd_pct> [ I<config>|I<fetch> ]
|
||||
|
||||
B<apcupsd_volt> [ I<config>|I<fetch> ]
|
||||
|
||||
B<apcupsd_time> [ I<config>|I<fetch> ]
|
||||
|
||||
B<apcupsd_pwr> [ I<config>|I<fetch> ]
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
munin plugin to monitor APC UPS via apcupsd by apcaccess.
|
||||
|
||||
=head1 INSTALLATION
|
||||
|
||||
cp apcupsd_pct $MUNIN_LIBDIR/plugsin/
|
||||
|
||||
cd YOUR_MUNIN_PLUGINS_DIR
|
||||
(make symbolic links different name)
|
||||
ln -s $MUNIN_LIBDIR/plugsin/apcupsd_pct apcupsd_pct
|
||||
ln -s $MUNIN_LIBDIR/plugsin/apcupsd_pct apcupsd_volt
|
||||
ln -s $MUNIN_LIBDIR/plugsin/apcupsd_pct apcupsd_time
|
||||
ln -s $MUNIN_LIBDIR/plugsin/apcupsd_pwr apcupsd_pwr
|
||||
|
||||
restart munin-node
|
||||
|
||||
=head1 REPOSITORY
|
||||
|
||||
L<http://github.com/hirose31/munin-apcupsd>
|
||||
|
||||
git clone git://github.com/hirose31/munin-apcupsd.git
|
||||
|
||||
patches and collaborators are welcome.
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
L<http://exchange.munin-monitoring.org/plugins/apcupsd_pct/details>
|
||||
|
||||
L<http://munin.projects.linpro.no/wiki/HowToWritePlugins>,
|
||||
L<http://munin.projects.linpro.no/wiki/protocol-config>
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
HIROSE, Masaaki E<lt>hirose31 _at_ gmail.comE<gt>
|
||||
|
||||
=head1 CHANGELOG
|
||||
|
||||
* 10/11/2010 - basos - added support for absolute power display
|
||||
|
||||
=head1 COPYRIGHT & LICENSE
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the same terms as Perl itself.
|
||||
|
||||
=cut
|
||||
|
||||
# for Emacsen
|
||||
# Local Variables:
|
||||
# mode: cperl
|
||||
# cperl-indent-level: 4
|
||||
# indent-tabs-mode: nil
|
||||
# coding: utf-8
|
||||
# End:
|
||||
|
||||
# vi: set ts=4 sw=4 sts=0 :
|
343
plugins/ups/apcupsd_ww
Executable file
343
plugins/ups/apcupsd_ww
Executable file
|
@ -0,0 +1,343 @@
|
|||
#!/usr/bin/perl -w
|
||||
#
|
||||
# Plugin to monitor apcupsd via apcaccess
|
||||
#
|
||||
# Version 1.3
|
||||
#
|
||||
# Copyright (C) 2005-2008 Behan Webster <behanw AT websterwood DOT com>
|
||||
# Licenced under GPL 2.0
|
||||
#
|
||||
# Written by: Behan Webster <behanw AT websterwood DOT com>
|
||||
# German translation by: Bianco Veigel <bianco.veigel AT zivillian DOT de>
|
||||
#
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use vars qw(%attrs %data %num);
|
||||
|
||||
my $apcaccess='/sbin/apcaccess';
|
||||
#$apcaccess='/home/behanw/bin/apcaccess';
|
||||
my $config='/etc/munin/plugin-conf.d/apcupsd_ww';
|
||||
|
||||
my $language = $ENV{LANG} || 'en';
|
||||
|
||||
# Example apcaccess output
|
||||
# KEY : VALUE
|
||||
#
|
||||
# UPSNAME : Elfhild
|
||||
# MODEL : SMART-UPS 1400 RM XL
|
||||
# STATUS : ONLINE
|
||||
# LINEV : 123.5 Volts
|
||||
# LOADPCT : 24.9 Percent Load Capacity
|
||||
# BCHARGE : 100.0 Percent
|
||||
# TIMELEFT : 63.0 Minutes
|
||||
# OUTPUTV : 123.5 Volts
|
||||
# ITEMP : 39.1 C Internal
|
||||
# BATTV : 54.5 Volts
|
||||
# NOMOUTV : 115 Volts
|
||||
# NOMBATTV : 48.0 Volts
|
||||
|
||||
# Possible values to graph in munin
|
||||
# Only the ones which are available will be graphed
|
||||
%attrs = (
|
||||
# APCACCESS_KEY => {
|
||||
# name => 'attribute_name',
|
||||
# label => {
|
||||
# en => 'English title',
|
||||
# de => 'Titel in Deutsch',
|
||||
# fr => 'titre en Francais',
|
||||
# },
|
||||
# type => 'name_of_functio_for_type', # Default is 'num'
|
||||
# # Can use one value, or list of values. If the first value can't be used, try the next.
|
||||
# # KEY Key from apcaccess
|
||||
# # num,num,num Specify a list of possible nominal values to guess from
|
||||
# # num Specify fixed nominal value
|
||||
# nominal => [ 'KEY', '100' ],
|
||||
# # KEY Key from apcaccess
|
||||
# # +-num% Calculate percentage min:max from nominal value
|
||||
# # +-num Calculate min:max from nominal value
|
||||
# # -num:+num Calculate min:max from nominal value
|
||||
# # num:num Specify fixed min:max values
|
||||
# # num or :num Specify fixed max value
|
||||
# # num: Specify fixed min value
|
||||
# warning => [ 'KEY:KEY', '+-10%', '-10:+15' ],
|
||||
# critical => [ 'KEY:KEY', '+-10%', '-10:+15' ],
|
||||
# },
|
||||
BCHARGE => { # BCHARGE : 100.0 Percent
|
||||
name => 'battery',
|
||||
label => {
|
||||
en => 'Percent battery charge',
|
||||
de => 'Batterieladung in Prozent',
|
||||
},
|
||||
warning => '33:', # %
|
||||
critical => '5:', # %
|
||||
},
|
||||
LOADPCT => { # LOADPCT : 28.6 Percent Load Capacity
|
||||
name => 'upsload',
|
||||
label => {
|
||||
en => 'Percent load capacity',
|
||||
de => 'Auslastung in Prozent',
|
||||
},
|
||||
warning => '75', # %
|
||||
critical => '90', # %
|
||||
},
|
||||
TIMELEFT => { # TIMELEFT : 17.0 Minutes
|
||||
name => 'timeleft',
|
||||
label => {
|
||||
en => 'Minutes of run time',
|
||||
de => 'Akkulaufzeit in Minuten',
|
||||
},
|
||||
warning => '5:', # mins
|
||||
critical => [ 'DLOWBATT:', '2:' ], # DLOWBATT : 02 Minutes
|
||||
},
|
||||
LINEV => { # LINEV : 121.5 Volts
|
||||
name => 'linevolts',
|
||||
label => {
|
||||
en => 'Line voltage',
|
||||
de => 'Eingangsspannung',
|
||||
},
|
||||
nominal => [ 'NOMINV', 'NOMOUTV', '115,230' ], # NA=115V, Europe=230V
|
||||
warning => [ '+-10%', '108:128' ],
|
||||
critical => [ 'LOTRANS:HITRANS', '+-15%', '104:132' ],
|
||||
},
|
||||
BATTV => { # BATTV : 27.7 Volts
|
||||
name => 'batteryvolts',
|
||||
label => {
|
||||
en => 'Battery voltage',
|
||||
de => 'Batteriespannung',
|
||||
},
|
||||
nominal => [ 'NOMBATTV', '12,24,48' ], # NOMBATTV : 48.0 Volts
|
||||
warning => '-5%:+15%',
|
||||
critical => '-10%:+25%',
|
||||
},
|
||||
OUTPUTV => { # OUTPUTV : 122.2 Volts
|
||||
name => 'outputvolts',
|
||||
label => {
|
||||
en => 'Output voltage',
|
||||
de => 'Ausgangsspannung',
|
||||
},
|
||||
nominal => [ 'NOMOUTV', '115,230' ], # NOMOUTV : 115 Volts
|
||||
warning => [ '+-10%', '108:128' ],
|
||||
critical => [ 'LOTRANS:HITRANS', '+-15%', '104:132' ],
|
||||
},
|
||||
ITEMP => { # ITEMP : 44.1 C Internal
|
||||
name => 'temperature',
|
||||
label => {
|
||||
en => 'UPS temperature',
|
||||
de => 'USV Temperatur',
|
||||
},
|
||||
warning => 50, # C
|
||||
critical => 60, # C
|
||||
},
|
||||
LINEFAIL => { # LINEFAIL : OK
|
||||
name => 'linefail',
|
||||
label => {
|
||||
en => 'Line voltage status',
|
||||
de => 'Status Eingangsspannung',
|
||||
},
|
||||
type => 'bool',
|
||||
critical => '0:', # Failed
|
||||
},
|
||||
BATTSTAT => { # BATTSTAT : OK
|
||||
name => 'battstat',
|
||||
label => {
|
||||
en => 'Battery status',
|
||||
de => 'Batteriestatus',
|
||||
},
|
||||
type => 'bool',
|
||||
critical => '0:', # Failed
|
||||
},
|
||||
MAINS => { # MAINS : OK
|
||||
name => 'mains',
|
||||
label => {
|
||||
en => 'Mains status',
|
||||
de => 'Status Eingangsspannung',
|
||||
},
|
||||
type => 'bool',
|
||||
critical => '0:', # Failed
|
||||
},
|
||||
#STATUS => { # STATUS : ONLINE
|
||||
# name => 'status',
|
||||
# label => {
|
||||
# en => 'Status',
|
||||
# },
|
||||
# type => 'status',
|
||||
# critical => 0,
|
||||
#},
|
||||
);
|
||||
|
||||
# Read config file
|
||||
# Can be used to override settings in %attrs
|
||||
if (-f $config) {
|
||||
require $config;
|
||||
}
|
||||
|
||||
# Determine plugin capabilities
|
||||
if (defined $ARGV[0] && $ARGV[0] =~ /autoconf|detect/) {
|
||||
if (-x $apcaccess) {
|
||||
print "yes\n";
|
||||
exit 0;
|
||||
} else {
|
||||
print "no (apcaccess not found)\n";
|
||||
exit 1;
|
||||
}
|
||||
}
|
||||
|
||||
# Read info from apcupsd using apcaccess
|
||||
die "$apcaccess: not found\n" unless -x $apcaccess;
|
||||
open (APCACCESS, "$apcaccess 2>&1 |") || die "$apcaccess: $!\n";
|
||||
while (<APCACCESS>) {
|
||||
chomp;
|
||||
die "$apcaccess: $_\n" if /Error contacting apcupsd/;
|
||||
$data{$1} = $2 if /^(\S+?)\s*:\s+(.+?)$/;
|
||||
$num{$1} = $2 if /^(\S+?)\s*:\s+([\d.x]+)/;
|
||||
}
|
||||
close APCACCESS;
|
||||
|
||||
# Auto-configure plugin
|
||||
if (defined $ARGV[0] && $ARGV[0] eq 'config') {
|
||||
if (defined $data{UPSNAME}) {
|
||||
print "graph_title $data{UPSNAME} ($data{MODEL})\n";
|
||||
} else {
|
||||
print "graph_title $data{MODEL}\n";
|
||||
}
|
||||
#print "graph_vlabel Units\n";
|
||||
print "graph_category ups\n";
|
||||
print "graph_info This graph shows information about your APC uninterruptible power supply.\n";
|
||||
|
||||
foreach my $what (sort keys %attrs) {
|
||||
&label("$what");
|
||||
}
|
||||
|
||||
# Print current values
|
||||
} else {
|
||||
foreach my $what (sort keys %attrs) {
|
||||
next unless defined $data{$what};
|
||||
my $func = $attrs{$what}{type} || 'num';
|
||||
my $value = eval "\&$func('$what')";
|
||||
print "$attrs{$what}{name}.value $value\n";
|
||||
}
|
||||
}
|
||||
|
||||
exit 0;
|
||||
|
||||
##############################################################################
|
||||
# Print label/title for value
|
||||
sub label {
|
||||
my $what = shift;
|
||||
return unless defined $data{$what};
|
||||
|
||||
my $attr = $attrs{$what};
|
||||
|
||||
# Determine language to use for labels
|
||||
my $lang = $language;
|
||||
$lang =~ s/_.*$// unless defined $attr->{label}{$lang};
|
||||
# Failback to english if translation isn't available
|
||||
$lang = 'en' unless defined $attr->{label}{$lang};
|
||||
|
||||
print "$attr->{name}.label $attr->{label}{$lang}\n";
|
||||
&info($what, 'warning');
|
||||
&info($what, 'critical');
|
||||
}
|
||||
|
||||
##############################################################################
|
||||
# Makes a scalar or array into an array (used in &info)
|
||||
sub list {
|
||||
return (ref($_[0]) eq 'ARRAY') ? @{$_[0]} : @_;
|
||||
}
|
||||
|
||||
##############################################################################
|
||||
# Used to setup warning or critical levels for munin
|
||||
sub info {
|
||||
my $what = shift;
|
||||
my $level = shift; # 'warning' or 'critical'
|
||||
|
||||
my $attr = $attrs{$what};
|
||||
return unless defined $attr->{$level};
|
||||
|
||||
# Determine nominal value for info calculation
|
||||
my $nom = undef;
|
||||
if (defined $attr->{nominal}) {
|
||||
for my $n (&list($attr->{nominal})) {
|
||||
# Guess list: compare guesses to value of $num{$what}
|
||||
if ($n =~ /,/) {
|
||||
my $fitness = ~0;
|
||||
next unless $num{$what};
|
||||
foreach my $possibility (split /[,\s]+/, $n) {
|
||||
my $diff = abs($num{$what} - $possibility);
|
||||
($nom, $fitness) = ($possibility, $diff) if $fitness >= $diff;
|
||||
}
|
||||
|
||||
# Absolute nominal value
|
||||
} elsif ($n =~ /^[\d.]+$/) {
|
||||
$nom = $n;
|
||||
last;
|
||||
|
||||
# Lookup nominal value as an APCUPSD key
|
||||
} elsif (defined $num{$n}) {
|
||||
$nom = $num{$n};
|
||||
last;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Calculate info value for $level
|
||||
foreach my $value (&list($attr->{$level})) {
|
||||
$value =~ s/([^:]+)/&calc($1,$nom)/eg;
|
||||
if ($value =~ /^[\d.:]+$/) {
|
||||
print "$attr->{name}.$level $value\n";
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
##############################################################################
|
||||
# Change warning/critical ranges into numbers for munin
|
||||
sub calc {
|
||||
my $v = shift;
|
||||
my $nom = shift;
|
||||
|
||||
return $v if $v =~ /^[\d.]+$/;
|
||||
return $num{$v} if defined $num{$v};
|
||||
return '' unless defined $nom;
|
||||
if ($v =~ /^\+-([\d.]+)%$/) {
|
||||
return sprintf "%.0f:%.0f", (100 - $1) * $nom / 100, (100 + $1) * $nom / 100;
|
||||
} elsif ($v =~ /^([-+][\d.]+)%$/) {
|
||||
return sprintf "%.0f", (100 + $1) * $nom / 100;
|
||||
} elsif ($v =~ /^\+-([\d.]+)$/) {
|
||||
return sprintf "%d:%d", $nom - $1, $nom + $1;
|
||||
} elsif ($v =~ /^([-+][\d.]+)$/) {
|
||||
return $nom + $1;
|
||||
} elsif ($v =~ /^\*([\d.]+)$/) {
|
||||
return $nom * $1;
|
||||
} elsif ($v =~ /^\/([\d.]+)$/) {
|
||||
return sprintf "%.0f", $nom / $1;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
##############################################################################
|
||||
# Default "type" routine to display values
|
||||
sub num {
|
||||
my $what = shift;
|
||||
return $num{$what};
|
||||
}
|
||||
|
||||
##############################################################################
|
||||
# "type" routine to change Ok/Not Ok into 1/0
|
||||
sub bool {
|
||||
my $what = shift;
|
||||
return $num{$what} eq "OK" ? "1" : "0";
|
||||
}
|
||||
|
||||
#sub status {
|
||||
# my $what = shift;
|
||||
# return unless defined $data{$what};
|
||||
# print "$attrs{$what}{name}.value ";
|
||||
# print $num{$what} eq "ONLINE" ? "1" : "0";
|
||||
# print "\n";
|
||||
#}
|
||||
|
||||
# vim: sw=4 ts=4
|
128
plugins/ups/snmp__apcpdu
Executable file
128
plugins/ups/snmp__apcpdu
Executable file
|
@ -0,0 +1,128 @@
|
|||
#!/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…
Add table
Add a link
Reference in a new issue