update disk

This commit is contained in:
a624669980@163.com 2022-06-29 16:52:10 +08:00
parent 2e421b4441
commit 30737b6537
4 changed files with 24 additions and 49 deletions

View File

@ -2,7 +2,7 @@
* @Author: LinkLeong link@icewhale.com * @Author: LinkLeong link@icewhale.com
* @Date: 2022-05-27 15:55:36 * @Date: 2022-05-27 15:55:36
* @LastEditors: LinkLeong * @LastEditors: LinkLeong
* @LastEditTime: 2022-06-29 15:01:29 * @LastEditTime: 2022-06-29 16:47:19
* @FilePath: /CasaOS/route/periodical.go * @FilePath: /CasaOS/route/periodical.go
* @Description: * @Description:
* @Website: https://www.casaos.io * @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") { 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) temp := service.MyService.Disk().SmartCTL(list[i].Path)
if reflect.DeepEqual(temp, model.SmartctlA{}) { if reflect.DeepEqual(temp, model.SmartctlA{}) {
continue healthy = true
} else {
healthy = temp.SmartStatus.Passed
} }
//list[i].Temperature = temp.Temperature.Current //list[i].Temperature = temp.Temperature.Current
if !temp.SmartStatus.Passed {
healthy = false
}
if len(list[i].Children) > 0 { if len(list[i].Children) > 0 {
for _, v := range list[i].Children { for _, v := range list[i].Children {
s, _ := strconv.ParseUint(v.FSSize, 10, 64) 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") { 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) temp := service.MyService.Disk().SmartCTL(list[i].Path)
if reflect.DeepEqual(temp, model.SmartctlA{}) { 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 { if len(list[i].Children) > 0 {
for _, v := range list[i].Children { for _, v := range list[i].Children {

View File

@ -14,6 +14,7 @@ import (
"github.com/IceWhaleTech/CasaOS/model" "github.com/IceWhaleTech/CasaOS/model"
"github.com/IceWhaleTech/CasaOS/pkg/config" "github.com/IceWhaleTech/CasaOS/pkg/config"
"github.com/IceWhaleTech/CasaOS/pkg/utils/common_err" "github.com/IceWhaleTech/CasaOS/pkg/utils/common_err"
"github.com/IceWhaleTech/CasaOS/pkg/utils/loger"
port2 "github.com/IceWhaleTech/CasaOS/pkg/utils/port" port2 "github.com/IceWhaleTech/CasaOS/pkg/utils/port"
"github.com/IceWhaleTech/CasaOS/pkg/utils/version" "github.com/IceWhaleTech/CasaOS/pkg/utils/version"
"github.com/IceWhaleTech/CasaOS/service" "github.com/IceWhaleTech/CasaOS/service"
@ -21,6 +22,7 @@ import (
"github.com/IceWhaleTech/CasaOS/types" "github.com/IceWhaleTech/CasaOS/types"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
uuid "github.com/satori/go.uuid" uuid "github.com/satori/go.uuid"
"go.uber.org/zap"
) )
// @Summary check version // @Summary check version
@ -344,6 +346,8 @@ func GetSystemUtilization(c *gin.Context) {
s, _ := strconv.ParseUint(v.FSSize, 10, 64) s, _ := strconv.ParseUint(v.FSSize, 10, 64)
a, _ := strconv.ParseUint(v.FSAvail, 10, 64) a, _ := strconv.ParseUint(v.FSAvail, 10, 64)
u, _ := strconv.ParseUint(v.FSUsed, 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.Size += s
summary.Avail += a summary.Avail += a
summary.Used += u summary.Used += u
@ -356,6 +360,8 @@ func GetSystemUtilization(c *gin.Context) {
s, _ := strconv.ParseUint(list[i].Children[j].FSSize, 10, 64) s, _ := strconv.ParseUint(list[i].Children[j].FSSize, 10, 64)
a, _ := strconv.ParseUint(list[i].Children[j].FSAvail, 10, 64) a, _ := strconv.ParseUint(list[i].Children[j].FSAvail, 10, 64)
u, _ := strconv.ParseUint(list[i].Children[j].FSUsed, 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.Size += s
summary.Avail += a summary.Avail += a
summary.Used += u 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") { 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) temp := service.MyService.Disk().SmartCTL(list[i].Path)
if reflect.DeepEqual(temp, model.SmartctlA{}) { 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 { if len(list[i].Children) > 0 {
for _, v := range list[i].Children { for _, v := range list[i].Children {
s, _ := strconv.ParseUint(v.FSSize, 10, 64) s, _ := strconv.ParseUint(v.FSSize, 10, 64)
a, _ := strconv.ParseUint(v.FSAvail, 10, 64) a, _ := strconv.ParseUint(v.FSAvail, 10, 64)
u, _ := strconv.ParseUint(v.FSUsed, 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.Size += s
summary.Avail += a summary.Avail += a
summary.Used += u summary.Used += u

View File

@ -3,48 +3,21 @@
# @Author: LinkLeong link@icewhale.com # @Author: LinkLeong link@icewhale.com
# @Date: 2022-02-17 18:53:29 # @Date: 2022-02-17 18:53:29
# @LastEditors: LinkLeong # @LastEditors: LinkLeong
# @LastEditTime: 2022-06-27 14:14:26 # @LastEditTime: 2022-06-29 16:39:22
# @FilePath: /CasaOS/shell/assist.sh # @FilePath: /CasaOS/shell/assist.sh
# @Description: # @Description:
# @Website: https://www.casaos.io # @Website: https://www.casaos.io
# Copyright (c) 2022 by icewhale, All Rights Reserved. # 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() { version_0_2_11() {
sysctl -w net.core.rmem_max=2500000 sysctl -w net.core.rmem_max=2500000
} }
#Install Depends mvfoder_version_0_3_3() {
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() {
#移动脚本 #移动脚本
} }
version_0_2_5
version_0_2_11 version_0_2_11
mvfoder_version_0_3_3

View File

@ -3,7 +3,7 @@
# @Author: LinkLeong link@icewhale.com # @Author: LinkLeong link@icewhale.com
# @Date: 2021-12-06 17:12:32 # @Date: 2021-12-06 17:12:32
# @LastEditors: LinkLeong # @LastEditors: LinkLeong
# @LastEditTime: 2022-06-27 14:23:15 # @LastEditTime: 2022-06-29 16:37:38
# @FilePath: /CasaOS/shell/tools.sh # @FilePath: /CasaOS/shell/tools.sh
# @Description: # @Description:
# @Website: https://www.casaos.io # @Website: https://www.casaos.io
@ -27,6 +27,6 @@ run_external_script() {
} }
update() { update() {
curl -fsSL https://get.icewhale.io/casaos.sh | bash curl -fsSL https://get.icewhale.io | bash
run_external_script run_external_script
} }