需先安裝AWS Cli

 

#查詢本機id

 

#call api 給cloudwatch
#aws cloudwatch put-metric-data –namespace HttpServerMetrics –metric-name  –dimension InstanceId=$instance_id –value $mem –unit “Megabytes”

 

#監控shellscript
#!/bin/bash
disk=`df -lha|grep /dev|head -1|awk ‘{printf $5}’`
aws cloudwatch put-metric-data –namespace disksize–metric-name disksizeuse –dimension InstanceId=$id –value $disk –unit “Percent”