diff --git a/icsapp/execsvc.go b/icsapp/execsvc.go index 0a83d25..06d6751 100644 --- a/icsapp/execsvc.go +++ b/icsapp/execsvc.go @@ -35,14 +35,13 @@ func Init(conf *icsconf.IcsConfig) (e *IcsExec) { func (exe IcsExec) Execute() *icserror.IcsError { l := icslog.GetIcsLog() - l.Printf(icslog.LOG_LEVEL_FATAL, -1, "11111") for !exe.service.GetExit() { for exe.service.GetStop() { time.Sleep(time.Millisecond) } ///////////////////////////////////////////////////////////////////// - //start statistic tcp + // voice gateway start statistic tcp cmdDone := make(chan *icserror.IcsError) go func() { cmdErr := icsstat.ListenStatMNG() @@ -56,13 +55,34 @@ func (exe IcsExec) Execute() *icserror.IcsError { }() ///////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////// + // voice agent start statistic tcp + cmdDone1 := make(chan *icserror.IcsError) + go func() { + cmdErr := icsstat.ListenStatMNG1() + if cmdErr != nil { + cmdDone1 <- cmdErr + return + } + //defer sm.Close() + + //cmdDone <- nil + }() + ///////////////////////////////////////////////////////////////////// + select { case err := <-cmdDone: - l.Printf(icslog.LOG_LEVEL_INFO, -1, "Closed Stat TCP Connection: %s", err) + l.Printf(icslog.LOG_LEVEL_INFO, -1, "Closed Gateway Stat TCP Connection: %s", err) if err != nil { //err.Print() return err } + case err1 := <-cmdDone1: + l.Printf(icslog.LOG_LEVEL_INFO, -1, "Closed Agent Stat TCP Connection: %s", err1) + if err1 != nil { + //err.Print() + return err1 + } } } diff --git a/icsconf/icsconf.go b/icsconf/icsconf.go index 51c4f22..84f5f44 100644 --- a/icsconf/icsconf.go +++ b/icsconf/icsconf.go @@ -17,6 +17,7 @@ type IcsConfig struct { LogConfig LogConfig `xml:"LOG"` Linger int `xml:"LINGER"` Target Target `xml:"TARGET"` + Target1 Target1 `xml:"TARGET1"` HomeDir string } @@ -32,6 +33,11 @@ type Target struct { TargetPort int `xml:"port,attr"` } +type Target1 struct { + Transport string `xml:"transport,attr"` + TargetPort int `xml:"port,attr"` +} + type LogConfig struct { Path string `xml:"PATH"` Disklimit int `xml:"DISKLIMIT"` diff --git a/icsstat/icsstat.go b/icsstat/icsstat.go index bafe25a..fbc59f9 100644 --- a/icsstat/icsstat.go +++ b/icsstat/icsstat.go @@ -103,6 +103,28 @@ func ListenStatMNG() (icserr *icserror.IcsError) { 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\r\n", StatsCommand) + if cmdErr != nil { + l.Printf(icslog.LOG_LEVEL_FATAL, -1, "%s", cmdErr.GetError()) + return nil + } + l.Printf(icslog.LOG_LEVEL_INFO, -1, "Listening Stat TCP Command %s port[%d]", statTransport, statPort) + fmt.Println(statTCP) + + return nil +} + func StatsCommand(t *icsnet.IcsTCPNet, bufend string) { l := icslog.GetIcsLog() statInfos := new(StatInfos)