[ Status ] optimize the code
This commit is contained in:
@@ -5,7 +5,7 @@ import "testing"
|
||||
func TestReadTimeOutput(t *testing.T) {
|
||||
strings := []string{
|
||||
"/bin/bash",
|
||||
"/root/simple.sh",
|
||||
"/root/IdeaProjects/ProjectOctopus/agent-go/tmp/simple.sh",
|
||||
}
|
||||
|
||||
ReadTimeCommandExecutor(strings)
|
||||
|
||||
@@ -9,7 +9,6 @@ require (
|
||||
github.com/spf13/viper v1.15.0
|
||||
github.com/streadway/amqp v1.0.0
|
||||
go.uber.org/zap v1.24.0
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
)
|
||||
|
||||
require (
|
||||
@@ -58,4 +57,5 @@ require (
|
||||
google.golang.org/protobuf v1.28.1 // indirect
|
||||
gopkg.in/ini.v1 v1.67.0 // indirect
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
|
||||
@@ -118,12 +118,18 @@ func executorOMHandler(octopusMessage *OctopusMessage) {
|
||||
|
||||
func statusOMHandler(octopusMessage *OctopusMessage) {
|
||||
|
||||
v, ok := (octopusMessage.Content).(string)
|
||||
if !ok {
|
||||
log.ErrorF("convert to string is wrong %s", v)
|
||||
}
|
||||
|
||||
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))
|
||||
fmt.Println(err.Error())
|
||||
log.Error(fmt.Sprintf("status message convert to json is wrong! msg is => %s", octopusMessage))
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -46,4 +46,5 @@ func GetCPUStatus() (*CPUStatus, error) {
|
||||
CPULoads: cpuLoads,
|
||||
SystemLoads: systemLoads,
|
||||
}, nil
|
||||
|
||||
}
|
||||
|
||||
7
agent-go/tmp/1.sh
Normal file
7
agent-go/tmp/1.sh
Normal file
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
|
||||
export http_proxy=http://10.250.0.10:10810 && export https_proxy=http://10.250.0.10:10810
|
||||
|
||||
|
||||
7
agent-go/tmp/simple.sh
Executable file
7
agent-go/tmp/simple.sh
Executable file
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
for i in {1..30}
|
||||
do
|
||||
echo "yes"
|
||||
sleep 0.3
|
||||
done
|
||||
Reference in New Issue
Block a user