示例#1
0
        public CallStats GetCallStats()
        {
            var _callStats = new CallStats();

            _callStats.Startup = started;
            _callStats.Running = running;

            lock (padlock) {
                var _currentOpen = currentOpen >= 0 ? currentOpen : 0;

                _callStats.TotalCalls            = todayLeg1;
                _callStats.TotalSuccessfullCalls = todayLeg2;
                _callStats.OpenCalls             = _currentOpen;
                _callStats.ConnectingCalls       = currentConnecting;
                _callStats.ConnectedCalls        = currentConnected;
                _callStats.TotalCurrentCalls     = _currentOpen + currentConnecting + currentConnected;
            }

            return(_callStats);
        }
        /*
         * 0	-- Endpoint Statistics --
         * 1	Total Endpoints: 123  Terminals: 0  Gateways: 123  NATed: 0
         * 2	Cached Endpoints: 0  Terminals: 0  Gateways: 0
         * 3	-- Call Statistics --
         * 4	Current Calls: 0 Active: 0 From Neighbor: 0 From Parent: 0
         * 5	Total Calls: 67989  Successful: 6336  From Neighbor: 56151  From Parent: 0
         * 6	Startup: Sat, 05 Mar 2005 01:58:44 -0500   Running: 10 days 16:10:30
         * 7	;
         */

        CallStats parse(string pData)
        {
            var _callStats = new CallStats();

            if (!string.IsNullOrEmpty(pData))
            {
                var _lines     = pData.Replace("\r", "").Split("\n".ToCharArray());
                var _startLine = _lines[6];

                _callStats.Startup = _startLine.Substring(8, _startLine.IndexOf("Running:") - 8).Trim();
                _callStats.Running = _startLine.Substring(_startLine.IndexOf("Running:") + 8).Trim();

                var _currCallsLine = _lines[4];
                var _currCalls     = _currCallsLine.Split(":".ToCharArray());
                _callStats.ConnectingCalls = int.Parse(_currCalls[1].Replace("Active", ""));
                _callStats.ConnectedCalls  = int.Parse(_currCalls[2].Replace("From Neighbor", ""));

                var _totalLine = _lines[5];
                var _totCalls  = _totalLine.Split(":".ToCharArray());
                _callStats.TotalCalls            = int.Parse(_totCalls[1].Replace("Successful", ""));
                _callStats.TotalSuccessfullCalls = int.Parse(_totCalls[2].Replace("From Neighbor", ""));
            }
            return(_callStats);
        }