Skip to content

Commit b5371c3

Browse files
doc: monitord package documentation (#77)
1 parent cc7fdef commit b5371c3

1 file changed

Lines changed: 58 additions & 0 deletions

File tree

docs/internals/monitord/readme.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Monitord Package
2+
3+
## Introduction
4+
5+
monitord package is responsible for continuously monitoring a node’s system resources.
6+
It provides a monitor stream for components such as CPU, memory, disk, network cards, and system uptime.
7+
8+
9+
## Interface
10+
### System Monitor
11+
12+
```go
13+
// systemMonitor implements the pkg.SystemMonitor interface
14+
type systemMonitor struct {
15+
duration time.Duration // duration between statistics collection
16+
node uint32 // node ID
17+
cl zbus.Client // client used to request node data
18+
}
19+
20+
type SystemMonitor interface {
21+
22+
// CPU starts cpu monitor stream
23+
// It periodically emits CPU usage percentage and time statistics
24+
CPU(ctx context.Context) <-chan pkg.TimesStat
25+
26+
// Disks starts disk monitor stream
27+
// It periodically emits disk stats for all mounted disks, including number of read/write operations, IO time, serial number
28+
Disks(ctx context.Context) <-chan pkg.DisksIOCountersStat
29+
30+
// Get the types of workloads can be deployed depending on the network manager running on the node
31+
GetNodeFeatures() []pkg.NodeFeature
32+
33+
// Memory starts memory monitor stream
34+
// It periodically emits VirtualMemoryStat containing memory usage statistics like Total, Available and Used in bytes
35+
Memory(ctx context.Context) <-chan pkg.VirtualMemoryStat
36+
37+
// Nics starts Nic monitor stream
38+
// It periodically emits Nic stats for all available network cards, including number of packets sent, received or dropped
39+
Nics(ctx context.Context) <-chan pkg.NicsIOCounterStat
40+
41+
// Returns node ID
42+
NodeID() uint32
43+
}
44+
```
45+
46+
### Host Monitor
47+
48+
```go
49+
// hostMonitor provides host-level monitoring such as system uptime.
50+
type hostMonitor struct {
51+
duration time.Duration
52+
}
53+
54+
type HostMonitor interface {
55+
// Uptime periodically reads /proc/uptime file, parses it and emits the uptime
56+
Uptime(ctx context.Context) <-chan time.Duration
57+
}
58+
```

0 commit comments

Comments
 (0)