trace
This commit is contained in:
@@ -5,13 +5,16 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/go-resty/resty/v2"
|
||||
"github.com/gorilla/mux"
|
||||
|
||||
"ems.agt/lib/dborm"
|
||||
"ems.agt/lib/global"
|
||||
"ems.agt/lib/log"
|
||||
"ems.agt/lib/run"
|
||||
"ems.agt/lib/services"
|
||||
"ems.agt/restagent/config"
|
||||
)
|
||||
@@ -19,6 +22,8 @@ import (
|
||||
var (
|
||||
UriTraceTaskV1 = config.DefaultUriPrefix + "/traceManagement/v1/subscriptions"
|
||||
UriTraceTask = config.DefaultUriPrefix + "/traceManagement/{apiVersion}/subscriptions"
|
||||
UriTraceRawMsg = config.DefaultUriPrefix + "/traceManagement/{apiVersion}/rawMessage/{id}"
|
||||
UriTraceDecMsg = config.DefaultUriPrefix + "/traceManagement/{apiVersion}/decMessage/{id}"
|
||||
|
||||
CustomUriTraceTaskV1 = config.UriPrefix + "/traceManagement/v1/subscriptions"
|
||||
CustomUriTraceTask = config.UriPrefix + "/traceManagement/{apiVersion}/subscriptions"
|
||||
@@ -373,5 +378,36 @@ func DeleteTraceTaskToNF(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
services.ResponseStatusOK204NoContent(w)
|
||||
return
|
||||
}
|
||||
|
||||
func GetRawMessage(w http.ResponseWriter, r *http.Request) {
|
||||
log.Debug("GetRawMessage processing... ")
|
||||
|
||||
}
|
||||
|
||||
func ParseRawMsg2Html(w http.ResponseWriter, r *http.Request) {
|
||||
log.Debug("ParseRawMsg2Html processing... ")
|
||||
|
||||
vars := mux.Vars(r)
|
||||
idStr := vars["id"]
|
||||
id, _ := strconv.Atoi(idStr)
|
||||
|
||||
traceData, err := dborm.XormGetTraceData(id)
|
||||
if err != nil {
|
||||
log.Error("Failed to dborm.XormGetTraceRawMsg:", err)
|
||||
services.ResponseInternalServerError500ProcessError(w, err)
|
||||
return
|
||||
}
|
||||
log.Trace("traceData:", traceData)
|
||||
htmlFile := fmt.Sprintf("traceDecMessage-%d-%d.html", traceData.TaskID, traceData.ID)
|
||||
pathFile := config.GetYamlConfig().OMC.FrontTraceDir + "/" + htmlFile
|
||||
command := fmt.Sprintf("ipdata2html -f %s -t %d -i N%d -d %x", pathFile, traceData.Timestamp, traceData.IfType, traceData.RawMsg)
|
||||
out, err := run.ExecCmd(command, "/")
|
||||
log.Tracef("Exec output: %v", string(out))
|
||||
if err != nil {
|
||||
log.Errorf("Faile to ipdate2html:", err)
|
||||
services.ResponseInternalServerError500ProcessError(w, err)
|
||||
return
|
||||
}
|
||||
services.ResponseStatusOK204NoContent(w)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user