omni-lchen / zabbix-cloudwatch

71 stars 61 forks source link

PostgreSQL monitoring #33

Closed tkreque closed 6 years ago

tkreque commented 6 years ago

Hi,

We're using this repository for sometime to monitor our MySQL databases with no issue so far. Recently we added a PostgreSQL in our RDS and we aren't able to integrate to Zabbix. The error that we got was:

# ./zabbixCloudWatch.py -z "localhost" -x "pginstance" -a "aws_account" -r "aws_region" -s "RDS" -d "DBInstanceIdentifier=pginstance" -p "300" -f "2018-04-16 13:10:00" -t "2018-04-16 13:15:00"
Traceback (most recent call last):
  File "./zabbixCloudWatch.py", line 368, in <module>
    sendLatestCloudWatchData(zabbix_server, zabbix_host, cw_data)
  File "./zabbixCloudWatch.py", line 221, in sendLatestCloudWatchData
    zabbix_key_timestamp = int(time.mktime(sorts[0]['Timestamp'].timetuple()))
UnboundLocalError: local variable 'sorts' referenced before assignment

After some investigation I was able to find that because of the first metric been a MySQL only the PostgreSQL wasn't able to populate the Zabbix.

I changed the lines 62-63 for the 66-67 in the _conf/aws_servicesmetrics.conf file and now we're abel to monitor the PostgreSQL as well. Old

    60      "RDS": [
    61          {
    62              "metric": "BinLogDiskUsage",
    63              "statistics": "Average"
    64          },
    65      {
    66              "metric": "CPUUtilization",
    67              "statistics": "Average"
    68          },

New

    60      "RDS": [
    61          {
    62              "metric": "CPUUtilization",
    63              "statistics": "Average"
    64          },
    65      {
    66              "metric": "BinLogDiskUsage",
    67              "statistics": "Average"
    68          },

I hope this can help other with the same issue ;)

omni-lchen commented 6 years ago

Strange, it looks like the same metrics but in different order, I can change the order, thanks.

tkreque commented 6 years ago

@omni-lchen Yes, I only had to change the order to PostgreSQL start to been monitored. :+1: