IBM-StorageSystem
view release on metacpan or search on metacpan
lib/IBM/StorageSystem/Statistic.pm view on Meta::CPAN
sub new {
my( $class, $ibm, %args ) = @_;
my $self = bless {}, $class;
weaken( $self->{__ibm} = $ibm );
foreach my $attr ( keys %args ) { $self->{$attr} = $args{$attr} }
$self->{ts} = time;
return $self;
}
sub refresh {
my $self = shift;
foreach my $stat ( splice @{ [ split /\n/, $self->{__ibm}->__cmd( 'lssystemstats -gui -delim :' ) ] }, 1 ) {
my ( $name, $epoch, $current, $peak, $peak_time, $peak_epoch ) = split /:/, $stat;
next unless $name eq $self->name;
$self->epoch( $epoch );
$self->current( $current );
$self->peak( $peak );
$self->peak_time( $peak_time );
$self->peak_epoch( $peak_epoch )
}
$self->{ts} = time;
return $self
}
sub history {
my $self = shift;
my @res;
foreach my $stat (splice @{ [split /\n/, $self->{__ibm}->__cmd( "lssystemstats -history $self->{name} -delim :")] }, 1) {
my ( $time, $name, $value ) = split /:/, $stat;
push @res, { time => $time, value => $value };
}
return reverse @res;
}
1;
__END__
=pod
=head1 NAME
IBM::StorageSystem::Statistic - Class for operations with IBM StorageSystem system statistics
=head1 VERSION
Version 0.01
=head1 SYNOPSIS
IBM::StorageSystem::Statistic - Class for operations with IBM StorageSystem system statistics
use IBM::StorageSystem;
my $ibm = IBM::StorageSystem->new( user => 'admin',
host => 'my-v7000',
key_path => '/path/to/my/.ssh/private_key'
) or die "Couldn't create object! $!\n";
# Print the current system FC IOPS
print $ibm->fc_io->current;
# Print the peak system FC IOPS
print $ibm->fc_io->peak;
# Refresh the FC IOPS statistics and print the new current value
$ibm->fc_io->refresh;
print $ibm->fc_io->current;
# Or, alternately
print $ibm->fc_io->refresh->current;
# Retrieve the historical statistics for CPU usage and print
# them along with the recorded epoch time
foreach my $v ( $ibm->fc_io->history ) { print "$v->{time} : $v->{value}\n" }
# e.g.
# 130110140921 : 100
# 130110140916 : 100
# 130110140911 : 92
# 130110140906 : 90
# 130110140901 : 100
# 130110140856 : 100
# 130110140851 : 92
# ... etc.
=head1 METHODS
=head3 name
Returns the statistic name - this is the same name as the method invocant.
=head3 epoch
Returns the epoch value for the samle period in which the statistic was measured.
=head3 current
Returns the current statistic value. Please refer to the lssystemstat manual page
for detailed information on possible return values.
=head3 peak
Returns the peak statistic value for the current measurement time period.
=head3 peak_time
Returns the time at which the peak statistic value for the current measurement period
was recorded.
Please see the L<NOTES> section below regarding the time format used and conversion
methods.
=head3 peak_epoch
Returns the epoch time at which the peak statistic value for the current measurement
period was recorded.
( run in 0.397 second using v1.01-cache-2.11-cpan-39bf76dae61 )