Example #1
0
 protected void FireAdded(Snapshot aSnapshot)
 {
     if (Added != null)
     {
         Added(aSnapshot);
     }
 }
Example #2
0
        protected override void LoopRun()
        {
            Core.Server[] servers = (from server in Servers.All select server).ToArray();
            Channel[] channels = (from server in servers from channel in server.Channels select channel).ToArray();
            Bot[] bots = (from channel in channels from bot in channel.Bots select bot).ToArray();
            Packet[] packets = (from bot in bots from packet in bot.Packets select packet).ToArray();

            var snap = new Snapshot();
            snap.Set(SnapshotValue.Timestamp, DateTime.Now.ToTimestamp());

            snap.Set(SnapshotValue.Speed, (from file in Files.All from part in file.Parts select part.Speed).Sum());

            snap.Set(SnapshotValue.Servers, (from server in servers select server).Count());
            snap.Set(SnapshotValue.ServersEnabled, (from server in servers where server.Enabled select server).Count());
            snap.Set(SnapshotValue.ServersDisabled, (from server in servers where !server.Enabled select server).Count());
            snap.Set(SnapshotValue.ServersConnected, (from server in servers where server.Connected select server).Count());
            snap.Set(SnapshotValue.ServersDisconnected, (from server in servers where !server.Connected select server).Count());

            snap.Set(SnapshotValue.Channels, (from channel in channels select channel).Count());
            snap.Set(SnapshotValue.ChannelsEnabled, (from channel in channels where channel.Enabled select channel).Count());
            snap.Set(SnapshotValue.ChannelsDisabled, (from channel in channels where !channel.Enabled select channel).Count());
            snap.Set(SnapshotValue.ChannelsConnected, (from channel in channels where channel.Connected select channel).Count());
            snap.Set(SnapshotValue.ChannelsDisconnected, (from channel in channels where !channel.Connected select channel).Count());

            snap.Set(SnapshotValue.Bots, (from bot in bots select bot).Count());
            snap.Set(SnapshotValue.BotsConnected, (from bot in bots where bot.Connected select bot).Count());
            snap.Set(SnapshotValue.BotsDisconnected, (from bot in bots where !bot.Connected select bot).Count());
            snap.Set(SnapshotValue.BotsFreeSlots, (from bot in bots where bot.InfoSlotCurrent > 0 select bot).Count());
            snap.Set(SnapshotValue.BotsFreeQueue, (from bot in bots where bot.InfoQueueCurrent > 0 select bot).Count());
            try
            {
                snap.Set(SnapshotValue.BotsAverageCurrentSpeed,
                         ((from bot in bots select bot.InfoSpeedCurrent).Sum() / (from bot in bots where bot.InfoSpeedCurrent > 0 select bot).Count()));
            }
            catch (DivideByZeroException)
            {
                snap.Set(SnapshotValue.BotsAverageCurrentSpeed, 0);
            }
            try
            {
                snap.Set(SnapshotValue.BotsAverageMaxSpeed,
                         ((from bot in bots select bot.InfoSpeedMax).Sum() / (from bot in bots where bot.InfoSpeedMax > 0 select bot).Count()));
            }
            catch (DivideByZeroException)
            {
                snap.Set(SnapshotValue.BotsAverageMaxSpeed, 0);
            }

            snap.Set(SnapshotValue.Packets, (from packet in packets select packet).Count());
            snap.Set(SnapshotValue.PacketsConnected, (from packet in packets where packet.Connected select packet).Count());
            snap.Set(SnapshotValue.PacketsDisconnected, (from packet in packets where !packet.Connected select packet).Count());
            snap.Set(SnapshotValue.PacketsSize, (from packet in packets select packet.Size).Sum());
            snap.Set(SnapshotValue.PacketsSizeDownloading, (from packet in packets where packet.Connected select packet.Size).Sum());
            snap.Set(SnapshotValue.PacketsSizeNotDownloading, (from packet in packets where !packet.Connected select packet.Size).Sum());
            snap.Set(SnapshotValue.PacketsSizeConnected, (from packet in packets where packet.Parent.Connected select packet.Size).Sum());
            snap.Set(SnapshotValue.PacketsSizeDisconnected, (from packet in packets where !packet.Parent.Connected select packet.Size).Sum());

            Snapshots.Add(snap);
        }
Example #3
0
 protected override void SnapshotAdded(Snapshot aSnap)
 {
     var response = new Response
     {
         Type = Response.Types.ObjectAdded,
         Data = Snapshots2Flot(Snapshots)
     };
     Broadcast(response);
 }
Example #4
0
        public void AddBackendPlugin(ABackendPlugin aPlugin)
        {
            Servers = aPlugin.LoadServers();
            _fileActions.Servers = Servers;
            Files = aPlugin.LoadFiles();
            _fileActions.Files = Files;
            Searches = aPlugin.LoadSearches();
            Snapshots = aPlugin.LoadStatistics();

            if (Snapshots.All.Count() > 0)
            {
                // put a empty snapshot on top to nullify values
                var lasttime = (from snapshot in Snapshots.All orderby snapshot.Get(SnapshotValue.Timestamp) select snapshot).Last().Get(SnapshotValue.Timestamp);
                var lastSnapshot = new Snapshot();
                lastSnapshot.Set(SnapshotValue.Timestamp, lasttime + 1);
                Snapshots.Add(lastSnapshot);

                var firstSnapshot = new Snapshot();
                firstSnapshot.Set(SnapshotValue.Timestamp, DateTime.Now.ToTimestamp());
                Snapshots.Add(firstSnapshot);
            }

            AddWorker(aPlugin);
        }
Example #5
0
 protected virtual void SnapshotAdded(Snapshot aSnap)
 {
 }
Example #6
0
 protected override void SnapshotAdded(Snapshot aSnap)
 {
     SaveSnapshots();
 }
Example #7
0
 public void Add(Snapshot aSnapshot)
 {
     _all.Add(aSnapshot);
     FireAdded(aSnapshot);
 }