dd
This commit is contained in:
@@ -138,7 +138,14 @@ tasks:
|
|||||||
interval: 5
|
interval: 5
|
||||||
unit: Seconds
|
unit: Seconds
|
||||||
at:
|
at:
|
||||||
do: TaskWriteSystemLog
|
do: TaskWriteSystemLog
|
||||||
|
- name: Copy log to /opt/omc/ftp/log
|
||||||
|
uri:
|
||||||
|
params: cp -rf /usr/local/omc/database/*.csv /opt/omc/ftp/log
|
||||||
|
interval: 10
|
||||||
|
unit: Minutes
|
||||||
|
at:
|
||||||
|
do: TaskRunShellCommand
|
||||||
# - name: Import CM to NF
|
# - name: Import CM to NF
|
||||||
# uri: /api/rest/systemManagement/v1/elementType/udm/objectType/cm
|
# uri: /api/rest/systemManagement/v1/elementType/udm/objectType/cm
|
||||||
# params: ne_id=SZ_01
|
# params: ne_id=SZ_01
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import (
|
|||||||
"mime/multipart"
|
"mime/multipart"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
"os/exec"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@@ -305,6 +306,74 @@ func (t *TaskFunc) TaskDBBackupCSVGetBySQL(uri, params, body string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t *TaskFunc) TaskRunShellCommand(uri, params, body string) {
|
||||||
|
log.Debug("TaskUpdateTable processing... ")
|
||||||
|
|
||||||
|
var output []byte
|
||||||
|
var str string
|
||||||
|
cmd := exec.Command("/bin/bash", "-c", params)
|
||||||
|
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", params, string(out))
|
||||||
|
//output = *ParseErrorOutput(err)
|
||||||
|
output = []byte(str)
|
||||||
|
//return &output
|
||||||
|
} else {
|
||||||
|
str := fmt.Sprintf("Command: %s output:\n\n%v\n", params, string(out))
|
||||||
|
output = []byte(str)
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Trace("str: ", str)
|
||||||
|
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 {
|
type CpuUsage struct {
|
||||||
NfCpuUsage uint16 `json:"nfCpuUsage"`
|
NfCpuUsage uint16 `json:"nfCpuUsage"`
|
||||||
SysCpuUsage uint16 `json:"sysCpuUsage"`
|
SysCpuUsage uint16 `json:"sysCpuUsage"`
|
||||||
|
|||||||
@@ -36,9 +36,9 @@ type MMLRequest struct {
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
// MML interface
|
// MML interface
|
||||||
UriMML = config.DefaultUriPrefix + "/opeartionManagement/{apiVersion}/elementType/{elementTypeValue}/objectType/mml"
|
UriMML = config.DefaultUriPrefix + "/{managementModule}/{apiVersion}/elementType/{elementTypeValue}/objectType/mml"
|
||||||
UriNeOmMml = config.DefaultUriPrefix + "/omManagement/{apiVersion}/mml/{netype}/{neid}"
|
UriNeOmMml = config.DefaultUriPrefix + "/omManagement/{apiVersion}/mml/{netype}/{neid}"
|
||||||
UriOmMmlExt = config.DefaultUriPrefix + "/opeartionManagement/{apiVersion}/elementType/OMC/objectType/mml"
|
UriOmMmlExt = config.DefaultUriPrefix + "/{managementModule}/{apiVersion}/elementType/OMC/objectType/mml"
|
||||||
UriOmMmlInt = config.DefaultUriPrefix + "/omManagement/{apiVersion}/mml/{neType}/{neId}"
|
UriOmMmlInt = config.DefaultUriPrefix + "/omManagement/{apiVersion}/mml/{neType}/{neId}"
|
||||||
|
|
||||||
CustomUriMML = config.UriPrefix + "/opeartionManagement/{apiVersion}/elementType/{elementTypeValue}/objectType/mml"
|
CustomUriMML = config.UriPrefix + "/opeartionManagement/{apiVersion}/elementType/{elementTypeValue}/objectType/mml"
|
||||||
|
|||||||
Reference in New Issue
Block a user