Mode:
Duration:
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
package main
import "fmt"
type Metric struct {
Name string
Value int
}
type Alarm struct {
Metric string
Threshold int
}
func sendLog(message string) {
fmt.Println("LOG:", message)
}
func checkAlarm(metric Metric, alarm Alarm) {
if metric.Value > alarm.Threshold {
fmt.Println("ALARM:", metric.Name, "threshold exceeded")
} else {
fmt.Println("Metric healthy:", metric.Name)
}
}
func main() {
metric := Metric{
Name: "CPU Usage",
Value: 85,
}
alarm := Alarm{
Metric: "CPU Usage",
Threshold: 80,
}
sendLog("API server started")
checkAlarm(metric, alarm)
}Coding works best on desktop or with an external keyboard.