UPD: clean up code comments

This commit is contained in:
KF 2022-11-03 21:11:15 +08:00
parent a0cf9362d4
commit ee09ad461c
Signed by: xpk
GPG Key ID: CD4FF6793F09AB86
2 changed files with 35 additions and 22 deletions

View File

@ -87,7 +87,6 @@ resource "aws_cloudwatch_metric_alarm" "ec2-mem_free" {
actions_enabled = var.actions-enabled actions_enabled = var.actions-enabled
alarm_actions = [var.alarm-actions-standard] alarm_actions = [var.alarm-actions-standard]
ok_actions = [var.alarm-actions-standard] ok_actions = [var.alarm-actions-standard]
treat_missing_data = "notBreaching"
dimensions = { dimensions = {
InstanceId = var.ec2-instance-id InstanceId = var.ec2-instance-id
ImageId = data.aws_instance.ec2-instance.ami ImageId = data.aws_instance.ec2-instance.ami
@ -101,20 +100,15 @@ resource "aws_cloudwatch_metric_alarm" "ec2-mem_free" {
resource "aws_cloudwatch_metric_alarm" "ec2-swap_free" { resource "aws_cloudwatch_metric_alarm" "ec2-swap_free" {
# zero is fine as most ec2 instances are deployed without any swap # zero is fine as most ec2 instances are deployed without any swap
alarm_name = "${var.cw-alarm-prefix}:EC2:swap_free:${var.ec2-instance-id}" alarm_name = "${var.cw-alarm-prefix}:EC2:swap_free:${var.ec2-instance-id}"
comparison_operator = "LessThanThreshold" comparison_operator = "LessThanThreshold"
evaluation_periods = "2" evaluation_periods = "2"
# metric_name = "swap_free" threshold = var.threshold-swap_free
# period = "900" alarm_description = "EC2:swap_free"
# statistic = "Average"
threshold = var.threshold-swap_free
alarm_description = "EC2:swap_free"
# namespace = "CWAgent"
insufficient_data_actions = [] insufficient_data_actions = []
actions_enabled = var.actions-enabled actions_enabled = var.actions-enabled
alarm_actions = [var.alarm-actions-standard] alarm_actions = [var.alarm-actions-standard]
ok_actions = [var.alarm-actions-standard] ok_actions = [var.alarm-actions-standard]
treat_missing_data = "notBreaching"
metric_query { metric_query {
id = "m1" id = "m1"
metric { metric {
@ -136,11 +130,6 @@ resource "aws_cloudwatch_metric_alarm" "ec2-swap_free" {
return_data = "true" return_data = "true"
} }
#dimensions = {
# InstanceId = var.ec2-instance-id
# ImageId = data.aws_instance.ec2-instance.ami
# InstanceType = data.aws_instance.ec2-instance.instance_type
#}
tags = var.default-tags tags = var.default-tags
lifecycle { lifecycle {
ignore_changes = [tags] ignore_changes = [tags]
@ -174,11 +163,9 @@ resource "aws_cloudwatch_metric_alarm" "ec2-disk_free" {
InstanceId = var.ec2-instance-id InstanceId = var.ec2-instance-id
ImageId = data.aws_instance.ec2-instance.ami ImageId = data.aws_instance.ec2-instance.ami
InstanceType = data.aws_instance.ec2-instance.instance_type InstanceType = data.aws_instance.ec2-instance.instance_type
#device = length(data.external.disk-device.result.device) > 0 ? data.external.disk-device.result.device : "unknown" device = data.external.disk-device.result.device
#fstype = length(data.external.disk-device.result.fstype) > 0 ? data.external.disk-device.result.fstype : "unknown" fstype = data.external.disk-device.result.fstype
device = data.external.disk-device.result.device path = "/"
fstype = data.external.disk-device.result.fstype
path = "/"
} }
tags = var.default-tags tags = var.default-tags
lifecycle { lifecycle {
@ -214,3 +201,28 @@ resource "aws_cloudwatch_metric_alarm" "ec2-disk_inodes_free" {
ignore_changes = [tags] ignore_changes = [tags]
} }
} }
resource "aws_cloudwatch_metric_alarm" "ec2-processes_total" {
alarm_name = "${var.cw-alarm-prefix}:EC2:processes_total:${var.ec2-instance-id}"
comparison_operator = "GreaterThanThreshold"
evaluation_periods = "2"
metric_name = "processes_total"
period = "900"
statistic = "Average"
threshold = var.threshold-processes_total
alarm_description = "EC2:processes_total"
namespace = "CWAgent"
insufficient_data_actions = []
actions_enabled = var.actions-enabled
alarm_actions = [var.alarm-actions-urgent]
ok_actions = [var.alarm-actions-urgent]
dimensions = {
InstanceId = var.ec2-instance-id
ImageId = data.aws_instance.ec2-instance.ami
InstanceType = data.aws_instance.ec2-instance.instance_type
}
tags = var.default-tags
lifecycle {
ignore_changes = [tags]
}
}

View File

@ -24,3 +24,4 @@ variable "threshold-mem_free" {}
variable "threshold-swap_free" {} variable "threshold-swap_free" {}
variable "threshold-disk_free" {} variable "threshold-disk_free" {}
variable "threshold-disk_inodes_free" {} variable "threshold-disk_inodes_free" {}
variable "threshold-processes_total" {}