randywallace / zabbix-cloudwatch

An external script for getting cloudwatch metrics into Zabbix
MIT License
27 stars 11 forks source link

Region immunity #5

Open vanch opened 9 years ago

vanch commented 9 years ago

After hours of debug I found some issue.

Environment: Ruby 2.0.0p645 Amazon Linux AMI release 2015.03 zabbix-cloudwatch 0.1.0

Problem: Always empty response with right request.

zabbix-cloudwatch --aws-access-key $AWSACCESSKEY --aws-secret-key $AWSSECRETKEY --aws-region eu-central-1 --namespace "AWS/RDS" --metricname FreeStorageSpace --dimension-name "DBInstanceIdentifier" --dimension-value somename

gives me nothing, just empty datapoint array.

Investigation: I've been found similar issues when region is not set, so I checked. In main binary that's ok eu-central-1, but when you going lower, to get_aws_options function, there is if with && which gives you on p options.key?"aws-region" && options['aws-region'] != '' - false. I can't understand why it's possible.

Solution: I've changed && to and and everything works. In this statement there is no difference between && and and so it's ok.

randywallace commented 8 years ago

http://devblog.avdi.org/2010/08/02/using-and-and-or-in-ruby/ good catch.

randywallace commented 8 years ago

7 should resolve this

tiago-cruz-movile commented 8 years ago

Good! confirmed here the change from && to and and now is working :+1: