【问题标题】:AWS RDS: How to get hold of the Current Activity / Number of Connections?AWS RDS:如何获取当前活动/连接数?
【发布时间】:2018-11-12 16:56:13
【问题描述】:

使用 AWS RDS 控制台,很容易在“当前活动”列中查看到实例的连接数:

如何从aws cli 获取此信息?据我所知,aws rds describe-db-instances 似乎没有这条特定信息。

注意:就我而言,知道是否存在 任何 连接就足够了。

【问题讨论】:

    标签: amazon-rds amazon-aurora


    【解决方案1】:

    对于指标,您应该使用aws cloudwatch 工具。要获取当前的数据库连接数,您可以使用以下内容:

    aws cloudwatch get-metric-statistics --namespace AWS/RDS
    --metric-name DatabaseConnections --start-time 2018-06-14T16:00:00Z
    --end-time 2018-06-14T16:01:00Z --period 60 --statistics "Maximum"
    --dimensions Name=DBInstanceIdentifier,Value=your-db-identifier
    

    您需要将它与代码或脚本结合起来以插入正确的 --start-time--end-time 值。

    【讨论】:

      【解决方案2】:
      mon-get-stats --region "your-region" --metric-name="DatabaseConnections" --namespace="AWS/RDS" --dimensions="DBInstanceIdentifier=your-db-name" --statistics Maximum > your-db-name.txt
      
      awk 'END{printf "%.0f",$3}' your-db-name.txt > your-db-name-final.txt
      
      echo "$(cat your-db-name-final.txt)"
      

      上面的小脚本显示您的 RDS 当前连接

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-07-08
        相关资源
        最近更新 更多