fix stats
This commit is contained in:
@@ -1070,3 +1070,38 @@ func Worker_nodes_plan(w http.ResponseWriter, r *http.Request) {
|
|||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
json.NewEncoder(w).Encode(workerNodesPlan)
|
json.NewEncoder(w).Encode(workerNodesPlan)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ClusterStats(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
|
data := models.ClusterStats{
|
||||||
|
ResourceUsage: models.ResourceUsage{
|
||||||
|
CPU: models.Usage{Used: 65, Total: 100, Unit: "cores"},
|
||||||
|
Memory: models.Usage{Used: 8.2, Total: 16, Unit: "GB"},
|
||||||
|
Storage: models.Usage{Used: 45, Total: 100, Unit: "GB"},
|
||||||
|
Network: models.Usage{Used: 2.1, Total: 10, Unit: "Gbps"},
|
||||||
|
},
|
||||||
|
Performance: models.Performance{
|
||||||
|
PodStartupTime: "2.3s",
|
||||||
|
APILatency: "45ms",
|
||||||
|
EtcdLatency: "12ms",
|
||||||
|
SchedulerLatency: "8ms",
|
||||||
|
},
|
||||||
|
Health: models.Health{
|
||||||
|
NodesHealthy: 3,
|
||||||
|
NodesTotal: 3,
|
||||||
|
PodsRunning: 10,
|
||||||
|
PodsTotal: 12,
|
||||||
|
Alerts: 2,
|
||||||
|
Warnings: 1,
|
||||||
|
},
|
||||||
|
Uptime: models.Uptime{
|
||||||
|
ClusterUptime: "15d 8h 32m",
|
||||||
|
LastMaintenance: "3d ago",
|
||||||
|
NextMaintenance: "11d from now",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
w.Header().Set("Content-Type", "application/json")
|
||||||
|
json.NewEncoder(w).Encode(data)
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
1
main.go
1
main.go
@@ -128,6 +128,7 @@ func main() {
|
|||||||
router.HandleFunc("/createcluster", handler.CreateClusterHandler)
|
router.HandleFunc("/createcluster", handler.CreateClusterHandler)
|
||||||
router.HandleFunc("/deletecluster", handler.Deletecluster)
|
router.HandleFunc("/deletecluster", handler.Deletecluster)
|
||||||
router.HandleFunc("/clusters", handler.ListUserClusters)
|
router.HandleFunc("/clusters", handler.ListUserClusters)
|
||||||
|
router.HandleFunc("/cluster/stats", handler.ClusterStats)
|
||||||
router.HandleFunc("/connect", handler.Connect)
|
router.HandleFunc("/connect", handler.Connect)
|
||||||
// router.HandleFunc("/cluster_nodes", handler.Cluster_nodes)
|
// router.HandleFunc("/cluster_nodes", handler.Cluster_nodes)
|
||||||
router.HandleFunc("/cluster_namespaces", handler.Cluster_namespaces)
|
router.HandleFunc("/cluster_namespaces", handler.Cluster_namespaces)
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ type Cluster struct {
|
|||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Namespace string `json:"namespace"`
|
Namespace string `json:"namespace"`
|
||||||
ControlPlane string `json:"controlPlane"`
|
ControlPlane string `json:"controlPlane"`
|
||||||
PlatformVersion string `json:"platformversion`
|
PlatformVersion string `json:"platformversion"`
|
||||||
Cpu string `json:"cpu"`
|
Cpu string `json:"cpu"`
|
||||||
Memory string `json:"memory"`
|
Memory string `json:"memory"`
|
||||||
CreatedAt string `json:"createdAt"`
|
CreatedAt string `json:"createdAt"`
|
||||||
@@ -109,3 +109,45 @@ type WorkerNodesPlans struct {
|
|||||||
Memory string `json:memory`
|
Memory string `json:memory`
|
||||||
Storage string `;sjon:storage`
|
Storage string `;sjon:storage`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ClusterStats struct {
|
||||||
|
ResourceUsage ResourceUsage `json:"resourceUsage"`
|
||||||
|
Performance Performance `json:"performance"`
|
||||||
|
Health Health `json:"health"`
|
||||||
|
Uptime Uptime `json:"uptime"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ResourceUsage struct {
|
||||||
|
CPU Usage `json:"cpu"`
|
||||||
|
Memory Usage `json:"memory"`
|
||||||
|
Storage Usage `json:"storage"`
|
||||||
|
Network Usage `json:"network"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Usage struct {
|
||||||
|
Used float64 `json:"used"`
|
||||||
|
Total float64 `json:"total"`
|
||||||
|
Unit string `json:"unit"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Performance struct {
|
||||||
|
PodStartupTime string `json:"podStartupTime"`
|
||||||
|
APILatency string `json:"apiLatency"`
|
||||||
|
EtcdLatency string `json:"etcdLatency"`
|
||||||
|
SchedulerLatency string `json:"schedulerLatency"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Health struct {
|
||||||
|
NodesHealthy int `json:"nodesHealthy"`
|
||||||
|
NodesTotal int `json:"nodesTotal"`
|
||||||
|
PodsRunning int `json:"podsRunning"`
|
||||||
|
PodsTotal int `json:"podsTotal"`
|
||||||
|
Alerts int `json:"alerts"`
|
||||||
|
Warnings int `json:"warnings"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Uptime struct {
|
||||||
|
ClusterUptime string `json:"clusterUptime"`
|
||||||
|
LastMaintenance string `json:"lastMaintenance"`
|
||||||
|
NextMaintenance string `json:"nextMaintenance"`
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user