@@ -28,18 +28,16 @@ resource "coder_agent" "main" {
28
28
# calculates CPU usage by summing the "us", "sy" and "id" columns of
29
29
# vmstat.
30
30
script = <<EOT
31
- vmstat | awk 'FNR==3 {printf "%2.0f%%", $13+$14+$16 }'
31
+ top -bn1 | awk 'FNR==3 {printf "%2.0f%%", $2+$3+$4 }'
32
32
EOT
33
33
interval = 1
34
34
timeout = 1
35
35
}
36
36
37
37
metadata {
38
38
display_name = "Disk Usage"
39
- key = "cpu"
40
- script = <<EOT
41
- df -h | awk -v mount="/" '$6 == mount { print $5 }'
42
- EOT
39
+ key = "disk"
40
+ script = "df -h | awk '$6 ~ /^\\/$/ { print $5 }'"
43
41
interval = 1
44
42
timeout = 1
45
43
}
@@ -59,7 +57,7 @@ resource "coder_agent" "main" {
59
57
key = "load"
60
58
script = <<EOT
61
59
awk '{print $1,$2,$3}' /proc/loadavg
62
- >>
60
+ EOT
63
61
interval = 1
64
62
timeout = 1
65
63
}
@@ -68,6 +66,16 @@ resource "coder_agent" "main" {
68
66
69
67
## Utilities
70
68
69
+ [ top] ( https://linux.die.net/man/1/top ) is available in most Linux
70
+ distributions and provides virtual memory, CPU and IO statistics. Running ` top `
71
+ produces output that looks like:
72
+
73
+ ```
74
+ %Cpu(s): 65.8 us, 4.4 sy, 0.0 ni, 29.3 id, 0.3 wa, 0.0 hi, 0.2 si, 0.0 st
75
+ MiB Mem : 16009.0 total, 493.7 free, 4624.8 used, 10890.5 buff/cache
76
+ MiB Swap: 0.0 total, 0.0 free, 0.0 used. 11021.3 avail Mem
77
+ ```
78
+
71
79
[ vmstat] ( https://linux.die.net/man/8/vmstat ) is available in most Linux
72
80
distributions and provides virtual memory, CPU and IO statistics. Running ` vmstat `
73
81
produces output that looks like:
0 commit comments