Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
260 views
in Technique[技术] by (71.8m points)

amazon ec2 - How to test "DiskSpaceUtilization" alarm for my ec2 instance?

I have set "root-disk-space-utilization" and "data-disk-space-utilization" for my ec2 instance. The code to set "root-disk-space-utilization":

aws cloudwatch put-metric-alarm 
--alarm-name root-disk-space-utilization 
--alarm-description "Alarm when root disk space exceeds $ROOT_DISK_THRESHOLD percent" 
--metric-name DiskSpaceUtilization 
--namespace System/Linux 
--statistic Average 
--period $period 
--threshold $ROOT_DISK_THRESHOLD 
--treat-missing-data notBreaching 
--comparison-operator GreaterThanThreshold 
--dimensions Name=Filesystem,Value=$ROOT_DEVICE Name=InstanceId,Value=$val Name=MountPath,Value=$ROOT_PATH 
--evaluation-periods 1 
--alarm-actions $arn 
--ok-actions $arn 
--unit Percent

Here, ROOT_DEVICE=/dev/sda1 ; DATA_DEVICE=/dev/sdf ; ROOT_PATH=/ ; DATA_PATH=/data . To set "data-disk-space-utilization":

aws cloudwatch put-metric-alarm 
--alarm-name data-disk-space-utilization 
--alarm-description "Alarm when data disk space exceeds $DATA_DISK_THRESHOLD percent" 
--metric-name DiskSpaceUtilization 
--namespace System/Linux 
--statistic Average 
--period $period 
--threshold $DATA_DISK_THRESHOLD 
--treat-missing-data notBreaching 
--comparison-operator GreaterThanThreshold 
--dimensions Name=Filesystem,Value=$DATA_DEVICE Name=InstanceId,Value=$val Name=MountPath,Value=$DATA_PATH 
--evaluation-periods 1 
--alarm-actions $arn 
--ok-actions $arn 
--unit Percent 

With the help of above code, I am able to set the cloudwatch metrics but none is getting in "Alarm State". I have also tried and changed the threshold to 1, just to check if it goes in the "Alarm State" but still it did not changed. I am a bit unsure if my above code is correct or not and how will it trigger Alarm? enter image description here

question from:https://stackoverflow.com/questions/65618107/how-to-test-diskspaceutilization-alarm-for-my-ec2-instance

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...