Example #1
0
        public Dictionary <string, double> GetResourceStatistics()
        {
            lock (mLockStatistics)
            {
                long serveTime = mServer.GetRunTime();
                if (serveTime - mIoStatistics.LastTime >= 1000)
                {
                    NodeResourceStatistics nstatis = new NodeResourceStatistics();
                    nstatis.NetworkReceiveBytes = mServer.ReceivBytes;
                    nstatis.NetworkReceiveIO    = mServer.ReceiveQuantity;
                    nstatis.NetworkSendBytes    = mServer.SendBytes;
                    nstatis.NetworkSendIO       = mServer.SendQuantity;
                    mRemoteNodeCenter.IOStatistics(nstatis);

                    nstatis.NetworkReceiveBytesPersecond = nstatis.NetworkReceiveBytes - mIoStatistics.NetworkReceiveBytes;
                    nstatis.NetworkReceiveIOPersecond    = nstatis.NetworkReceiveIO - mIoStatistics.NetworkReceiveIO;
                    nstatis.NetworkSendBytesPersecond    = nstatis.NetworkSendBytes - mIoStatistics.NetworkSendBytes;
                    nstatis.NetworkSendIOPersecond       = nstatis.NetworkSendIO - mIoStatistics.NetworkSendIO;


                    if (GetResourceStatisticsEvent != null)
                    {
                        GetResourceStatisticsEvent(nstatis, this);
                    }
                    nstatis.LastTime = serveTime;
                    mIoStatistics    = nstatis;
                }
                mIoStatistics.ProcessedMessages  = mProcessedMessages;
                mIoStatistics.ProcessingMessages = mProcessingMessages;
                return(mIoStatistics.ToProperties());
            }
        }
        public void IOStatistics(NodeResourceStatistics statis)
        {
            lock (mNetworkStatistics)
            {
                NodeResourceStatistics value;
                foreach (INodeConnection conn in GetOnlines())
                {
                    if (!mNetworkStatistics.TryGetValue(conn.RemoteNodeID, out value))
                    {
                        value = new SmartRoute.NodeResourceStatistics();
                        mNetworkStatistics[conn.RemoteNodeID] = value;
                    }
                    value.NetworkReceiveBytes = conn.Client.ReceivBytes;
                    value.NetworkReceiveIO    = conn.Client.ReceiveQuantity;
                    value.NetworkSendBytes    = conn.Client.SendBytes;
                    value.NetworkSendIO       = conn.Client.SendQuantity;
                }

                foreach (NodeResourceStatistics item in mNetworkStatistics.Values)
                {
                    statis.NetworkSendIO       += item.NetworkSendIO;
                    statis.NetworkSendBytes    += item.NetworkSendBytes;
                    statis.NetworkReceiveIO    += item.NetworkReceiveIO;
                    statis.NetworkReceiveBytes += item.NetworkReceiveBytes;
                }
            }
        }