mesh/delivery-group group feat/774-l3-reland rejected: composed together: the checker's verdict at the members' heads (b48c90fea31f): integration: mesh-self-ch…
mesh/delivery closed: a newer head of the same pull request
mesh/check failed: integration: mesh-self-check/cmd/mesh-self-check.TestTheSelfCheckWholeRunsOnTheBus: the run answered {Run:doctor-1793351737-1 At:20…
One commit with exactly the tree of the reviewed head35b4509c0a, on main12c2574c9d, so two compiled programs added and removed on the branch leave no trace in history (issue 1577).
62 lines
2.3 KiB
Go
62 lines
2.3 KiB
Go
// The disk-load module's Go bundle (novox/hq ADR 0188, ADR 0193, issue 312): a process the node's
|
|
// runtime launches and speaks MCP over stdio to. It reads the machine's storage load from /proc and
|
|
// /sys — iowait, pressure stall, each disk's busy share, throughput, IOPS, wait and queue depth, the
|
|
// filesystems' space and the processes doing the I/O — and changes nothing of the machine.
|
|
//
|
|
// It also measures the data items the modules of its node declare (ADR 0233) and keeps each reading and the item's
|
|
// seven-day peak as its own state `readings` (ADR 0571 clause 3), composed from the bus (no file).
|
|
package main
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"os"
|
|
"strings"
|
|
"time"
|
|
|
|
stdio "git.novox.be/novox/mesh-sdk/go"
|
|
"git.novox.be/novox/mesh-sdk/go/announce"
|
|
"git.novox.be/novox/mesh-sdk/go/catalogue"
|
|
"git.novox.be/novox/mesh-sdk/go/compose/frombus"
|
|
"git.novox.be/novox/mesh-sdk/go/compose/fromruntime"
|
|
)
|
|
|
|
func logf(format string, args ...any) { fmt.Fprintf(os.Stderr, "[disk-load] "+format+"\n", args...) }
|
|
|
|
func main() {
|
|
if err := stdio.Keeps(announce.State{Name: StateReadings}); err != nil {
|
|
logf("%v", err)
|
|
os.Exit(1)
|
|
}
|
|
node := os.Getenv("MESH_NODE")
|
|
k := &Keeper{Node: node, Store: busStore{}, Say: logf, Measurer: Measurer{Run: RootRunner, Now: time.Now},
|
|
Items: func(ctx context.Context) (map[string][]catalogue.PlacedDataItem, error) {
|
|
return placedItems(ctx, node)
|
|
}}
|
|
if node != "" {
|
|
every := time.Hour
|
|
if d, err := time.ParseDuration(os.Getenv("MESH_DISK_MEASURE_EVERY")); err == nil && d >= time.Minute {
|
|
every = d
|
|
}
|
|
go k.Loop(context.Background(), every, 3*time.Minute)
|
|
}
|
|
tools := append(Tools(Here()), ReadingTools(k)...)
|
|
// An empty name serves as the module the runtime names (MESH_SERVED_MODULE): disk-load.
|
|
if err := stdio.Serve("", tools); err != nil {
|
|
fmt.Fprintln(os.Stderr, err)
|
|
os.Exit(1)
|
|
}
|
|
}
|
|
|
|
// placedItems is every data item the modules placed on node declare, composed from the bus as the node composes itself.
|
|
func placedItems(ctx context.Context, node string) (map[string][]catalogue.PlacedDataItem, error) {
|
|
items, unplaced, err := frombus.DataItems(ctx, fromruntime.Reader(), frombus.Mesh{}, frombus.Scope{Node: node})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if len(unplaced) > 0 {
|
|
logf("data items left out as not placeable: %s", strings.Join(unplaced, "; "))
|
|
}
|
|
return items, nil
|
|
}
|