[agent-go] [status] - test for connect
This commit is contained in:
@@ -3,9 +3,11 @@ package rabbitmq
|
||||
import (
|
||||
"agent-go/executor"
|
||||
"agent-go/g"
|
||||
"agent-go/status"
|
||||
"agent-go/utils"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -105,10 +107,28 @@ func executorOMHandler(octopusMessage *OctopusMessage) {
|
||||
}
|
||||
|
||||
func statusOMHandler(octopusMessage *OctopusMessage) {
|
||||
log.Info("接收到查询Agent状态的请求,假装已经处理")
|
||||
|
||||
//statusMessageString := octopusMessage.Content.(string)
|
||||
statusMsgString := octopusMessage.Content.(string)
|
||||
var statusMessage *status.StatusMessage
|
||||
err := json.Unmarshal([]byte(statusMsgString), &statusMessage)
|
||||
if err != nil {
|
||||
log.Error(fmt.Sprintf("status message convert to json is wrong! msg is => %s", statusMsgString))
|
||||
return
|
||||
}
|
||||
|
||||
var statusRes string
|
||||
if strings.HasPrefix(statusMessage.Type, "p") {
|
||||
// ping info
|
||||
statusRes = status.Ping()
|
||||
} else {
|
||||
// status info
|
||||
agentStatusString, _ := json.Marshal(status.ReportAppStatus())
|
||||
statusRes = string(agentStatusString)
|
||||
}
|
||||
|
||||
// 返回消息
|
||||
|
||||
log.InfoF("接收到查询Agent状态的请求,结果为 => %s", statusRes)
|
||||
}
|
||||
|
||||
func blackHoleOMHandler(octopusMessage *OctopusMessage) {
|
||||
|
||||
@@ -8,6 +8,19 @@ import (
|
||||
|
||||
var log = logger2.Log
|
||||
|
||||
type StatusMessage struct {
|
||||
/**
|
||||
* which kind of status should be return
|
||||
* metric => short time message
|
||||
* all => all agent status message
|
||||
* healthy => check for healthy
|
||||
* */
|
||||
Type string `json:"type,omitempty"`
|
||||
AgentTopicName string `json:"agent_topic_name,omitempty"`
|
||||
MetricRepeatCount int `json:"metric_repeat_count,omitempty"`
|
||||
metricRepeatPinch int `json:"metric_repeat_pinch,omitempty"`
|
||||
}
|
||||
|
||||
type AgentStatus struct {
|
||||
CPUStatus *CPUStatus
|
||||
MemoryStatus *MemoryStatus
|
||||
|
||||
0
agent-go/tmp/status-agentStatus.json
Normal file
0
agent-go/tmp/status-agentStatus.json
Normal file
8
agent-go/tmp/status-ping.json
Normal file
8
agent-go/tmp/status-ping.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"uuid": "2023-03-27 14:38:49",
|
||||
"init_time": "2023-03-27T14:38:49.8162801+08:00",
|
||||
"type": "PING",
|
||||
"content": "ping",
|
||||
"result": "",
|
||||
"ac_time": "0001-01-01T00:00:00Z"
|
||||
}
|
||||
Reference in New Issue
Block a user