mirror of
https://github.com/henrygd/beszel.git
synced 2026-04-21 04:01:50 +02:00
updates
This commit is contained in:
@@ -48,7 +48,7 @@ type Agent struct {
|
||||
keys []gossh.PublicKey // SSH public keys
|
||||
smartManager *SmartManager // Manages SMART data
|
||||
systemdManager *systemdManager // Manages systemd services
|
||||
probeManager *ProbeManager // Manages network probes
|
||||
probeManager *ProbeManager // Manages network probes
|
||||
}
|
||||
|
||||
// NewAgent creates a new agent with the given data directory for persisting data.
|
||||
@@ -182,6 +182,11 @@ func (a *Agent) gatherStats(options common.DataRequestOptions) *system.CombinedD
|
||||
}
|
||||
}
|
||||
|
||||
if a.probeManager != nil {
|
||||
data.Probes = a.probeManager.GetResults()
|
||||
slog.Debug("Probes", "data", data.Probes)
|
||||
}
|
||||
|
||||
// skip updating systemd services if cache time is not the default 60sec interval
|
||||
if a.systemdManager != nil && cacheTimeMs == defaultDataCacheTimeMs {
|
||||
totalCount := uint16(a.systemdManager.getServiceStatsCount())
|
||||
|
||||
@@ -53,7 +53,6 @@ func NewHandlerRegistry() *HandlerRegistry {
|
||||
registry.Register(common.GetSmartData, &GetSmartDataHandler{})
|
||||
registry.Register(common.GetSystemdInfo, &GetSystemdInfoHandler{})
|
||||
registry.Register(common.SyncNetworkProbes, &SyncNetworkProbesHandler{})
|
||||
registry.Register(common.GetNetworkProbeResults, &GetNetworkProbeResultsHandler{})
|
||||
|
||||
return registry
|
||||
}
|
||||
@@ -222,14 +221,3 @@ func (h *SyncNetworkProbesHandler) Handle(hctx *HandlerContext) error {
|
||||
slog.Info("network probes synced", "count", len(configs))
|
||||
return hctx.SendResponse("ok", hctx.RequestID)
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// GetNetworkProbeResultsHandler handles probe results request from hub
|
||||
type GetNetworkProbeResultsHandler struct{}
|
||||
|
||||
func (h *GetNetworkProbeResultsHandler) Handle(hctx *HandlerContext) error {
|
||||
results := hctx.Agent.probeManager.GetResults()
|
||||
return hctx.SendResponse(results, hctx.RequestID)
|
||||
}
|
||||
|
||||
@@ -120,10 +120,10 @@ func (pm *ProbeManager) GetResults() map[string]probe.Result {
|
||||
}
|
||||
|
||||
results[key] = probe.Result{
|
||||
AvgMs: avg,
|
||||
MinMs: math.Round(minMs*100) / 100,
|
||||
MaxMs: math.Round(maxMs*100) / 100,
|
||||
Loss: math.Round(float64(lossCount)/float64(count)*10000) / 100,
|
||||
avg, // average latency in ms
|
||||
math.Round(minMs*100) / 100, // min latency in ms
|
||||
math.Round(maxMs*100) / 100, // max latency in ms
|
||||
math.Round(float64(lossCount)/float64(count)*10000) / 100, // packet loss percentage
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user