[agent-go] [status] - test for connect
This commit is contained in:
@@ -3,9 +3,11 @@ package rabbitmq
|
|||||||
import (
|
import (
|
||||||
"agent-go/executor"
|
"agent-go/executor"
|
||||||
"agent-go/g"
|
"agent-go/g"
|
||||||
|
"agent-go/status"
|
||||||
"agent-go/utils"
|
"agent-go/utils"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -105,10 +107,28 @@ func executorOMHandler(octopusMessage *OctopusMessage) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func statusOMHandler(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) {
|
func blackHoleOMHandler(octopusMessage *OctopusMessage) {
|
||||||
|
|||||||
@@ -8,6 +8,19 @@ import (
|
|||||||
|
|
||||||
var log = logger2.Log
|
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 {
|
type AgentStatus struct {
|
||||||
CPUStatus *CPUStatus
|
CPUStatus *CPUStatus
|
||||||
MemoryStatus *MemoryStatus
|
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"
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package io.wdd.rpc.status.beans;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Data
|
||||||
|
public class AgentStatus {
|
||||||
|
|
||||||
|
@JsonProperty("CPUStatus")
|
||||||
|
private CPUInfo cPUStatus;
|
||||||
|
|
||||||
|
@JsonProperty("MemoryStatus")
|
||||||
|
private MemoryInfo memoryStatus;
|
||||||
|
|
||||||
|
@JsonProperty("NetworkStatus")
|
||||||
|
private NetworkInfo networkStatus;
|
||||||
|
|
||||||
|
@JsonProperty("DiskStatus")
|
||||||
|
private DiskInfo diskStatus;
|
||||||
|
|
||||||
|
}
|
||||||
32
server/src/main/java/io/wdd/rpc/status/beans/DiskInfo.java
Normal file
32
server/src/main/java/io/wdd/rpc/status/beans/DiskInfo.java
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
package io.wdd.rpc.status.beans;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Data
|
||||||
|
public class DiskInfo {
|
||||||
|
|
||||||
|
@JsonProperty("Total")
|
||||||
|
private Long total;
|
||||||
|
@JsonProperty("Used")
|
||||||
|
private Long used;
|
||||||
|
@JsonProperty("LogicalDisk")
|
||||||
|
private List<LogicalDiskDTO> logicalDisk;
|
||||||
|
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Data
|
||||||
|
public static class LogicalDiskDTO {
|
||||||
|
@JsonProperty("device")
|
||||||
|
private String device;
|
||||||
|
@JsonProperty("mountpoint")
|
||||||
|
private String mountpoint;
|
||||||
|
@JsonProperty("fstype")
|
||||||
|
private String fstype;
|
||||||
|
@JsonProperty("opts")
|
||||||
|
private List<String> opts;
|
||||||
|
}
|
||||||
|
}
|
||||||
21
server/src/main/java/io/wdd/rpc/status/beans/MemoryInfo.java
Normal file
21
server/src/main/java/io/wdd/rpc/status/beans/MemoryInfo.java
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
package io.wdd.rpc.status.beans;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Data
|
||||||
|
public class MemoryInfo {
|
||||||
|
|
||||||
|
@JsonProperty("TotalMemory")
|
||||||
|
private Long totalMemory;
|
||||||
|
@JsonProperty("UsedMemory")
|
||||||
|
private Long usedMemory;
|
||||||
|
@JsonProperty("AvailableMemory")
|
||||||
|
private Long availableMemory;
|
||||||
|
@JsonProperty("TotalVirtualMemory")
|
||||||
|
private Long totalVirtualMemory;
|
||||||
|
@JsonProperty("UsedVirtualMemory")
|
||||||
|
private Long usedVirtualMemory;
|
||||||
|
}
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
package io.wdd.rpc.status.beans;
|
|
||||||
|
|
||||||
public class AgentStatus {
|
|
||||||
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user