I must be missing something....
Thanks again for the help!
below is the dump from Data::Dumper
and the modified function produces these errors....
ERRORS:
Scalar found where operator expected at ./describe_alarms.pl line 97,
+near
"@($result" (#1)
(S syntax) The Perl lexer knows whether to expect a term or an ope
+rator.
If it sees what it knows to be a term when it was expecting to see
+ an
operator, it gives you this warning. Usually it indicates that an
operator or delimiter was omitted, such as a semicolon.
(Missing operator before $result?) (#2)
(S syntax) This is an educated guess made in conjunction with the
+message
"%s found where operator expected". Often the missing operator is
+ a comma.
syntax error at ./describe_alarms.pl line 97, near "@($result"
Execution of ./describe_alarms.pl aborted due to compilation errors (#
+3)
(F) Probably means you had a syntax error. Common reasons include
+:
A keyword is misspelled.
A semicolon is missing.
A comma is missing.
An opening or closing parenthesis is missing.
An opening or closing brace is missing.
A closing quote is missing.
Often there will be another error message associated with the synt
+ax
error giving more information. (Sometimes it helps to turn on -w.
+)
The error message itself often tells you where it was in the line
+when
it decided to give up. Sometimes the actual error is several toke
+ns
before this, because Perl is good at understanding random input.
Occasionally the line number may be misleading, and once in a blue
+ moon
the only way to figure out what's triggering the error is to call
perl -c repeatedly, chopping away half the program each time to se
+e
if the error went away. Sort of the cybernetic version of 20 ques
+tions.
Uncaught exception from user code:
syntax error at ./describe_alarms.pl line 97, near "@($result"
Execution of ./describe_alarms.pl aborted due to compilation error
+s.
MODIFIED FUNCTION:
sub describe_alarms {
my ($alarm_name_prefix) = @_;
my $result;
my $obj = Paws->service( 'CloudWatch', region => 'us-east-1' );
$result = $obj->DescribeAlarms(
AlarmNamePrefix => $alarm_name_prefix,
);
# print Dumper($result);
print Dumper(ref @($result->MetricAlarms));
#print Dumper(@($result->MetricAlarms));
exit;
=pod
foreach ( @($result->MetricAlarms) ){
print "-"x79,"\n";
print "**AlarmName** : ", $_->AlarmName,"\n";
print Dumper($_);
}
print "\n***\n--number of elements: ", scalar @($result->MetricAla
+rms), "\n";
#return $result;
=cut
return $result;
}
DUMP:
$VAR1 = bless(
{
'_request_id' => '3eeadc30-9588-11e8-9cf2-e1b5a579da44',
'MetricAlarms' => [
bless(
{
'AlarmArn' =>
'arn:aws:cloudwatch:us-east-1:xxxxxxxxxxxxx:alarm:pubtech-best-gte-90-
+dev',
'StateReason' =>
'Threshold Crossed: 1 out of the last 2 datapoints [0.152614819450015
+(01/08/18 11:31:00)] was not greater than or equal to the threshold (
+90.0) (minimum 1 datapoint for ALARM -> OK transition).',
'AlarmActions' => [
'arn:aws:sns:us-east-1:xxxxxxxx:bestsellers_prd_best-alarm2'
],
'AlarmName' => 'pubtech-best-gte-90-dev',
'AlarmDescription' =>
'Alarm when volume is greater than or equal 90 p
+ercent',
'Period' => '300',
'ActionsEnabled' => 1,
'Dimensions' => [
bless(
{
'Name' => 'Filesystem',
'Value' => '/dev/xvdf'
},
'Paws::CloudWatch::Dimension'
),
bless(
{
'Name' => 'MountPath',
'Value' => '/best'
},
'Paws::CloudWatch::Dimension'
),
bless(
{
'Value' => 'xxxxxxxxxxxxxxx',
'Name' => 'InstanceId'
},
'Paws::CloudWatch::Dimension'
)
],
'Statistic' => 'Average',
'Threshold' => '90.0',
'DatapointsToAlarm' => '2',
'Namespace' => 'System/Linux',
'ComparisonOperator' => 'GreaterThanOrEqualToThres
+hold',
'StateReasonData' =>
'{"version":"1.0","queryDate":"2018-08-01T11:36:17.049+0000","startDat
+e":"2018-08-01T11:31:00.000+0000","statistic":"Average","period":300,
+"recentDatapoints":[0.152614819450015],"threshold":90.0}',
'StateValue' => 'OK',
'StateUpdatedTimestamp' => '2018-08-01T11:36:17.06
+2Z',
'EvaluationPeriods' => '2',
'TreatMissingData' => 'missing',
'MetricName' => 'DiskSpaceUtilization',
'AlarmConfigurationUpdatedTimestamp' =>
'2018-07-12T14:40:07.798Z'
},
'Paws::CloudWatch::MetricAlarm'
)
]
},
'Paws::CloudWatch::DescribeAlarmsOutput'
);
|