forked from mtusi2026/mtusi2026lab5
ЛР 5: асинхронная обработка изображений и идемпотентность pipeline
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Local operator command, never an HTTP endpoint. cgroup v2 records peaks
|
||||
// between Docker samples too; the experiment recreates API cgroups per case.
|
||||
func memorySnapshot() error {
|
||||
result := map[string]uint64{}
|
||||
for _, name := range []string{"memory.current", "memory.peak"} {
|
||||
raw, err := os.ReadFile("/sys/fs/cgroup/" + name)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cgroup v2 %s unavailable", name)
|
||||
}
|
||||
value, err := strconv.ParseUint(strings.TrimSpace(string(raw)), 10, 64)
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid cgroup %s", name)
|
||||
}
|
||||
result[name] = value
|
||||
}
|
||||
return json.NewEncoder(os.Stdout).Encode(result)
|
||||
}
|
||||
Reference in New Issue
Block a user