This commit is contained in:
2023-08-18 14:10:34 +08:00
parent 6e3408bb5f
commit 19f973c115

View File

@@ -329,51 +329,6 @@ func (t *TaskFunc) TaskRunShellCommand(uri, params, body string) {
log.Trace("output:", output)
}
func (t *TaskFunc) TaskRunShellCommand(uri, params, body string) {
log.Debug("TaskRunShellCommand processing... ")
cmd := exec.Command("/bin/bash", "-c", command)
out, err := cmd.CombinedOutput()
log.Tracef("Exec output: %v", string(out))
if err != nil {
log.Error("exe cmd error: ", err)
str := fmt.Sprintf("Command: %s output:\n\n%v\n", command, string(out))
//output = *ParseErrorOutput(err)
output = []byte(str)
//return &output
} else {
str := fmt.Sprintf("Command: %s output:\n\n%v\n", command, string(out))
output = []byte(str)
}
var response *resty.Response
tableName := t.GetTableNameFromUri(uri)
filePath := fmt.Sprintf("%s/%s-%s.csv", GetYamlConfig().Database.Backup, tableName, time.Now().Local().Format(global.DateData))
pa := fmt.Sprintf(params, filePath)
requestURI := fmt.Sprintf("%s?%s", uri, pa)
requestURL := fmt.Sprintf("%s%s", yamlConfig.OMC.HostUri, requestURI)
log.Debug("requestURL: Get ", requestURL)
client := resty.New()
response, err := client.R().
EnableTrace().
SetHeaders(map[string]string{"User-Agent": GetDefaultUserAgent()}).
SetHeaders(map[string]string{"Content-Type": "application/json;charset=UTF-8"}).
Get(requestURL)
if err != nil {
log.Error("Failed to Get:", err)
}
log.Debug("StatusCode: ", response.StatusCode())
switch response.StatusCode() {
case http.StatusOK, http.StatusCreated, http.StatusNoContent, http.StatusAccepted:
log.Debug("response body:", string(response.Body()))
body := new(map[string]interface{})
_ = json.Unmarshal(response.Body(), &body)
default:
log.Error("response body:", string(response.Body()))
}
}
type CpuUsage struct {
NfCpuUsage uint16 `json:"nfCpuUsage"`
SysCpuUsage uint16 `json:"sysCpuUsage"`