mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-24 09:57:09 +00:00
added support for absolute power display
This commit is contained in:
parent
2ef171cb7d
commit
0a94f881e6
1 changed files with 41 additions and 3 deletions
|
@ -43,6 +43,13 @@ 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
|
||||
|
@ -50,7 +57,8 @@ time
|
|||
sub decide_monitor_type {
|
||||
my $type = $0 =~ /_pct/ ? "pct" :
|
||||
$0 =~ /_volt/ ? "volt" :
|
||||
$0 =~ /_time/ ? "time" : undef
|
||||
$0 =~ /_time/ ? "time" :
|
||||
$0 =~ /_pwr/ ? "pwr" : undef
|
||||
or croak "unknown monitor type: $0";
|
||||
|
||||
# common
|
||||
|
@ -91,6 +99,14 @@ sub decide_monitor_type {
|
|||
label => "remaining runtime left on batteries",
|
||||
},
|
||||
);
|
||||
} elsif ($type eq "pwr") {
|
||||
$Graph{graph_title} .= "Power";
|
||||
$Graph{graph_vlabel} = "watts";
|
||||
%Metric =(
|
||||
LOADMETRIC => {
|
||||
label => "absolute power consumption",
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -103,12 +119,13 @@ sub do_fetch {
|
|||
|
||||
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]*)/) : 0);
|
||||
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;
|
||||
|
@ -144,6 +161,19 @@ sub retrieve_apcupsd_status {
|
|||
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);
|
||||
|
@ -159,7 +189,7 @@ __END__
|
|||
|
||||
=head1 NAME
|
||||
|
||||
B<apcupsd_pct>, B<apcupsd_volt>, B<apcupsd_time> - munin plugin for APC UPS
|
||||
B<apcupsd_pct>, B<apcupsd_volt>, B<apcupsd_time>, B<apcupsd_pwr>- munin plugin for APC UPS
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
|
@ -169,6 +199,7 @@ B<apcupsd_volt> [ I<config>|I<fetch> ]
|
|||
|
||||
B<apcupsd_time> [ I<config>|I<fetch> ]
|
||||
|
||||
B<apcupsd_pwr> [ I<config>|I<fetch> ]
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
|
@ -183,6 +214,7 @@ munin plugin to monitor APC UPS via apcupsd by apcaccess.
|
|||
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
|
||||
|
||||
|
@ -196,6 +228,8 @@ 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>
|
||||
|
||||
|
@ -203,6 +237,10 @@ L<http://munin.projects.linpro.no/wiki/protocol-config>
|
|||
|
||||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue