mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-23 06:35:42 +00:00
obsolete
This commit is contained in:
parent
312bfae174
commit
2ef171cb7d
1 changed files with 4 additions and 219 deletions
|
@ -1,221 +1,6 @@
|
||||||
#!/usr/bin/env perl
|
This plugin is obsolete. Instead, please use apcupsd_pct plugin:
|
||||||
|
|
||||||
use strict;
|
apcupsd_pct plugin
|
||||||
use warnings;
|
http://exchange.munin-monitoring.org/plugins/apcupsd_pct/details
|
||||||
use Carp;
|
|
||||||
use Pod::Usage;
|
|
||||||
|
|
||||||
our $APCACCESS = $ENV{apcaccess} || "/sbin/apcaccess";
|
thanks.
|
||||||
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
|
|
||||||
|
|
||||||
=end comment
|
|
||||||
|
|
||||||
=cut
|
|
||||||
|
|
||||||
sub decide_monitor_type {
|
|
||||||
my $type = $0 =~ /_pct/ ? "pct" :
|
|
||||||
$0 =~ /_volt/ ? "volt" :
|
|
||||||
$0 =~ /_time/ ? "time" : 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",
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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 $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]*)/) : 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 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> - 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> ]
|
|
||||||
|
|
||||||
|
|
||||||
=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
|
|
||||||
|
|
||||||
restart munin-node
|
|
||||||
|
|
||||||
=head1 REPOSITORY
|
|
||||||
|
|
||||||
L<http://github.com/hirose31/munin-apcupsd-fixme/tree/master>
|
|
||||||
|
|
||||||
git clone git://github.com/hirose31/fixme.git
|
|
||||||
|
|
||||||
patches and collaborators are welcome.
|
|
||||||
|
|
||||||
=head1 SEE ALSO
|
|
||||||
|
|
||||||
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 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 :
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue