mirror of
https://github.com/henrygd/beszel.git
synced 2026-04-21 04:01:50 +02:00
updates
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
package probe
|
||||
|
||||
import "fmt"
|
||||
import "strconv"
|
||||
|
||||
// Config defines a network probe task sent from hub to agent.
|
||||
type Config struct {
|
||||
@@ -11,18 +11,21 @@ type Config struct {
|
||||
}
|
||||
|
||||
// Result holds aggregated probe results for a single target.
|
||||
type Result struct {
|
||||
AvgMs float64 `cbor:"0,keyasint" json:"avg"`
|
||||
MinMs float64 `cbor:"1,keyasint" json:"min"`
|
||||
MaxMs float64 `cbor:"2,keyasint" json:"max"`
|
||||
Loss float64 `cbor:"3,keyasint" json:"loss"` // packet loss %
|
||||
}
|
||||
//
|
||||
// 0: avg latency in ms
|
||||
//
|
||||
// 1: min latency in ms
|
||||
//
|
||||
// 2: max latency in ms
|
||||
//
|
||||
// 3: packet loss percentage (0-100)
|
||||
type Result []float64
|
||||
|
||||
// Key returns the map key used for this probe config (e.g. "icmp:1.1.1.1", "tcp:host:443", "http:https://example.com").
|
||||
func (c Config) Key() string {
|
||||
switch c.Protocol {
|
||||
case "tcp":
|
||||
return c.Protocol + ":" + c.Target + ":" + fmt.Sprintf("%d", c.Port)
|
||||
return c.Protocol + ":" + c.Target + ":" + strconv.FormatUint(uint64(c.Port), 10)
|
||||
default:
|
||||
return c.Protocol + ":" + c.Target
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/henrygd/beszel/internal/entities/container"
|
||||
"github.com/henrygd/beszel/internal/entities/probe"
|
||||
"github.com/henrygd/beszel/internal/entities/systemd"
|
||||
)
|
||||
|
||||
@@ -174,9 +175,10 @@ type Details struct {
|
||||
|
||||
// Final data structure to return to the hub
|
||||
type CombinedData struct {
|
||||
Stats Stats `json:"stats" cbor:"0,keyasint"`
|
||||
Info Info `json:"info" cbor:"1,keyasint"`
|
||||
Containers []*container.Stats `json:"container" cbor:"2,keyasint"`
|
||||
SystemdServices []*systemd.Service `json:"systemd,omitempty" cbor:"3,keyasint,omitempty"`
|
||||
Details *Details `cbor:"4,keyasint,omitempty"`
|
||||
Stats Stats `json:"stats" cbor:"0,keyasint"`
|
||||
Info Info `json:"info" cbor:"1,keyasint"`
|
||||
Containers []*container.Stats `json:"container" cbor:"2,keyasint"`
|
||||
SystemdServices []*systemd.Service `json:"systemd,omitempty" cbor:"3,keyasint,omitempty"`
|
||||
Details *Details `cbor:"4,keyasint,omitempty"`
|
||||
Probes map[string]probe.Result `cbor:"5,keyasint,omitempty"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user