diff --git a/route/periodical.go b/route/periodical.go index d06c8b4..9ffd5f6 100644 --- a/route/periodical.go +++ b/route/periodical.go @@ -2,7 +2,7 @@ * @Author: LinkLeong link@icewhale.com * @Date: 2022-05-27 15:55:36 * @LastEditors: LinkLeong - * @LastEditTime: 2022-06-29 15:01:29 + * @LastEditTime: 2022-06-29 16:47:19 * @FilePath: /CasaOS/route/periodical.go * @Description: * @Website: https://www.casaos.io @@ -99,13 +99,13 @@ func SendDiskBySocket() { if list[i].Tran == "sata" || list[i].Tran == "nvme" || list[i].Tran == "spi" || list[i].Tran == "sas" || strings.Contains(list[i].SubSystems, "virtio") || (list[i].Tran == "ata" && list[i].Type == "disk") { temp := service.MyService.Disk().SmartCTL(list[i].Path) if reflect.DeepEqual(temp, model.SmartctlA{}) { - continue + healthy = true + } else { + healthy = temp.SmartStatus.Passed } //list[i].Temperature = temp.Temperature.Current - if !temp.SmartStatus.Passed { - healthy = false - } + if len(list[i].Children) > 0 { for _, v := range list[i].Children { s, _ := strconv.ParseUint(v.FSSize, 10, 64) @@ -222,12 +222,9 @@ func SendAllHardwareStatusBySocket() { if list[i].Tran == "sata" || list[i].Tran == "nvme" || list[i].Tran == "spi" || list[i].Tran == "sas" || strings.Contains(list[i].SubSystems, "virtio") || (list[i].Tran == "ata" && list[i].Type == "disk") { temp := service.MyService.Disk().SmartCTL(list[i].Path) if reflect.DeepEqual(temp, model.SmartctlA{}) { - continue - } - - //list[i].Temperature = temp.Temperature.Current - if !temp.SmartStatus.Passed { - healthy = false + healthy = true + } else { + healthy = temp.SmartStatus.Passed } if len(list[i].Children) > 0 { for _, v := range list[i].Children { diff --git a/route/v1/system.go b/route/v1/system.go index 62c9b31..4b57278 100644 --- a/route/v1/system.go +++ b/route/v1/system.go @@ -14,6 +14,7 @@ import ( "github.com/IceWhaleTech/CasaOS/model" "github.com/IceWhaleTech/CasaOS/pkg/config" "github.com/IceWhaleTech/CasaOS/pkg/utils/common_err" + "github.com/IceWhaleTech/CasaOS/pkg/utils/loger" port2 "github.com/IceWhaleTech/CasaOS/pkg/utils/port" "github.com/IceWhaleTech/CasaOS/pkg/utils/version" "github.com/IceWhaleTech/CasaOS/service" @@ -21,6 +22,7 @@ import ( "github.com/IceWhaleTech/CasaOS/types" "github.com/gin-gonic/gin" uuid "github.com/satori/go.uuid" + "go.uber.org/zap" ) // @Summary check version @@ -344,6 +346,8 @@ func GetSystemUtilization(c *gin.Context) { s, _ := strconv.ParseUint(v.FSSize, 10, 64) a, _ := strconv.ParseUint(v.FSAvail, 10, 64) u, _ := strconv.ParseUint(v.FSUsed, 10, 64) + loger.Info("disk info", zap.Any("/ total:", s)) + loger.Info("disk path", zap.Any("path", v.Path)) summary.Size += s summary.Avail += a summary.Used += u @@ -356,6 +360,8 @@ func GetSystemUtilization(c *gin.Context) { s, _ := strconv.ParseUint(list[i].Children[j].FSSize, 10, 64) a, _ := strconv.ParseUint(list[i].Children[j].FSAvail, 10, 64) u, _ := strconv.ParseUint(list[i].Children[j].FSUsed, 10, 64) + loger.Info("disk info", zap.Any("/ total:", s)) + loger.Info("disk path", zap.Any("path", list[i].Path)) summary.Size += s summary.Avail += a summary.Used += u @@ -373,18 +379,17 @@ func GetSystemUtilization(c *gin.Context) { if list[i].Tran == "sata" || list[i].Tran == "nvme" || list[i].Tran == "spi" || list[i].Tran == "sas" || strings.Contains(list[i].SubSystems, "virtio") || (list[i].Tran == "ata" && list[i].Type == "disk") { temp := service.MyService.Disk().SmartCTL(list[i].Path) if reflect.DeepEqual(temp, model.SmartctlA{}) { - continue - } - - //list[i].Temperature = temp.Temperature.Current - if !temp.SmartStatus.Passed { - healthy = false + healthy = true + } else { + healthy = temp.SmartStatus.Passed } if len(list[i].Children) > 0 { for _, v := range list[i].Children { s, _ := strconv.ParseUint(v.FSSize, 10, 64) a, _ := strconv.ParseUint(v.FSAvail, 10, 64) u, _ := strconv.ParseUint(v.FSUsed, 10, 64) + loger.Info("disk info", zap.Any("/ total:", s)) + loger.Info("disk path", zap.Any("path", list[i].Path)) summary.Size += s summary.Avail += a summary.Used += u diff --git a/shell/assist.sh b/shell/assist.sh index 8ffde33..d3c1855 100644 --- a/shell/assist.sh +++ b/shell/assist.sh @@ -3,48 +3,21 @@ # @Author: LinkLeong link@icewhale.com # @Date: 2022-02-17 18:53:29 # @LastEditors: LinkLeong - # @LastEditTime: 2022-06-27 14:14:26 + # @LastEditTime: 2022-06-29 16:39:22 # @FilePath: /CasaOS/shell/assist.sh # @Description: # @Website: https://www.casaos.io # Copyright (c) 2022 by icewhale, All Rights Reserved. ### - - -# add in v0.2.5 - -readonly CASA_DEPANDS="curl smartmontools parted fdisk ntfs-3g" - -version_0_2_5() { - install_depends "$CASA_DEPANDS" -} version_0_2_11() { sysctl -w net.core.rmem_max=2500000 } -#Install Depends -install_depends() { - ((EUID)) && sudo_cmd="sudo" - if [[ ! -x "$(command -v '$1')" ]]; then - packagesNeeded=$1 - if [ -x "$(command -v apk)" ]; then - $sudo_cmd apk add --no-cache $packagesNeeded - elif [ -x "$(command -v apt-get)" ]; then - $sudo_cmd apt-get -y -q install $packagesNeeded - elif [ -x "$(command -v dnf)" ]; then - $sudo_cmd dnf install $packagesNeeded - elif [ -x "$(command -v zypper)" ]; then - $sudo_cmd zypper install $packagesNeeded - fi - fi -} - -mvfoder() { +mvfoder_version_0_3_3() { #移动脚本 } -version_0_2_5 - version_0_2_11 +mvfoder_version_0_3_3 \ No newline at end of file diff --git a/shell/tools.sh b/shell/tools.sh index 8ce62d6..f3784ad 100644 --- a/shell/tools.sh +++ b/shell/tools.sh @@ -3,7 +3,7 @@ # @Author: LinkLeong link@icewhale.com # @Date: 2021-12-06 17:12:32 # @LastEditors: LinkLeong - # @LastEditTime: 2022-06-27 14:23:15 + # @LastEditTime: 2022-06-29 16:37:38 # @FilePath: /CasaOS/shell/tools.sh # @Description: # @Website: https://www.casaos.io @@ -27,6 +27,6 @@ run_external_script() { } update() { - curl -fsSL https://get.icewhale.io/casaos.sh | bash + curl -fsSL https://get.icewhale.io | bash run_external_script } \ No newline at end of file