fix RRD implementation on network troughput
This commit is contained in:
@@ -3,6 +3,7 @@ package system
|
||||
import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/atlasos/calypso/internal/common/logger"
|
||||
"github.com/atlasos/calypso/internal/tasks"
|
||||
@@ -233,3 +234,22 @@ func (h *Handler) GetSystemLogs(c *gin.Context) {
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{"logs": logs})
|
||||
}
|
||||
|
||||
// GetNetworkThroughput retrieves network throughput data from RRD
|
||||
func (h *Handler) GetNetworkThroughput(c *gin.Context) {
|
||||
// Default to last 5 minutes
|
||||
durationStr := c.DefaultQuery("duration", "5m")
|
||||
duration, err := time.ParseDuration(durationStr)
|
||||
if err != nil {
|
||||
duration = 5 * time.Minute
|
||||
}
|
||||
|
||||
data, err := h.service.GetNetworkThroughput(c.Request.Context(), duration)
|
||||
if err != nil {
|
||||
h.logger.Error("Failed to get network throughput", "error", err)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": "failed to get network throughput"})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{"data": data})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user