omni-lchen / zabbix-cloudwatch

71 stars 61 forks source link

AttributeError: 'NoneType' object has no attribute 'get_metric_statistics' #53

Open ycatoireDS opened 4 years ago

ycatoireDS commented 4 years ago

Hi,

First, thank you for your work. But i have a problem when i launch cli command to retrieve metrics from RDS instance.

When i launch this command : ./cron.RDS.sh "database-zabbix" "FOUQUET RDS" "127.0.0.1" "awsfouquet" "eu-west-3" Or this command : ./zabbixCloudWatch.py -z "127.0.0.1" -x "FOUQUET RDS" -a "awsfouquet" -r "" -s "RDS" -d "DBInstanceIdentifier=database-zabbix" -p "60" -f "2019-12-05 15:30:00" -t "2019-12-05 16:00:00"

I have these errors :

Traceback (most recent call last): File "./zabbixCloudWatch.py", line 394, in cw_data = getCloudWatchData(aws_account, aws_region, aws_service, dimensions) File "./zabbixCloudWatch.py", line 181, in getCloudWatchData results = cw.get_metric_statistics(period, start_time, end_time, metric_name, namespace, statistics, dimensions) AttributeError: 'NoneType' object has no attribute 'get_metric_statistics'

But if i try to get metrics from AWS CLI, it works well : aws cloudwatch get-metric-statistics --namespace 'AWS/RDS' --metric-name 'CPUUtilization' --dimensions Name=DBInstanceIdentifier,Value=database-zabbix --start-time '2019-12-05T12:00:00Z' --end-time '2019-12-05T12:30:00Z' --period 60 --statistics 'Maximum'

Result : { "Timestamp": "2019-12-05T12:24:00Z", "Maximum": 1.47540983606554, "Unit": "Percent" } ], "Label": "CPUUtilization"

Thanks for your help.

ycatoireDS commented 4 years ago

Hi, nobody ? :)

sherrerq commented 4 years ago

Hello. I have the same problem. It appears when I uncomment get_metric_statistics function in zabbixCloudWatch.py. I have done it trying to solve other problem (TypeError: 'NoneType' object is not iterable) without success.

I do not know why it is uncommented in the script

ycatoireDS commented 4 years ago

Hi @sherrerq ,

Thanks for your help. This is the line you talk ? (line 78 and 165) : get_metric_statistics(period, start_time, end_time, metric_name, namespace, statistics, dimensions=None, unit=None)

Because these lines are commented in my zabbixCloudWatch.py. If i uncomment these lines i have this error :

Traceback (most recent call last):
  File "/opt/zabbix/cloudwatch/zabbixCloudWatch.py", line 394, in <module>
    cw_data = getCloudWatchData(aws_account, aws_region, aws_service, dimensions)
  File "/opt/zabbix/cloudwatch/zabbixCloudWatch.py", line 165, in getCloudWatchData
    get_metric_statistics(period, start_time, end_time, metric_name, namespace, statistics, dimensions=None, unit=None)
NameError: global name 'get_metric_statistics' is not defined

Thanks for your help.