Forum Discussion
mariogolf_57851
Dec 20, 2010Nimbostratus
System::SystemInfo::get_fan_metrics
Can you help me formatting the output returned from this call please?
----------------------------------------------------------------------------
sub get_fan_metrics
----------------------------------------------------------------------------
sub get_fan_metrics()
{
$soapResponse = $SystemInfo->get_fan_metrics();
&checkResponse($soapResponse);
@PlatformFans = $soapResponse->result;
foreach $PlatformFans (@PlatformFans)
{
@FanMetric = @{$PlatformFans->{"fans"}};
print Dumper \@FanMetric;
}
}
$VAR1 = [
bless( [
bless( {
'metric_type' => 'FAN_INDEX',
'value' => '101'
}, 'System::FanMetric' ),
bless( {
'metric_type' => 'FAN_STATE',
'value' => '1'
}, 'System::FanMetric' ),
bless( {
'metric_type' => 'FAN_SPEED',
'value' => '4530'
}, 'System::FanMetric' )
], 'System::FanMetric[]' ),
bless( [
bless( {
'metric_type' => 'FAN_INDEX',
'value' => '102'
}, 'System::FanMetric' ),
bless( {
'metric_type' => 'FAN_STATE',
'value' => '1'
}, 'System::FanMetric' ),
bless( {
'metric_type' => 'FAN_SPEED',
'value' => '4440'
}, 'System::FanMetric' )
], 'System::FanMetric[]' ),
bless( [
bless( {
'metric_type' => 'FAN_INDEX',
'value' => '103'
}, 'System::FanMetric' ),
bless( {
'metric_type' => 'FAN_STATE',
'value' => '1'
}, 'System::FanMetric' ),
bless( {
'metric_type' => 'FAN_SPEED',
'value' => '4411'
}, 'System::FanMetric' )
], 'System::FanMetric[]' ),
bless( [
bless( {
'metric_type' => 'FAN_INDEX',
'value' => '104'
}, 'System::FanMetric' ),
bless( {
'metric_type' => 'FAN_STATE',
'value' => '1'
}, 'System::FanMetric' ),
bless( {
'metric_type' => 'FAN_SPEED',
'value' => '4272'
}, 'System::FanMetric' )
], 'System::FanMetric[]' ),
bless( [
bless( {
'metric_type' => 'FAN_INDEX',
'value' => '105'
}, 'System::FanMetric' ),
bless( {
'metric_type' => 'FAN_STATE',
'value' => '1'
}, 'System::FanMetric' ),
bless( {
'metric_type' => 'FAN_SPEED',
'value' => '4299'
}, 'System::FanMetric' )
], 'System::FanMetric[]' ),
bless( [
bless( {
'metric_type' => 'FAN_INDEX',
'value' => '106'
}, 'System::FanMetric' ),
bless( {
'metric_type' => 'FAN_STATE',
'value' => '1'
}, 'System::FanMetric' ),
bless( {
'metric_type' => 'FAN_SPEED',
'value' => '4245'
}, 'System::FanMetric' )
], 'System::FanMetric[]' )
];
- mariogolf_57851Nimbostratus
---------------------------------------------------------------------------- sub get_fan_metrics ---------------------------------------------------------------------------- sub get_fan_metrics() { $soapResponse = $SystemInfo->get_fan_metrics(); $PlatformFans = $soapResponse->result; $TimeStamp=$PlatformFans->{'time_stamp'}; $FanMetric=$PlatformFans->{'fans'}; @AoA=$FanMetric; for $i ( 0 .. $AoA ) { for $j ( 0 .. ${$AoA[$i]} ) { $FanIndex = $AoA[$i][$j][0]; for my $Index (sort keys %{$FanIndex}) { print $Index . " " . $FanIndex->{"$Index"} . "\n"; } $FanState = $AoA[$i][$j][1]; for my $State (sort keys %{$FanState}) { print $State . " " . $FanState->{"$State"} . "\n"; } $FanSpeed = $AoA[$i][$j][2]; for my $Speed (sort keys %{$FanSpeed}) { print $Speed . " " . $FanSpeed->{"$Speed"} . "\n"; } } } print "The statistics were gathered: ["; print $TimeStamp->{'year'}; print $TimeStamp->{'month'}; print $TimeStamp->{'day'}; print $TimeStamp->{'hour'}; print $TimeStamp->{'minute'}; print $TimeStamp->{'second'}; print "]\n"; }
- mariogolf_57851NimbostratusThis code is ugly and needs cleaned up for pretty output but it is a start and works for these types of array outputs.
- mariogolf_57851NimbostratusYields:
- mariogolf_57851Nimbostratus& should be replaced by a simple &.
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects