forked from ntimo/coder-hetzner-cloud-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcoder.tf
More file actions
113 lines (103 loc) · 2.31 KB
/
coder.tf
File metadata and controls
113 lines (103 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
data "coder_parameter" "volume_size" {
name = "volume_size"
description = "Disk Size in GB"
default = 10
type = "number"
mutable = true
validation {
min = 10
max = 250
monotonic = "increasing"
}
}
data "coder_parameter" "code_server_extentions" {
name = "code-server extentions"
type = "list(string)"
description = "List of code-server extentions"
mutable = true
default = jsonencode([
"dracula-theme.theme-dracula",
"ms-toolsai.jupyter",
"redhat.vscode-yaml",
"redhat.vscode-xml",
"redhat.ansible",
"samuelcolvin.jinjahtml",
"PKief.material-icon-theme",
"hashicorp.terraform",
"hashicorp.hcl",
"GitLab.gitlab-workflow",
"scala-lang.scala",
"scalameta.metals"
])
}
data "coder_workspace" "me" {
}
resource "coder_agent" "dev" {
arch = strcontains(module.hcloud_instance_type.value, "cax") ? "arm64" : "amd64" #change this!
os = "linux"
metadata {
display_name = "CPU Usage"
key = "cpu"
script = <<EOT
echo "$[100-$(vmstat 1 2|tail -1|awk '{print $15}')]"%
EOT
interval = 15
timeout = 5
}
metadata {
display_name = "Memory Usage"
key = "RAM"
script = <<EOT
free | awk '/^Mem/ { printf("%.0f%%", $2/$4 ) }'
EOT
interval = 15
timeout = 1
}
metadata {
display_name = "Load Average"
key = "load"
script = <<EOT
awk '{print $1}' /proc/loadavg
EOT
interval = 15
timeout = 1
}
metadata {
display_name = "Disk Usage /"
key = "disk-root"
script = <<EOT
df -h / | awk '{ print $5 }' | tail -1
EOT
interval = 15
timeout = 1
}
metadata {
display_name = "Disk Usage home"
key = "disk-home"
script = <<EOT
df -h /home/* | awk '{ print $5 }' | tail -1
EOT
interval = 15
timeout = 1
}
metadata {
display_name = "Process Count"
key = "process_count"
script = <<EOT
ps aux | wc -l
EOT
interval = 10
timeout = 1
}
metadata {
display_name = "Container Count"
key = "container_count"
script = <<EOT
[ -x "$(command -v docker)" ] && sudo docker ps | tail -n +2 | wc -l && exit 0
[ -x "$(command -v podman)" ] && podman ps | tail -n +2 | wc -l && exit 0
echo 0
EOT
interval = 15
timeout = 1
}
}