package icsstat import ( "bytes" "fmt" "io" "math/rand" "os" "strings" "sync" "time" "gitlab.com/ics_cinnamon/voiceStatistics/icsconf" "gitlab.com/ics_cinnamon/voiceStatistics/icserror" "gitlab.com/ics_cinnamon/voiceStatistics/icslog" "gitlab.com/ics_cinnamon/voiceStatistics/icsnet" ) type SeqVal struct { Seq string M *sync.Mutex } type Host struct { HostName string M *sync.Mutex } type StatInfos struct { //necessary value SeqId string // 25 LogTime string // 14 LogType string // 3 Sid string // 50 ResultCode string // 8 ReqTime string // 17 RspTime string // 17 ClientIp string // 40 DevInfo string // 5 OsInfo string // 50 NwInfo string // 5 SvcName string // 32 DevModel string // 50 CarrierType string // 1 HostName string // 32 ScnName string // 32 //not necessary CallId string // 60 TrId string // 100 ConcCall string // 5 SvcType string // 20 SvcReqTime string // 17 SvcRspTime string // 17 TransferNo string // 20 CallTime string // 5 CallType string // 10 FunName string // 30 ResultMsg string // 256 SttText string // 8192 TtsText string // 1024 } var gSeqVal *SeqVal var ghost *Host const ( //necessary value STAT_INFO = 0 SEQ_ID = STAT_INFO + 25 LOG_TIME = SEQ_ID + 14 LOG_TYPE = LOG_TIME + 3 SID = LOG_TYPE + 50 RESULT_CODE = SID + 8 REQ_TIME = RESULT_CODE + 17 RES_TIME = REQ_TIME + 17 CLIENT_IP = RES_TIME + 40 DEV_INFO = CLIENT_IP + 5 OS_INFO = DEV_INFO + 50 NW_INFO = OS_INFO + 5 SVC_NAME = NW_INFO + 32 DEV_MODEL = SVC_NAME + 50 CARRIER_TYPE = DEV_MODEL + 1 HOST_NAME = CARRIER_TYPE + 32 SCN_NAME = HOST_NAME + 32 //not necessary CALL_ID = SCN_NAME + 60 TR_ID = CALL_ID + 100 CONC_CALL = TR_ID + 5 SVC_TYPE = CONC_CALL + 20 SVC_REQ_TIME = SVC_TYPE + 17 SVC_RSP_TIME = SVC_REQ_TIME + 17 TRANSFER_NO = SVC_RSP_TIME + 20 CALL_TIME = TRANSFER_NO + 5 CALL_TYPE = CALL_TIME + 10 FUN_NAME = CALL_TYPE + 30 RESULT_MSG = FUN_NAME + 255 STT_TEXT = RESULT_MSG + 8192 TTS_TEXT = STT_TEXT + 1024 ) func ListenStatMNG() (icserr *icserror.IcsError) { // l := icslog.GetIcsLog() conf := icsconf.GetIcsConfig() //start bot-command listen statPort := conf.Target.TargetPort statTransport := conf.Target.Transport statLocalAddrStr := fmt.Sprintf("0.0.0.0:%d", statPort) statLocalAddr := icsnet.NewNetAddrWithIPAddr(statLocalAddrStr) var cmdErr *icserror.IcsError statTCP, cmdErr := icsnet.ListenAndServeTCP(&statLocalAddr, nil, "\r\n", StatsCommandVG) if cmdErr != nil { // l.Printf(icslog.LOG_LEVEL_FATAL, -1, "%s", cmdErr.GetError()) return nil } fmt.Printf("Listening Stat TCP Command %s port[%d]", statTransport, statPort) // l.Printf(icslog.LOG_LEVEL_INFO, -1, "Listening Stat TCP Command %s port[%d]", statTransport, statPort) fmt.Println(statTCP) return nil } func ListenStatMNG1() (icserr *icserror.IcsError) { // l := icslog.GetIcsLog() conf := icsconf.GetIcsConfig() //start bot-command listen statPort := conf.Target1.TargetPort statTransport := conf.Target1.Transport statLocalAddrStr := fmt.Sprintf("0.0.0.0:%d", statPort) statLocalAddr := icsnet.NewNetAddrWithIPAddr(statLocalAddrStr) var cmdErr *icserror.IcsError statTCP, cmdErr := icsnet.ListenAndServeTCP(&statLocalAddr, nil, "\r\n", StatsCommandVA) if cmdErr != nil { // l.Printf(icslog.LOG_LEVEL_FATAL, -1, "%s", cmdErr.GetError()) return nil } fmt.Printf("Listening Stat TCP Command %s port[%d]", statTransport, statPort) // l.Printf(icslog.LOG_LEVEL_INFO, -1, "Listening Stat TCP Command %s port[%d]", statTransport, statPort) fmt.Println(statTCP) return nil } func NewSidVal() { // conf := icsconf.GetIcsConfig() timeN := time.Now() nano := fmt.Sprintf("%d", timeN.UTC().Nanosecond()) seq := fmt.Sprintf("%02d%02d%02d%03s", timeN.Hour(), timeN.Minute(), timeN.Second(), nano[:3]) gSeqVal = &SeqVal{ Seq: seq, } gSeqVal.M = &sync.Mutex{} hostname, err := os.Hostname() if err != nil { fmt.Println(err) os.Exit(1) } ghost = &Host{ HostName: hostname, } ghost.M = &sync.Mutex{} } func GetIcsSid() *SeqVal { return gSeqVal } func StatsCommandVG(t *icsnet.IcsTCPNet, bufend string) { l := icslog.GetIcsLog() statInfos := new(StatInfos) // s := GetIcsSid() rand.Seed(time.Now().UnixNano()) randNum := fmt.Sprintf("%07d", rand.Intn(10000000)) // randNum := fmt.Sprintf("%07d", rand.Intn(9999999)) // defer func() { // if err := recover(); err != nil { // l.Printf(icslog.LOG_LEVEL_WARN, -1, "%s\n", // icserror.ICSERRNETNotConnectError.GetMessage()) // if t != nil { // t.Close() // } // return // } // }() defer t.Close() // l.Printf(icslog.LOG_LEVEL_INFO, -1, "Connected from - %s", t.RemoteAddr()) // for { statReads, rlen, rerr := t.ReadS(10137, bufend) // 여기서 전체 몇 byte씩 읽어서 로그를 찍을건지 알아야함 if rerr != nil { if rerr.GetError() != io.EOF { // l.Printf(icslog.LOG_LEVEL_ERROR, -1, "[Stat Command] ReadS Error! - %s[%d:%d]", // rerr.GetError(), rlen, len(statReads)) return } } else { fmt.Printf("Recved Stat Command(%s) %d \n", statReads, rlen) statInfos.ChangeByteToString(statReads) svc := statInfos.SvcType[0:1] now := fmt.Sprintf("%s", time.Now()) b := now[:23] c := strings.ReplaceAll(b, "-", "") d := strings.ReplaceAll(c, ".", "") e := strings.ReplaceAll(d, " ", "") nowS := strings.ReplaceAll(e, ":", "") seqId := nowS + svc + randNum ghost.M.Lock() hostName := ghost.HostName ghost.M.Unlock() insLog := "" insLog += fmt.Sprintf("SEQ_ID=%s|", seqId) insLog += fmt.Sprintf("LOG_TIME=%s|", statInfos.LogTime) insLog += fmt.Sprintf("LOG_TYPE=%s|", statInfos.LogType) insLog += fmt.Sprintf("SID=%s|", statInfos.Sid) insLog += fmt.Sprintf("RESULT_CODE=%s|", statInfos.ResultCode) insLog += fmt.Sprintf("REQ_TIME=%s|", statInfos.ReqTime) insLog += fmt.Sprintf("RSP_TIME=%s|", statInfos.RspTime) insLog += fmt.Sprintf("CLIENT_IP=%s|", statInfos.ClientIp) insLog += fmt.Sprintf("DEV_INFO=%s|", statInfos.DevInfo) insLog += fmt.Sprintf("OS_INFO=%s|", statInfos.OsInfo) insLog += fmt.Sprintf("NW_INFO=%s|", statInfos.NwInfo) insLog += fmt.Sprintf("SVC_NAME=%s|", statInfos.SvcName) insLog += fmt.Sprintf("DEV_MODEL=%s|", statInfos.DevModel) insLog += fmt.Sprintf("CARRIER_TYPE=%s|", statInfos.CarrierType) insLog += fmt.Sprintf("HOST_NAME=%s|", hostName) insLog += fmt.Sprintf("SCN_NAME=%s|", statInfos.ScnName) insLog += fmt.Sprintf("CALL_ID=%s|", statInfos.CallId) insLog += fmt.Sprintf("TR_ID=%s|", statInfos.TrId) insLog += fmt.Sprintf("CONC_CALL=%s|", statInfos.ConcCall) insLog += fmt.Sprintf("SVC_TYPE=%s|", statInfos.SvcType) insLog += fmt.Sprintf("SVC_REQ_TIME=%s|", statInfos.SvcReqTime) insLog += fmt.Sprintf("SVC_RSP_TIME=%s|", statInfos.SvcRspTime) insLog += fmt.Sprintf("TRANSFER_NO=%s|", statInfos.TransferNo) insLog += fmt.Sprintf("CALL_TIME=%s|", statInfos.CallTime) insLog += fmt.Sprintf("CALL_TYPE=%s|", statInfos.CallType) insLog += fmt.Sprintf("FUN_NAME=%s|", statInfos.FunName) insLog += fmt.Sprintf("RESULT_MSG=%s|", statInfos.ResultMsg) insLog += fmt.Sprintf("STT_TEXT=%s|", statInfos.SttText) insLog += fmt.Sprintf("TTS_TEXT=%s", statInfos.TtsText) l.Printf(icslog.LOG_LEVEL_INFO, -1, "%s", insLog) // fmt.Printf("stats- %s \n", statInfos.SeqId) // fmt.Printf("stats- %s \n", statInfos.LogTime) // fmt.Printf("stats- %s \n", statInfos.LogType) // fmt.Printf("stats- %s \n", statInfos.Sid) // fmt.Printf("stats- %s \n", statInfos.ResultCode) // fmt.Printf("stats- %s \n", statInfos.ReqTime) // fmt.Printf("stats- %s \n", statInfos.RspTime) // fmt.Printf("stats- %s \n", statInfos.ClientIp) // fmt.Printf("stats- %s \n", statInfos.DevInfo) // fmt.Printf("stats- %s \n", statInfos.OsInfo) // fmt.Printf("stats- %s \n", statInfos.NwInfo) // fmt.Printf("stats- %s \n", statInfos.SvcName) // fmt.Printf("stats- %s \n", statInfos.DevModel) // fmt.Printf("stats- %s \n", statInfos.CarrierType) // fmt.Printf("stats- %s \n", statInfos.HostName) // fmt.Printf("stats- %s \n", statInfos.ScnName) // fmt.Printf("stats- %s \n", statInfos.CallId) // fmt.Printf("stats- %s \n", statInfos.TrId) // fmt.Printf("stats- %s \n", statInfos.ConcCall) // fmt.Printf("stats- %s \n", statInfos.SvcType) // fmt.Printf("stats- %s \n", statInfos.SvcReqTime) // fmt.Printf("stats- %s \n", statInfos.SvcRspTime) // fmt.Printf("stats- %s \n", statInfos.TransferNo) // fmt.Printf("stats- %s \n", statInfos.CallTime) // fmt.Printf("stats- %s \n", statInfos.CallType) // fmt.Printf("stats- %s \n", statInfos.FunName) // fmt.Printf("stats- %s \n", statInfos.ResultMsg) // fmt.Printf("stats- %s \n", statInfos.SttText) // fmt.Printf("stats- %s \n", statInfos.TtsText) } // } } func StatsCommandVA(t *icsnet.IcsTCPNet, bufend string) { l := icslog.GetIcsLog() statInfos := new(StatInfos) // s := GetIcsSid() rand.Seed(time.Now().UnixNano()) randNum := fmt.Sprintf("%07d", rand.Intn(10000000)) // randNum := fmt.Sprintf("%04d", rand.Intn(9999)) defer t.Close() statReads, rlen, rerr := t.ReadS(10137, bufend) // 여기서 전체 몇 byte씩 읽어서 로그를 찍을건지 알아야함 if rerr != nil { if rerr.GetError() != io.EOF { return } } else { fmt.Printf("Recved Stat Command(%s) %d \n", statReads, rlen) statInfos.ChangeByteToString(statReads) svc := statInfos.SvcType[0:1] now := fmt.Sprintf("%s", time.Now()) b := now[:23] c := strings.ReplaceAll(b, "-", "") d := strings.ReplaceAll(c, ".", "") e := strings.ReplaceAll(d, " ", "") nowS := strings.ReplaceAll(e, ":", "") seqId := nowS + svc + randNum ghost.M.Lock() hostName := ghost.HostName ghost.M.Unlock() insLog := "" insLog += fmt.Sprintf("SEQ_ID=%s|", seqId) insLog += fmt.Sprintf("LOG_TIME=%s|", statInfos.LogTime) insLog += fmt.Sprintf("LOG_TYPE=%s|", statInfos.LogType) insLog += fmt.Sprintf("SID=%s|", statInfos.Sid) insLog += fmt.Sprintf("RESULT_CODE=%s|", statInfos.ResultCode) insLog += fmt.Sprintf("REQ_TIME=%s|", statInfos.ReqTime) insLog += fmt.Sprintf("RSP_TIME=%s|", statInfos.RspTime) insLog += fmt.Sprintf("CLIENT_IP=%s|", statInfos.ClientIp) insLog += fmt.Sprintf("DEV_INFO=%s|", statInfos.DevInfo) insLog += fmt.Sprintf("OS_INFO=%s|", statInfos.OsInfo) insLog += fmt.Sprintf("NW_INFO=%s|", statInfos.NwInfo) insLog += fmt.Sprintf("SVC_NAME=%s|", statInfos.SvcName) insLog += fmt.Sprintf("DEV_MODEL=%s|", statInfos.DevModel) insLog += fmt.Sprintf("CARRIER_TYPE=%s|", statInfos.CarrierType) insLog += fmt.Sprintf("HOST_NAME=%s|", hostName) insLog += fmt.Sprintf("SCN_NAME=%s|", statInfos.ScnName) insLog += fmt.Sprintf("CALL_ID=%s|", statInfos.CallId) insLog += fmt.Sprintf("TR_ID=%s|", statInfos.TrId) insLog += fmt.Sprintf("CONC_CALL=%s|", statInfos.ConcCall) insLog += fmt.Sprintf("SVC_TYPE=%s|", statInfos.SvcType) insLog += fmt.Sprintf("SVC_REQ_TIME=%s|", statInfos.SvcReqTime) insLog += fmt.Sprintf("SVC_RSP_TIME=%s|", statInfos.SvcRspTime) insLog += fmt.Sprintf("TRANSFER_NO=%s|", statInfos.TransferNo) insLog += fmt.Sprintf("CALL_TIME=%s|", statInfos.CallTime) insLog += fmt.Sprintf("CALL_TYPE=%s|", statInfos.CallType) insLog += fmt.Sprintf("FUN_NAME=%s|", statInfos.FunName) insLog += fmt.Sprintf("RESULT_MSG=%s|", statInfos.ResultMsg) insLog += fmt.Sprintf("STT_TEXT=%s|", statInfos.SttText) insLog += fmt.Sprintf("TTS_TEXT=%s", statInfos.TtsText) l.Printf(icslog.LOG_LEVEL_INFO, -1, "%s", insLog) // fmt.Printf("stats- %s \n", statInfos.SeqId) // fmt.Printf("stats- %s \n", statInfos.LogTime) // fmt.Printf("stats- %s \n", statInfos.LogType) // fmt.Printf("stats- %s \n", statInfos.Sid) // fmt.Printf("stats- %s \n", statInfos.ResultCode) // fmt.Printf("stats- %s \n", statInfos.ReqTime) // fmt.Printf("stats- %s \n", statInfos.RspTime) // fmt.Printf("stats- %s \n", statInfos.ClientIp) // fmt.Printf("stats- %s \n", statInfos.DevInfo) // fmt.Printf("stats- %s \n", statInfos.OsInfo) // fmt.Printf("stats- %s \n", statInfos.NwInfo) // fmt.Printf("stats- %s \n", statInfos.SvcName) // fmt.Printf("stats- %s \n", statInfos.DevModel) // fmt.Printf("stats- %s \n", statInfos.CarrierType) // fmt.Printf("stats- %s \n", statInfos.HostName) // fmt.Printf("stats- %s \n", statInfos.ScnName) // fmt.Printf("stats- %s \n", statInfos.CallId) // fmt.Printf("stats- %s \n", statInfos.TrId) // fmt.Printf("stats- %s \n", statInfos.ConcCall) // fmt.Printf("stats- %s \n", statInfos.SvcType) // fmt.Printf("stats- %s \n", statInfos.SvcReqTime) // fmt.Printf("stats- %s \n", statInfos.SvcRspTime) // fmt.Printf("stats- %s \n", statInfos.TransferNo) // fmt.Printf("stats- %s \n", statInfos.CallTime) // fmt.Printf("stats- %s \n", statInfos.CallType) // fmt.Printf("stats- %s \n", statInfos.FunName) // fmt.Printf("stats- %s \n", statInfos.ResultMsg) // fmt.Printf("stats- %s \n", statInfos.SttText) // fmt.Printf("stats- %s \n", statInfos.TtsText) } } func (statInfos *StatInfos) ChangeByteToString(statInfo []byte) *icserror.IcsError { // l := icslog.GetIcsLog() // defer func() { // l.Printf(icslog.LOG_LEVEL_WARN, -1, "%s \n%s", // icserror.ICSERRNETNotConnectError.GetMessage(), debug.Stack()) // return // }() // n := bytes.Index(statInfo[STAT_INFO:SEQ_ID], []byte{0}) seqId := string(statInfo[STAT_INFO:SEQ_ID]) // fmt.Println("seqid ", statInfo[STAT_INFO : SEQ_ID]) n := bytes.Index([]byte(seqId), []byte{0}) if n != -1 && n < SEQ_ID { statInfos.SeqId = string([]byte(seqId)[:n]) } else { statInfos.SeqId = string(statInfo[STAT_INFO:SEQ_ID]) } logTime := string(statInfo[SEQ_ID:LOG_TIME]) // fmt.Println("seqid ", statInfo[STAT_INFO : SEQ_ID]) n = bytes.Index([]byte(logTime), []byte{0}) if n != -1 && n < LOG_TIME { statInfos.LogTime = string([]byte(logTime)[:n]) } else { statInfos.LogTime = string(statInfo[SEQ_ID:LOG_TIME]) } logType := string(statInfo[LOG_TIME:LOG_TYPE]) // fmt.Println("seqid ", statInfo[STAT_INFO : SEQ_ID]) n = bytes.Index([]byte(logType), []byte{0}) if n != -1 && n < LOG_TYPE { statInfos.LogType = string([]byte(logType)[:n]) } else { statInfos.LogType = string(statInfo[LOG_TIME:LOG_TYPE]) } sid := string(statInfo[LOG_TYPE:SID]) // fmt.Println("seqid ", statInfo[STAT_INFO : SEQ_ID]) n = bytes.Index([]byte(sid), []byte{0}) if n != -1 && n < SID { statInfos.Sid = string([]byte(sid)[:n]) } else { statInfos.Sid = string(statInfo[LOG_TYPE:SID]) } resultCode := string(statInfo[SID:RESULT_CODE]) // fmt.Println("seqid ", statInfo[STAT_INFO : SEQ_ID]) n = bytes.Index([]byte(resultCode), []byte{0}) if n != -1 && n < RESULT_CODE { statInfos.ResultCode = string([]byte(resultCode)[:n]) } else { statInfos.ResultCode = string(statInfo[SID:RESULT_CODE]) } reqTime := string(statInfo[RESULT_CODE:REQ_TIME]) // fmt.Println("seqid ", statInfo[STAT_INFO : SEQ_ID]) n = bytes.Index([]byte(reqTime), []byte{0}) if n != -1 && n < REQ_TIME { statInfos.ReqTime = string([]byte(reqTime)[:n]) } else { statInfos.ReqTime = string(statInfo[RESULT_CODE:REQ_TIME]) } rspTime := string(statInfo[REQ_TIME:RES_TIME]) // fmt.Println("seqid ", statInfo[STAT_INFO : SEQ_ID]) n = bytes.Index([]byte(rspTime), []byte{0}) if n != -1 && n < RES_TIME { statInfos.RspTime = string([]byte(rspTime)[:n]) } else { statInfos.RspTime = string(statInfo[REQ_TIME:RES_TIME]) } clientIp := string(statInfo[RES_TIME:CLIENT_IP]) // fmt.Println("seqid ", statInfo[STAT_INFO : SEQ_ID]) n = bytes.Index([]byte(clientIp), []byte{0}) if n != -1 && n < CLIENT_IP { statInfos.ClientIp = string([]byte(clientIp)[:n]) } else { statInfos.ClientIp = string(statInfo[RES_TIME:CLIENT_IP]) } devInfo := string(statInfo[CLIENT_IP:DEV_INFO]) // fmt.Println("seqid ", statInfo[STAT_INFO : SEQ_ID]) n = bytes.Index([]byte(devInfo), []byte{0}) if n != -1 && n < DEV_INFO { statInfos.DevInfo = string([]byte(devInfo)[:n]) } else { statInfos.DevInfo = string(statInfo[CLIENT_IP:DEV_INFO]) } osInfo := string(statInfo[DEV_INFO:OS_INFO]) // fmt.Println("seqid ", statInfo[STAT_INFO : SEQ_ID]) n = bytes.Index([]byte(osInfo), []byte{0}) if n != -1 && n < OS_INFO { statInfos.OsInfo = string([]byte(osInfo)[:n]) } else { statInfos.OsInfo = string(statInfo[DEV_INFO:OS_INFO]) } nwInfo := string(statInfo[OS_INFO:NW_INFO]) // fmt.Println("seqid ", statInfo[STAT_INFO : SEQ_ID]) n = bytes.Index([]byte(nwInfo), []byte{0}) if n != -1 && n < NW_INFO { statInfos.NwInfo = string([]byte(nwInfo)[:n]) } else { statInfos.NwInfo = string(statInfo[OS_INFO:NW_INFO]) } svcName := string(statInfo[NW_INFO:SVC_NAME]) // fmt.Println("seqid ", statInfo[STAT_INFO : SEQ_ID]) n = bytes.Index([]byte(svcName), []byte{0}) if n != -1 && n < SVC_NAME { statInfos.SvcName = string([]byte(svcName)[:n]) } else { statInfos.SvcName = string(statInfo[NW_INFO:SVC_NAME]) } devModel := string(statInfo[SVC_NAME:DEV_MODEL]) // fmt.Println("seqid ", statInfo[STAT_INFO : SEQ_ID]) n = bytes.Index([]byte(devModel), []byte{0}) if n != -1 && n < DEV_MODEL { statInfos.DevModel = string([]byte(devModel)[:n]) } else { statInfos.DevModel = string(statInfo[SVC_NAME:DEV_MODEL]) } carrierType := string(statInfo[DEV_MODEL:CARRIER_TYPE]) // fmt.Println("seqid ", statInfo[STAT_INFO : SEQ_ID]) n = bytes.Index([]byte(carrierType), []byte{0}) if n != -1 && n < CARRIER_TYPE { statInfos.CarrierType = string([]byte(carrierType)[:n]) } else { statInfos.CarrierType = string(statInfo[DEV_MODEL:CARRIER_TYPE]) } hostName := string(statInfo[CARRIER_TYPE:HOST_NAME]) // fmt.Println("seqid ", statInfo[STAT_INFO : SEQ_ID]) n = bytes.Index([]byte(hostName), []byte{0}) if n != -1 && n < HOST_NAME { statInfos.HostName = string([]byte(hostName)[:n]) } else { statInfos.HostName = string(statInfo[CARRIER_TYPE:HOST_NAME]) } scnName := string(statInfo[HOST_NAME:SCN_NAME]) // fmt.Println("seqid ", statInfo[STAT_INFO : SEQ_ID]) n = bytes.Index([]byte(scnName), []byte{0}) if n != -1 && n < SCN_NAME { statInfos.ScnName = string([]byte(scnName)[:n]) } else { statInfos.HostName = string(statInfo[HOST_NAME:SCN_NAME]) } callId := string(statInfo[SCN_NAME:CALL_ID]) // fmt.Println("seqid ", statInfo[STAT_INFO : SEQ_ID]) n = bytes.Index([]byte(callId), []byte{0}) if n != -1 && n < CALL_ID { statInfos.CallId = string([]byte(callId)[:n]) } else { statInfos.CallId = string(statInfo[SCN_NAME:CALL_ID]) } trId := string(statInfo[CALL_ID:TR_ID]) // fmt.Println("seqid ", statInfo[STAT_INFO : SEQ_ID]) n = bytes.Index([]byte(trId), []byte{0}) if n != -1 && n < TR_ID { statInfos.TrId = string([]byte(trId)[:n]) } else { statInfos.TrId = string(statInfo[CALL_ID:TR_ID]) } concCall := string(statInfo[TR_ID:CONC_CALL]) // fmt.Println("seqid ", statInfo[STAT_INFO : SEQ_ID]) n = bytes.Index([]byte(concCall), []byte{0}) if n != -1 && n < CONC_CALL { statInfos.ConcCall = string([]byte(concCall)[:n]) } else { statInfos.ConcCall = string(statInfo[TR_ID:CONC_CALL]) } svcType := string(statInfo[CONC_CALL:SVC_TYPE]) // fmt.Println("seqid ", statInfo[STAT_INFO : SEQ_ID]) n = bytes.Index([]byte(svcType), []byte{0}) if n != -1 && n < SVC_TYPE { statInfos.SvcType = string([]byte(svcType)[:n]) } else { statInfos.SvcType = string(statInfo[CONC_CALL:SVC_TYPE]) } svcReqTime := string(statInfo[SVC_TYPE:SVC_REQ_TIME]) // fmt.Println("seqid ", statInfo[STAT_INFO : SEQ_ID]) n = bytes.Index([]byte(svcReqTime), []byte{0}) if n != -1 && n < SVC_REQ_TIME { statInfos.SvcReqTime = string([]byte(svcReqTime)[:n]) } else { statInfos.SvcReqTime = string(statInfo[SVC_TYPE:SVC_REQ_TIME]) } svcRspTime := string(statInfo[SVC_REQ_TIME:SVC_RSP_TIME]) // fmt.Println("seqid ", statInfo[STAT_INFO : SEQ_ID]) n = bytes.Index([]byte(svcRspTime), []byte{0}) if n != -1 && n < SVC_RSP_TIME { statInfos.SvcRspTime = string([]byte(svcRspTime)[:n]) } else { statInfos.SvcRspTime = string(statInfo[SVC_REQ_TIME:SVC_RSP_TIME]) } transferNo := string(statInfo[SVC_RSP_TIME:TRANSFER_NO]) // fmt.Println("seqid ", statInfo[STAT_INFO : SEQ_ID]) n = bytes.Index([]byte(transferNo), []byte{0}) if n != -1 && n < TRANSFER_NO { statInfos.TransferNo = string([]byte(transferNo)[:n]) } else { statInfos.TransferNo = string(statInfo[SVC_RSP_TIME:TRANSFER_NO]) } callTime := string(statInfo[TRANSFER_NO:CALL_TIME]) // fmt.Println("seqid ", statInfo[STAT_INFO : SEQ_ID]) n = bytes.Index([]byte(callTime), []byte{0}) if n != -1 && n < CALL_TIME { statInfos.CallTime = string([]byte(callTime)[:n]) } else { statInfos.CallTime = string(statInfo[TRANSFER_NO:CALL_TIME]) } callType := string(statInfo[CALL_TIME:CALL_TYPE]) // fmt.Println("seqid ", statInfo[STAT_INFO : SEQ_ID]) n = bytes.Index([]byte(callType), []byte{0}) if n != -1 && n < CALL_TYPE { statInfos.CallType = string([]byte(callType)[:n]) } else { statInfos.CallType = string(statInfo[CALL_TIME:CALL_TYPE]) } funName := string(statInfo[CALL_TYPE:FUN_NAME]) // fmt.Println("seqid ", statInfo[STAT_INFO : SEQ_ID]) n = bytes.Index([]byte(funName), []byte{0}) if n != -1 && n < FUN_NAME { statInfos.FunName = string([]byte(funName)[:n]) } else { statInfos.FunName = string(statInfo[CALL_TYPE:FUN_NAME]) } resultMsg := string(statInfo[FUN_NAME:RESULT_MSG]) // fmt.Println("seqid ", statInfo[STAT_INFO : SEQ_ID]) n = bytes.Index([]byte(resultMsg), []byte{0}) if n != -1 && n < RESULT_MSG { statInfos.ResultMsg = string([]byte(resultMsg)[:n]) } else { statInfos.ResultMsg = string(statInfo[FUN_NAME:RESULT_MSG]) } sttText := string(statInfo[RESULT_MSG:STT_TEXT]) // fmt.Println("seqid ", statInfo[STAT_INFO : SEQ_ID]) n = bytes.Index([]byte(sttText), []byte{0}) if n != -1 && n < RESULT_MSG { statInfos.SttText = string([]byte(sttText)[:n]) } else { statInfos.SttText = string(statInfo[RESULT_MSG:STT_TEXT]) } ttsText := string(statInfo[STT_TEXT:]) // fmt.Println("seqid ", statInfo[STAT_INFO : SEQ_ID]) n = bytes.Index([]byte(ttsText), []byte{0}) if n != -1 { statInfos.TtsText = string([]byte(ttsText)[:n]) } else { statInfos.TtsText = string(statInfo[STT_TEXT:]) } /* // n := bytes.Index(statInfo[SEQ_ID:LOG_TIME], []byte{0}) statInfos.LogTime = string(statInfo[SEQ_ID:LOG_TIME]) // fmt.Println("seqid ", statInfo[SEQ_ID : SEQ_ID+n]) // n = bytes.Index(statInfo[LOG_TIME:LOG_TYPE], []byte{0}) statInfos.LogType = string(statInfo[LOG_TIME:LOG_TYPE]) // fmt.Println("seqid ", statInfo[SEQ_ID : SEQ_ID+n]) // n = bytes.Index(statInfo[LOG_TYPE:SID], []byte{0}) statInfos.Sid = string(statInfo[LOG_TYPE:SID]) // n = bytes.Index(statInfo[SID:RESULT_CODE], []byte{0}) statInfos.ResultCode = string(statInfo[SID:RESULT_CODE]) // n = bytes.Index(statInfo[RESULT_CODE:REQ_TIME], []byte{0}) statInfos.ReqTime = string(statInfo[RESULT_CODE:REQ_TIME]) // n = bytes.Index(statInfo[REQ_TIME:RES_TIME], []byte{0}) statInfos.RspTime = string(statInfo[REQ_TIME:RES_TIME]) // n = bytes.Index(statInfo[RES_TIME:CLIENT_IP], []byte{0}) statInfos.ClientIp = string(statInfo[RES_TIME:CLIENT_IP]) // n = bytes.Index(statInfo[CLIENT_IP:DEV_INFO], []byte{0}) statInfos.DevInfo = string(statInfo[CLIENT_IP:DEV_INFO]) // n = bytes.Index(statInfo[DEV_INFO:OS_INFO], []byte{0}) statInfos.OsInfo = string(statInfo[DEV_INFO:OS_INFO]) // n = bytes.Index(statInfo[OS_INFO:NW_INFO], []byte{0}) statInfos.NwInfo = string(statInfo[OS_INFO:NW_INFO]) // n = bytes.Index(statInfo[NW_INFO:SVC_NAME], []byte{0}) statInfos.SvcName = string(statInfo[NW_INFO:SVC_NAME]) // n = bytes.Index(statInfo[SVC_NAME:DEV_MODEL], []byte{0}) statInfos.DevModel = string(statInfo[SVC_NAME:DEV_MODEL]) // n = bytes.Index(statInfo[DEV_MODEL:CARRIER_TYPE], []byte{0}) statInfos.CarrierType = string(statInfo[DEV_MODEL:CARRIER_TYPE]) // n = bytes.Index(statInfo[CARRIER_TYPE:HOST_NAME], []byte{0}) statInfos.HostName = string(statInfo[CARRIER_TYPE:HOST_NAME]) // n = bytes.Index(statInfo[HOST_NAME:SCN_NAME], []byte{0}) statInfos.ScnName = string(statInfo[HOST_NAME:SCN_NAME]) // n = bytes.Index(statInfo[SCN_NAME:CALL_ID], []byte{0}) statInfos.CallId = string(statInfo[SCN_NAME:CALL_ID]) // n = bytes.Index(statInfo[CALL_ID:TR_ID], []byte{0}) statInfos.TrId = string(statInfo[CALL_ID:TR_ID]) // n = bytes.Index(statInfo[TR_ID:CONC_CALL], []byte{0}) statInfos.ConcCall = string(statInfo[TR_ID:CONC_CALL]) // n = bytes.Index(statInfo[CONC_CALL:SVC_TYPE], []byte{0}) statInfos.SvcType = string(statInfo[CONC_CALL:SVC_TYPE]) // n = bytes.Index(statInfo[SVC_TYPE:SVC_REQ_TIME], []byte{0}) statInfos.SvcReqTime = string(statInfo[SVC_TYPE:SVC_REQ_TIME]) // n = bytes.Index(statInfo[SVC_REQ_TIME:SVC_RSP_TIME], []byte{0}) statInfos.SvcRspTime = string(statInfo[SVC_REQ_TIME:SVC_RSP_TIME]) // n = bytes.Index(statInfo[SVC_REQ_TIME:SVC_RSP_TIME], []byte{0}) statInfos.TransferNo = string(statInfo[SVC_RSP_TIME:TRANSFER_NO]) // n = bytes.Index(statInfo[SVC_REQ_TIME:SVC_RSP_TIME], []byte{0}) statInfos.CallTime = string(statInfo[TRANSFER_NO:CALL_TIME]) // n = bytes.Index(statInfo[SVC_REQ_TIME:SVC_RSP_TIME], []byte{0}) statInfos.CallType = string(statInfo[CALL_TIME:CALL_TYPE]) // n = bytes.Index(statInfo[SVC_REQ_TIME:SVC_RSP_TIME], []byte{0}) statInfos.FunName = string(statInfo[CALL_TYPE:FUN_NAME]) // n = bytes.Index(statInfo[SVC_RSP_TIME:RESULT_MSG], []byte{0}) statInfos.ResultMsg = string(statInfo[FUN_NAME:RESULT_MSG]) // n = bytes.Index(statInfo[RESULT_MSG:STT_TEXT], []byte{0}) statInfos.SttText = string(statInfo[RESULT_MSG:STT_TEXT]) // n = bytes.Index(statInfo[STT_TEXT:TTS_TEXT], []byte{0}) statInfos.TtsText = string(statInfo[STT_TEXT:]) */ return nil }