From 483f5b760429d0fa2bf29a656e78843b596b6e53 Mon Sep 17 00:00:00 2001
From: "meilin.huang" <954537473@qq.com>
Date: Thu, 5 May 2022 21:26:55 +0800
Subject: [PATCH] =?UTF-8?q?fix:=20shell=E8=84=9A=E6=9C=AC=E6=96=87?=
=?UTF-8?q?=E4=BB=B6=E7=94=A8=E5=AD=97=E7=AC=A6=E4=B8=B2=E6=9B=BF=E6=8D=A2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.gitignore | 3 +
mayfly_go_web/package.json | 2 +-
.../src/views/ops/machine/MachineList.vue | 4 +-
.../src/views/ops/machine/MachineStats.vue | 8 +-
mayfly_go_web/yarn.lock | 2 +-
server/devops/infrastructure/machine/shell.go | 69 +++---------
.../infrastructure/machine/shell/monitor.sh | 14 ---
.../infrastructure/machine/shell/stats.sh | 15 ---
server/devops/infrastructure/machine/stats.go | 2 +-
.../devops/infrastructure/machine/status.go | 105 ------------------
10 files changed, 29 insertions(+), 195 deletions(-)
delete mode 100644 server/devops/infrastructure/machine/shell/monitor.sh
delete mode 100644 server/devops/infrastructure/machine/shell/stats.sh
delete mode 100644 server/devops/infrastructure/machine/status.go
diff --git a/.gitignore b/.gitignore
index c6f25b13..3b2b2a10 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,5 +11,8 @@
# Output of the go coverage tool, specifically when used with LiteIDE
*.out
+*.lock
+*.sum
+
*/node_modules/
**/vendor/
\ No newline at end of file
diff --git a/mayfly_go_web/package.json b/mayfly_go_web/package.json
index 551dd398..a6cf653b 100644
--- a/mayfly_go_web/package.json
+++ b/mayfly_go_web/package.json
@@ -12,7 +12,7 @@
"countup.js": "^2.0.7",
"cropperjs": "^1.5.11",
"echarts": "^5.3.2",
- "element-plus": "^2.1.10",
+ "element-plus": "^2.1.11",
"@element-plus/icons-vue": "^1.1.3",
"jsonlint": "^1.6.3",
"lodash": "^4.17.21",
diff --git a/mayfly_go_web/src/views/ops/machine/MachineList.vue b/mayfly_go_web/src/views/ops/machine/MachineList.vue
index 4f1cfe6a..8ed8a38f 100644
--- a/mayfly_go_web/src/views/ops/machine/MachineList.vue
+++ b/mayfly_go_web/src/views/ops/machine/MachineList.vue
@@ -50,7 +50,7 @@
-
+
{{
@@ -58,7 +58,7 @@
}}
-
+
-
+
-
+
@@ -23,11 +23,11 @@
-
+
-
+
diff --git a/mayfly_go_web/yarn.lock b/mayfly_go_web/yarn.lock
index a8b05e7d..9a26b6a0 100644
--- a/mayfly_go_web/yarn.lock
+++ b/mayfly_go_web/yarn.lock
@@ -613,7 +613,7 @@ echarts@^5.3.2:
tslib "2.3.0"
zrender "5.3.1"
-element-plus@^2.1.10:
+element-plus@^2.1.11:
version "2.1.11"
resolved "https://registry.npmmirror.com/element-plus/-/element-plus-2.1.11.tgz#6c1be29f5d78ea78720e0dda519960fd0c7d8fde"
integrity sha512-s4X0I8s787tv+9UdekBC1g7v42Fj4bucPAmu03EjbgrGrV7BJvkoBGuK52lNfu4yC76bl6Uyjesd5Fu8CMakSw==
diff --git a/server/devops/infrastructure/machine/shell.go b/server/devops/infrastructure/machine/shell.go
index 67af54c1..d8a069c2 100644
--- a/server/devops/infrastructure/machine/shell.go
+++ b/server/devops/infrastructure/machine/shell.go
@@ -1,54 +1,19 @@
package machine
-import (
- "io/ioutil"
- "mayfly-go/base/biz"
-)
-
-const BasePath = "./devops/infrastructure/machine/shell/"
-
-// const MonitorTemp = "cpuRate:{cpuRate}%,memRate:{memRate}%,sysLoad:{sysLoad}\n"
-
-// shell文件内容缓存,避免每次读取文件
-var shellCache = make(map[string]string)
-
-// func (c *Cli) GetProcessByName(name string) (*string, error) {
-// return c.Run(getShellContent("sys_info"))
-// }
-
-// func (c *Cli) GetSystemInfo() (*string, error) {
-// return c.Run(getShellContent("system_info"))
-// }
-
-// func (c *Cli) GetMonitorInfo() *entity.MachineMonitor {
-// mm := new(entity.MachineMonitor)
-// res, _ := c.Run(getShellContent("monitor"))
-// if res == nil {
-// return nil
-// }
-// resMap := make(map[string]interface{})
-// utils.ReverStrTemplate(MonitorTemp, *res, resMap)
-
-// err := utils.Map2Struct(resMap, mm)
-// if err != nil {
-// global.Log.Error("解析machine monitor: %s", err.Error())
-// return nil
-// }
-// mm.MachineId = c.machine.Id
-// mm.CreateTime = time.Now()
-// return mm
-// }
-
-// 获取shell内容
-func getShellContent(name string) string {
- cacheShell := shellCache[name]
- if cacheShell != "" {
- return cacheShell
- }
-
- bytes, err := ioutil.ReadFile(BasePath + name + ".sh")
- biz.ErrIsNil(err, "获取shell文件失败")
- shellStr := string(bytes)
- shellCache[name] = shellStr
- return shellStr
-}
+const StatsShell = `
+cat /proc/uptime
+echo '-----'
+/bin/hostname -f
+echo '-----'
+cat /proc/loadavg
+echo '-----'
+cat /proc/meminfo
+echo '-----'
+df -B1
+echo '-----'
+/sbin/ip -o addr
+echo '-----'
+/bin/cat /proc/net/dev
+echo '-----'
+top -b -n 1 | grep Cpu
+`
diff --git a/server/devops/infrastructure/machine/shell/monitor.sh b/server/devops/infrastructure/machine/shell/monitor.sh
deleted file mode 100644
index 0b62ac14..00000000
--- a/server/devops/infrastructure/machine/shell/monitor.sh
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-# 获取监控信息
-function get_monitor_info() {
- cpu_rate=$(cat /proc/stat | awk '/cpu/{printf("%.2f%\n"), ($2+$4)*100/($2+$4+$5)}' | awk '{print $0}' | head -1)
- mem_rate=$(free -m | sed -n '2p' | awk '{print""($3/$2)*100"%"}')
- sys_load=$(uptime | cut -d: -f5)
- cat <