diff --git a/atune/server/go.mod b/atune/server/go.mod index f14ac3807f5486c594c6196a1b6ae601511512d2..b5c65386d0214a4c24df788005d07875ac47c5c2 100644 --- a/atune/server/go.mod +++ b/atune/server/go.mod @@ -3,7 +3,7 @@ module openeuler.org/PilotGo/atune-plugin go 1.18 require ( - gitee.com/openeuler/PilotGo/sdk v0.0.0-20231218035738-e5355d2a2d29 + gitee.com/openeuler/PilotGo/sdk v0.0.0-20231225071221-260195e4ee3e github.com/gin-gonic/gin v1.9.1 gopkg.in/yaml.v2 v2.4.0 gorm.io/driver/mysql v1.5.1 diff --git a/atune/server/go.sum b/atune/server/go.sum index 4356f6d90db42f3ce9c2a26ca3b877983dfa4c60..ac3c66b8dd8ca0f231633513be638079efe071ba 100644 --- a/atune/server/go.sum +++ b/atune/server/go.sum @@ -1,5 +1,9 @@ gitee.com/openeuler/PilotGo/sdk v0.0.0-20231218035738-e5355d2a2d29 h1:8BkdZwuBvt8u+iFClylVWahrDox6n+q1+pf27jd5JNA= gitee.com/openeuler/PilotGo/sdk v0.0.0-20231218035738-e5355d2a2d29/go.mod h1:zEVmY3l48/CvR2kIM3DJpD/jWTG1qkOxRoHJii/D0us= +gitee.com/openeuler/PilotGo/sdk v0.0.0-20231220075944-c00326991801 h1:D7DF8kmhHZoesTGJsbeL9qhIZzQdmnUGOnPhbpo5P70= +gitee.com/openeuler/PilotGo/sdk v0.0.0-20231220075944-c00326991801/go.mod h1:zEVmY3l48/CvR2kIM3DJpD/jWTG1qkOxRoHJii/D0us= +gitee.com/openeuler/PilotGo/sdk v0.0.0-20231225071221-260195e4ee3e h1:UKsQvDsAqPY/Zsgi58wzsLwPikS66e+wH6oeEGGMx80= +gitee.com/openeuler/PilotGo/sdk v0.0.0-20231225071221-260195e4ee3e/go.mod h1:zEVmY3l48/CvR2kIM3DJpD/jWTG1qkOxRoHJii/D0us= github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM= github.com/bytedance/sonic v1.9.1 h1:6iJ6NqdoxCDr6mbY8h18oSO+cShGSMRGCEo7F2h0x8s= github.com/bytedance/sonic v1.9.1/go.mod h1:i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U= diff --git a/atune/server/vendor/gitee.com/openeuler/PilotGo/sdk/common/machine.go b/atune/server/vendor/gitee.com/openeuler/PilotGo/sdk/common/machine.go index e194752e36a0b5f91617f1ccd30217af03534b6c..33ef06057611f73883b1d6b3a94c316664b357b0 100644 --- a/atune/server/vendor/gitee.com/openeuler/PilotGo/sdk/common/machine.go +++ b/atune/server/vendor/gitee.com/openeuler/PilotGo/sdk/common/machine.go @@ -1,12 +1,13 @@ package common type MachineNode struct { - UUID string `json:"uuid"` - Department string `json:"department"` - IP string `json:"ip"` - CPUArch string `json:"cpu_arch"` - OS string `json:"os"` - State int `json:"state"` + UUID string `json:"uuid"` + Department string `json:"department"` + IP string `json:"ip"` + CPUArch string `json:"cpu_arch"` + OS string `json:"os"` + RunStatus string `json:"runstatus"` + MaintStatus string `json:"maintatatus"` } type Batch struct { diff --git a/atune/server/vendor/gitee.com/openeuler/PilotGo/sdk/common/script.go b/atune/server/vendor/gitee.com/openeuler/PilotGo/sdk/common/script.go index 46a53126f12a72aafba7f601879c317f274c17da..f63e6da065d7959106040c1853a0bd583d7b639f 100644 --- a/atune/server/vendor/gitee.com/openeuler/PilotGo/sdk/common/script.go +++ b/atune/server/vendor/gitee.com/openeuler/PilotGo/sdk/common/script.go @@ -2,13 +2,9 @@ package common type AsyncCmdResult struct { TaskID string `json:"task_id"` - Result []*RunResult `json:"result"` + Result []*CmdResult `json:"result"` } -type RunResult struct { - CmdResult CmdResult `json:"cmd_result"` - Error interface{} `json:"error"` -} type CmdResult struct { MachineUUID string `json:"machine_uuid"` MachineIP string `json:"machine_ip"` @@ -20,4 +16,5 @@ type CmdResult struct { type CmdStruct struct { Batch *Batch `json:"batch"` Command string `json:"command"` + CmdType string `json:"cmd_type"` } diff --git a/atune/server/vendor/gitee.com/openeuler/PilotGo/sdk/logger/logger.go b/atune/server/vendor/gitee.com/openeuler/PilotGo/sdk/logger/logger.go index 5423ed3237eea3f560a9bab17abb5a055713cc4b..32cc99bcb895cb2bf7a13cf18539910990e6803d 100644 --- a/atune/server/vendor/gitee.com/openeuler/PilotGo/sdk/logger/logger.go +++ b/atune/server/vendor/gitee.com/openeuler/PilotGo/sdk/logger/logger.go @@ -16,7 +16,6 @@ package logger import ( "errors" - "io" "os" "time" @@ -93,11 +92,6 @@ func Init(conf *LogOpts) error { return nil } -// 不输出日志 -func Discard() { - logrus.SetOutput(io.Discard) -} - func Trace(format string, args ...interface{}) { logrus.Tracef(format, args...) } @@ -149,12 +143,14 @@ func RequestLogger() gin.HandlerFunc { clientIP := c.ClientIP() // 日志格式 - Debug("status_code:%d latency_time:%s client_ip:%s req_method:%s req_uri:%s", - statusCode, - latencyTime, - clientIP, - reqMethod, - reqUri, - ) + if reqUri != "/api/v1/pluginapi/heartbeat" { + Debug("status_code:%d latency_time:%s client_ip:%s req_method:%s req_uri:%s", + statusCode, + latencyTime, + clientIP, + reqMethod, + reqUri, + ) + } } } diff --git a/atune/server/vendor/gitee.com/openeuler/PilotGo/sdk/plugin/client/heartbeat.go b/atune/server/vendor/gitee.com/openeuler/PilotGo/sdk/plugin/client/heartbeat.go index 43aacc4a0f7bb9df812b5f67d4b9c7cb447c4fe4..2c393a19e67c299263a5202fd181f42ff811ee05 100644 --- a/atune/server/vendor/gitee.com/openeuler/PilotGo/sdk/plugin/client/heartbeat.go +++ b/atune/server/vendor/gitee.com/openeuler/PilotGo/sdk/plugin/client/heartbeat.go @@ -10,7 +10,16 @@ import ( "gitee.com/openeuler/PilotGo/sdk/utils/httputils" ) -var HeartbeatInterval = 30 * time.Second +const ( + HeartbeatInterval = 30 * time.Second + HeartbeatKey = "heartbeat:" +) + +// 插件连接状态 +type PluginStatus struct { + Connected bool + LastConnect time.Time +} func (client *Client) SendHeartbeat() { clientID := client.PluginInfo.Url + "+" + client.PluginInfo.Name diff --git a/atune/server/vendor/gitee.com/openeuler/PilotGo/sdk/plugin/client/script.go b/atune/server/vendor/gitee.com/openeuler/PilotGo/sdk/plugin/client/script.go index 1477090acc7a6aa4514b0a0b8f9a785ed431e972..e5fa25985118f7a57593fd144f20b1a5a9d2425b 100644 --- a/atune/server/vendor/gitee.com/openeuler/PilotGo/sdk/plugin/client/script.go +++ b/atune/server/vendor/gitee.com/openeuler/PilotGo/sdk/plugin/client/script.go @@ -13,7 +13,7 @@ type CallbackHandler struct { TaskLen int } -type RunCommandCallback func([]*common.RunResult) +type RunCommandCallback func([]*common.CmdResult) func (c *Client) RunCommand(batch *common.Batch, cmd string) ([]*common.CmdResult, error) { url := "http://" + c.Server() + "/api/v1/pluginapi/run_command"