예제 #1
0
        public void Run()
        {
            while (!exitFlag_)
            {
                try
                {
                    if (Enable && channel_.State == ChannelState.Ready)
                    {
                        QueryStatsResponse res = null;
                        try
                        {
                            res = client_.QueryStats(new QueryStatsRequest()
                            {
                                Pattern = "", Reset = true
                            });
                        }
                        catch (Exception ex)
                        {
                            Utils.SaveLog(ex.Message, ex);
                        }

                        if (res != null)
                        {
                            var   itemId         = config_.getItemId();
                            var   serverStatItem = GetServerStatItem(itemId);
                            ulong up             = 0,
                                  down           = 0;

                            //TODO: parse output
                            ParseOutput(res.Stat, out up, out down);

                            serverStatItem.todayUp   += up;
                            serverStatItem.todayDown += down;
                            serverStatItem.totalUp   += up;
                            serverStatItem.totalDown += down;

                            if (UpdateUI)
                            {
                                updateFunc_(up, down, new List <ServerStatItem> {
                                    serverStatItem
                                });
                            }
                        }
                    }
                    Thread.Sleep(config_.statisticsFreshRate);
                    channel_.ConnectAsync();
                }
                catch (Exception ex)
                {
                    Utils.SaveLog(ex.Message, ex);
                }
            }
        }
예제 #2
0
        public void run()
        {
            try
            {
                while (!exitFlag_)
                {
                    if (enabled_ && channel_.State == ChannelState.Ready)
                    {
                        var res = client_.QueryStats(new QueryStatsRequest()
                        {
                            Pattern = "", Reset = true
                        });

                        var   addr = config_.address();
                        var   port = config_.port();
                        var   cur  = Statistic.FindIndex(item => item.address == addr && item.port == port);
                        ulong up   = 0,
                              down = 0;

                        //TODO: parse output
                        parseOutput(res.Stat, out up, out down);

                        Up   = up;
                        Down = down;

                        TotalUp   += up;
                        TotalDown += down;

                        if (cur != -1)
                        {
                            Statistic[cur].todayUp   += up;
                            Statistic[cur].todayDown += down;
                            Statistic[cur].totalUp   += up;
                            Statistic[cur].totalDown += down;
                        }

                        if (UpdateUI)
                        {
                            updateFunc_(TotalUp, TotalDown, Up, Down, Statistic);
                        }
                        Thread.Sleep(config_.statisticsFreshRate);
                        channel_.ConnectAsync();
                    }
                }
            }
            catch {  }
        }
예제 #3
0
        public void Run()
        {
            while (!exitFlag_)
            {
                try
                {
                    if (enabled_ && channel_.State == ChannelState.Ready)
                    {
                        QueryStatsResponse res = null;
                        try
                        {
                            res = client_.QueryStats(new QueryStatsRequest()
                            {
                                Pattern = "", Reset = true
                            });
                        }
                        catch (Exception ex)
                        {
                            Utils.SaveLog(ex.Message, ex);
                        }

                        if (res != null)
                        {
                            var   addr = config_.address();
                            var   port = config_.port();
                            var   path = config_.path();
                            var   cur  = Statistic.FindIndex(item => item.address == addr && item.port == port && item.path == path);
                            ulong up   = 0,
                                  down = 0;

                            //TODO: parse output
                            ParseOutput(res.Stat, out up, out down);

                            Up   = up;
                            Down = down;

                            TotalUp   += up;
                            TotalDown += down;

                            if (cur != -1)
                            {
                                Statistic[cur].todayUp   += up;
                                Statistic[cur].todayDown += down;
                                Statistic[cur].totalUp   += up;
                                Statistic[cur].totalDown += down;
                            }

                            if (UpdateUI)
                            {
                                updateFunc_(TotalUp, TotalDown, Up, Down, Statistic);
                            }
                        }
                    }
                    Thread.Sleep(config_.statisticsFreshRate);
                    channel_.ConnectAsync();
                }
                catch (Exception ex)
                {
                    Utils.SaveLog(ex.Message, ex);
                }
            }
        }