1package Cisco::UCS::Common::PowerStats; 2 3use strict; 4use warnings; 5 6use Scalar::Util qw(weaken); 7 8our $VERSION = '0.51'; 9 10our %V_MAP = ( 11 consumedPower => 'consumed_power', 12 consumedPowerAvg=> 'consumed_power_avg', 13 consumedPowerMin=> 'consumed_power_min', 14 consumedPowerMax=> 'consumed_power_max', 15 inputCurrent => 'input_current', 16 inputCurrentAvg => 'input_current_avg', 17 inputCurrentMin => 'input_current_min', 18 inputCurrentMax => 'input_current_max', 19 inputVoltage => 'input_voltage', 20 inputVoltageAvg => 'input_voltage_avg', 21 inputVoltageMin => 'input_voltage_min', 22 inputVoltageMax => 'input_voltage_max', 23 thresholded => 'thresholded', 24 suspect => 'suspect', 25 timeCollected => 'time_collected' 26); 27 28{ no strict 'refs'; 29 30 while ( my ($attribute, $pseudo) = each %V_MAP ) { 31 *{ __PACKAGE__ .'::'. $pseudo } = sub { 32 my $self = shift; 33 return $self->{$attribute} 34 } 35 } 36} 37 38sub new { 39 my ( $class, $args ) = @_; 40 41 my $self = bless {}, $class; 42 43 foreach my $var ( keys %$args ) { 44 $self->{ $var } = $args->{ $var }; 45 } 46 47 return $self 48} 49 501; 51 52__END__ 53 54=head1 NAME 55 56Cisco::UCS::Common::PowerStats - Class for operations with Cisco UCS power 57usage statistics. 58 59=cut 60 61=head1 SYNOPSIS 62 63 # Print all blades in all chassis along with a cacti-style listing of 64 # the blades current, minimum and maximum power consumption values. 65 66 map { 67 print "Chassis: " . $_->id ."\n"; 68 69 map { print "\tBlade: ". $_->id ." - Power consumed -" 70 . " Current:". $_->power_stats->consumed_power 71 . " Max:". $_->power_stats->consumed_power_max 72 . " Min:". $_->power_stats->consumed_power_min ."\n" 73 } 74 sort { $a->id <=> $b->id } $_->get_blades 75 76 } 77 sort { 78 $a->id <=> $b->id 79 } $ucs->get_chassiss; 80 81 # Prints something like: 82 # 83 # Chassis: 1 84 # Blade: 1 - Power consumed - Current:115.656647 Max:120.913757 Min:110.399513 85 # Blade: 2 - Power consumed - Current:131.427994 Max:139.313675 Min:126.170883 86 # Blade: 3 - Power consumed - Current:131.427994 Max:157.713593 Min:126.170883 87 # Blade: 4 - Power consumed - Current:0.000000 Max:0.000000 Min:0.000000 88 # Blade: 5 - Power consumed - Current:0.000000 Max:0.000000 Min:0.000000 89 # Blade: 6 - Power consumed - Current:0.000000 Max:0.000000 Min:0.000000 90 # Blade: 7 - Power consumed - Current:0.000000 Max:0.000000 Min:0.000000 91 # Blade: 8 - Power consumed - Current:0.000000 Max:0.000000 Min:0.000000 92 # Chassis: 2 93 # Blade: 1 - Power consumed - Current:131.427994 Max:136.685120 Min:128.799438 94 # Blade: 2 - Power consumed - Current:126.170883 Max:131.427994 Min:123.542320 95 # Blade: 3 - Power consumed - Current:134.056564 Max:155.085037 Min:131.427994 96 # ...etc. 97 98=head1 DESCRIPTION 99 100Cisco::UCS::Common::PowerStats is a class providing operations with a Cisco 101UCS power usage statistics. 102 103Note that you are not supposed to call the constructor yourself, rather a 104Cisco::UCS::Common::PowerStats object is created automatically by method calls 105on a L<Cisco::UCS::Blade> object. 106 107=head1 METHODS 108 109=head3 consumed_power 110 111Returns the current power consumed value for the blade. 112 113=head3 consumed_power_avg 114 115Returns the current average power consumed value for the blade. 116 117=head3 consumed_power_min 118 119Returns the current minimum power consumed value for the blade. 120 121=head3 consumed_power_max 122 123Returns the current maximum power consumed value for the blade. 124 125=head3 input_current 126 127Returns the current input current value for the blade. 128 129=head3 input_current_avg 130 131Returns the current average input current value for the blade. 132 133=head3 input_current_min 134 135Returns the current minimum input current value for the blade. 136 137=head3 input_current_max 138 139Returns the current maximum input current value for the blade. 140 141=head3 input_voltage 142 143Returns the current input voltage value for the blade. 144 145=head3 input_voltage_avg 146 147Returns the current average input voltage value for the blade. 148 149=head3 input_voltage_min 150 151Returns the current minimum input voltage value for the blade. 152 153=head3 input_voltage_max 154 155Returns the current maximum input voltage value for the blade. 156 157=head3 thresholded 158 159Returns the input power thresholded state for the blade. 160 161=head3 suspect 162 163Returns the input power suspect state for the blade. 164 165=head3 time_collected 166 167Returns the timestamp at which time the power statsitics were collected. 168 169=head1 AUTHOR 170 171Luke Poskitt, C<< <ltp at cpan.org> >> 172 173=head1 BUGS 174 175Please report any bugs or feature requests to 176C<bug-cisco-ucs-common-powerstats at rt.cpan.org>, or through the web 177interface at 178L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Cisco-UCS-Common-PowerStats>. 179I will be notified, and then you'll automatically be notified of progress on 180your bug as I make changes. 181 182 183=head1 SUPPORT 184 185You can find documentation for this module with the perldoc command. 186 187 perldoc Cisco::UCS::Common::PowerStats 188 189You can also look for information at: 190 191=over 4 192 193=item * RT: CPAN's request tracker 194 195L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Cisco-UCS-Common-PowerStats> 196 197=item * AnnoCPAN: Annotated CPAN documentation 198 199L<http://annocpan.org/dist/Cisco-UCS-Common-PowerStats> 200 201=item * CPAN Ratings 202 203L<http://cpanratings.perl.org/d/Cisco-UCS-Common-PowerStats> 204 205=item * Search CPAN 206 207L<http://search.cpan.org/dist/Cisco-UCS-Common-PowerStats/> 208 209=back 210 211=head1 LICENSE AND COPYRIGHT 212 213Copyright 2013 Luke Poskitt. 214 215This program is free software; you can redistribute it and/or modify it 216under the terms of either: the GNU General Public License as published 217by the Free Software Foundation; or the Artistic License. 218 219See http://dev.perl.org/licenses/ for more information. 220 221 222=cut 223