Esempio n. 1
0
        public PingerStats GetStats()
        {
            PingerStats stats = new PingerStats();

            int deltaValid = getPingerDelayValid();
            int timeNow    = Utils.UnixTimeStamp();

            int iTotal = 0;

            lock (Engine.Servers)
            {
                foreach (ServerInfo infoServer in Engine.Servers.Values)
                {
                    if ((stats.OlderCheckDate == 0) || (stats.OlderCheckDate > infoServer.LastPingResult))
                    {
                        stats.OlderCheckDate = infoServer.LastPingResult;
                    }

                    if ((stats.LatestCheckDate == 0) || (stats.LatestCheckDate < infoServer.LastPingResult))
                    {
                        stats.LatestCheckDate = infoServer.LastPingResult;
                    }

                    iTotal++;
                    if (timeNow - infoServer.LastPingResult > deltaValid)
                    {
                        stats.Invalid++;
                    }
                }
            }

            //Console.WriteLine("Ping Total:" + iTotal.ToString() + ", Invalid:" + iInvalid.ToString());

            stats.Valid = (stats.Invalid == 0);

            return(stats);
        }
Esempio n. 2
0
		public PingerStats GetStats()
		{
			PingerStats stats = new PingerStats();

			int deltaValid = getPingerDelayValid();			
			int timeNow = Utils.UnixTimeStamp();

			int iTotal = 0;
			
			lock (Engine.Servers)
			{
				foreach (ServerInfo infoServer in Engine.Servers.Values)
				{
					if( (stats.OlderCheckDate == 0) || (stats.OlderCheckDate > infoServer.LastPingResult) )
						stats.OlderCheckDate = infoServer.LastPingResult;

					if ((stats.LatestCheckDate == 0) || (stats.LatestCheckDate < infoServer.LastPingResult))
						stats.LatestCheckDate = infoServer.LastPingResult;

					iTotal++;
					if (timeNow - infoServer.LastPingResult > deltaValid)
						stats.Invalid++;						
				}
			}

			//Console.WriteLine("Ping Total:" + iTotal.ToString() + ", Invalid:" + iInvalid.ToString());

			stats.Valid = (stats.Invalid == 0);

			return stats;
		}