Perl unable to print String[] - get_monitor_association

Hi.

I am trying to use get_monitor_association() to query monitors of a server.

monitor_rule has structure of:

- type:MonitorRuleType(An indicator of how to deal/interpret with the list of monitors in monitor_templates.)

- quorum:long(A value to be used when type is MONITOR_RULE_TYPE_M_OF_N, i.e. this value is the M in M of N. This value is ignored for other rule types.)

- monitor_templates:String[](The list of monitors that constitute this monitor rule.)

However, the following Perl code is unable to retrieve the monitor_templates list.

Please kindly give advice.

Thanks in advance.

Alex

$soapResponse = $NodeAddress->get_monitor_association

(

SOAP::Data->name(server_names => [$sServerName]),

);

&checkResponse($soapResponse);

my @MonitorAssociationList = @{$soapResponse->result};

foreach $MonitorAssociation (@MonitorAssociationList)

{

print $MonitorAssociation ->{‘server_name’} . “\n”;

$monitorRule = $MonitorAssociation → {‘monitor_rule’};

print $monitorRule → {‘type’} . “\n”;

Okay so far for the above

**** Unable to show result for followings ****

@MonitorTemplatesList = $monitorRule → {‘monitor_templates’};

print “$MonitorTemplatesList[0]\n”;

print “@MonitorTemplatesList \n”;

}

Hi.

I understand now that monitor_templates is a pointer to a string array.

I changed the code to followings and it shows the results correctly.

$MonitorTemplatesList = $monitorRule → {‘monitor_templates’};

print “@$MonitorTemplatesList \n”;

Cheers.

Alex

Yeah, it’s an array. You can do something like this if you want to iterate through the list.

@MonitorTemplatesList = @{$monitorRule->{'monitor_templates'}};
foreach $MonitorTemplate (@MonitorTemplatesList)
{
  print "Template: $MonitorTemplate\n";
}

-Joe

Do you have an example for a PoolMember get_monitor_association?

Example follows.

Great example, thanks for the contribution!

-Joe

Thank you Joe. Just building on your examples. I appreciate your comments as well as your code.