增加获取磁盘挂载点接口
This commit is contained in:
parent
21e8e8f1b8
commit
c955afd861
@ -70,7 +70,7 @@ func (a *MonitorApi) GetDiskStateByPath(c *gin.Context) {
|
|||||||
cacheDiskName := global.SystemMonitor_DISK_INFO + req.Path
|
cacheDiskName := global.SystemMonitor_DISK_INFO + req.Path
|
||||||
|
|
||||||
if v, ok := global.SystemMonitor.Get(cacheDiskName); ok {
|
if v, ok := global.SystemMonitor.Get(cacheDiskName); ok {
|
||||||
global.Logger.Debugln("读取缓存的的RAM信息")
|
global.Logger.Debugln("读取缓存的的DISK信息")
|
||||||
apiReturn.SuccessData(c, v)
|
apiReturn.SuccessData(c, v)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -85,3 +85,12 @@ func (a *MonitorApi) GetDiskStateByPath(c *gin.Context) {
|
|||||||
global.SystemMonitor.Set(cacheDiskName, diskState, cacheSecond*time.Second)
|
global.SystemMonitor.Set(cacheDiskName, diskState, cacheSecond*time.Second)
|
||||||
apiReturn.SuccessData(c, diskState)
|
apiReturn.SuccessData(c, diskState)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *MonitorApi) GetDiskMountpoints(c *gin.Context) {
|
||||||
|
if list, err := monitor.GetDiskMountpoints(); err != nil {
|
||||||
|
apiReturn.Error(c, err.Error())
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
apiReturn.SuccessData(c, list)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -97,6 +97,10 @@ func GetDiskInfo() ([]DiskInfo, error) {
|
|||||||
return disks, nil
|
return disks, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetDiskMountpoints() ([]disk.PartitionStat, error) {
|
||||||
|
return disk.Partitions(true)
|
||||||
|
}
|
||||||
|
|
||||||
func GetDiskInfoByPath(path string) (*DiskInfo, error) {
|
func GetDiskInfoByPath(path string) (*DiskInfo, error) {
|
||||||
diskInfo := DiskInfo{}
|
diskInfo := DiskInfo{}
|
||||||
usage, err := disk.Usage(path)
|
usage, err := disk.Usage(path)
|
||||||
|
@ -9,7 +9,8 @@ import (
|
|||||||
|
|
||||||
func InitMonitorRouter(router *gin.RouterGroup) {
|
func InitMonitorRouter(router *gin.RouterGroup) {
|
||||||
api := api_v1.ApiGroupApp.ApiSystem.MonitorApi
|
api := api_v1.ApiGroupApp.ApiSystem.MonitorApi
|
||||||
// r := router.Group("", middleware.LoginInterceptor)
|
r := router.Group("", middleware.LoginInterceptor)
|
||||||
|
r.POST("/system/monitor/getDiskMountpoints", api.GetDiskMountpoints)
|
||||||
|
|
||||||
// 公开模式
|
// 公开模式
|
||||||
rPublic := router.Group("", middleware.PublicModeInterceptor)
|
rPublic := router.Group("", middleware.PublicModeInterceptor)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user