diff --git a/plugins/other/apcupsd_pct b/plugins/other/apcupsd_pct index 25fa6c8c..65e34ea5 100755 --- a/plugins/other/apcupsd_pct +++ b/plugins/other/apcupsd_pct @@ -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, B, B - munin plugin for APC UPS +B, B, B, B- munin plugin for APC UPS =head1 SYNOPSIS @@ -169,6 +199,7 @@ B [ I|I ] B [ I|I ] +B [ I|I ] =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 + L, L @@ -203,6 +237,10 @@ L HIROSE, Masaaki Ehirose31 _at_ gmail.comE +=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