71 lines
2.0 KiB
Go
71 lines
2.0 KiB
Go
package main
|
|
|
|
// import (
|
|
// "cmii-uav-watchdog-agent/host_info"
|
|
// "cmii-uav-watchdog-common/wdd_log"
|
|
// "net/http"
|
|
// "os"
|
|
// "os/signal"
|
|
// "syscall"
|
|
|
|
// "github.com/gin-gonic/gin"
|
|
// )
|
|
|
|
// func StartHostInfoGin() {
|
|
// // 创建一个默认的 Gin 路由
|
|
// var r = gin.Default() // 定义一个 GET 路由
|
|
// r.GET("/ping", func(c *gin.Context) {
|
|
// c.JSON(http.StatusOK, gin.H{"message": "pong"})
|
|
// })
|
|
|
|
// // 定义一个 POST 路由
|
|
// r.POST("/echo", func(c *gin.Context) {
|
|
// var json map[string]interface{}
|
|
// if err := c.ShouldBindJSON(&json); err == nil {
|
|
// c.JSON(http.StatusOK, json)
|
|
// } else {
|
|
// c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
|
// }
|
|
// })
|
|
|
|
// r.GET("/cpu", func(c *gin.Context) {
|
|
// cpuInfo := host_info.GetCPUInfo() // 直接返回 CPU 信息
|
|
// c.JSON(http.StatusOK, cpuInfo)
|
|
// })
|
|
|
|
// r.GET("/memory", func(c *gin.Context) {
|
|
// memInfo := host_info.GetMemoryInfo() // 直接返回内存信息
|
|
// c.JSON(http.StatusOK, memInfo)
|
|
// })
|
|
|
|
// r.GET("/disk", func(c *gin.Context) {
|
|
// diskInfo := host_info.GetDiskInfo() // 直接返回磁盘信息
|
|
// c.JSON(http.StatusOK, diskInfo)
|
|
// })
|
|
|
|
// r.GET("/motherboard", func(c *gin.Context) {
|
|
// mbInfo := host_info.GetMotherboardInfo() // 直接返回主板信息
|
|
// c.JSON(http.StatusOK, mbInfo)
|
|
// })
|
|
|
|
// r.GET("/network", func(c *gin.Context) {
|
|
// networkInterfaces := host_info.GetNetworkInterfaces()
|
|
// c.JSON(http.StatusOK, networkInterfaces)
|
|
// })
|
|
// r.GET("/all", func(c *gin.Context) {
|
|
// allInfo := host_info.GetAllInfo()
|
|
// c.JSON(http.StatusOK, allInfo)
|
|
// })
|
|
// //r.GET("/phy", func(c *gin.Context) {
|
|
// // allInfo, _ := services.GetPVForLV()
|
|
// // c.JSON(http.StatusOK, allInfo)
|
|
// //})
|
|
// // 启动服务,监听在 8080 端口
|
|
// r.Run(":8098")
|
|
// // 等待终止信号
|
|
// sigs := make(chan os.Signal, 1)
|
|
// signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
|
|
// <-sigs
|
|
// wdd_log.Info("正在关闭服务...")
|
|
// }
|