예제 #1
0
        private void CollectReceiveStat(string type, int length)
        {
            lock (stats)
            {
                if (m_collectingStats)
                {
                    msgsIn.Event();
                    bytesIn.Event(length);

                    SyncConnectorStat msgStat;
                    if (!m_packetTypesRcvd.TryGetValue(type, out msgStat))
                    {
                        msgStat = new SyncConnectorStat(
                            "DSG_Msgs_Typ_Rcvd|" + description + "|" + type, // shortName
                            type + "_Rcvd",                                  // name
                            "connector DSG messages of type " + type,        // description
                            " messages",                                     // unit
                            m_regionSyncModule.Scene.Name,                   // region
                            m_connectorNum,                                  // connectornum
                            m_regionSyncModule.ActorID,                      // myActorID
                            otherSideRegionName,                             // otherSideRegionName
                            otherSideActorID,                                // otherSideActorID
                            type                                             // messageType
                            );
                        StatsManager.RegisterStat(msgStat);
                        m_packetTypesRcvd.Add(type, msgStat);
                    }
                    msgStat.Event();
                }
            }
        }
예제 #2
0
        private void StartCollectingStats()
        {
            // If stats not enabled or stats have already been initialized, just return.
            if (!m_regionSyncModule.StatCollector.Enabled || m_registeredStats.Count > 0)
            {
                return;
            }

            msgsIn = new SyncConnectorStat(
                "DSG_Msgs_Rcvd|" + description, // shortName
                "Msgs_Rcvd",                    // name
                "connector DSG messages rcvd",  // description
                " messages",                    // unit
                m_regionSyncModule.Scene.Name,  // region
                m_connectorNum,                 // connectornum
                m_regionSyncModule.ActorID,     // myActorID
                otherSideRegionName,            // otherSideRegionName
                otherSideActorID                // otherSideActorID
                );
            // msgsIn.AddHistogram("Msgs_Rcvd_Last_Minute", new EventHistogram(60, 1000)); // last minute in seconds
            // msgsIn.AddHistogram("Msgs_Rcvd_Last_Hour", new EventHistogram(60, 60000));  // last hour in minutes
            // msgsIn.AddHistogram("Msgs_Rcvd_Last_Day", new EventHistogram(24, 3600000)); // last day in hours
            StatsManager.RegisterStat(msgsIn);
            m_registeredStats.Add(msgsIn);

            msgsOut = new SyncConnectorStat(
                "DSG_Msgs_Sent|" + description, // shortName
                "Msgs_Sent",                    // name
                "connector DSG messages sent",  // description
                " messages",                    // unit
                m_regionSyncModule.Scene.Name,  // region
                m_connectorNum,                 // connectornum
                m_regionSyncModule.ActorID,     // myActorID
                otherSideRegionName,            // otherSideRegionName
                otherSideActorID                // otherSideActorID
                );
            // msgsOut.AddHistogram("Msgs_Sent_Last_Minute", new EventHistogram(60, 1000)); // last minute in seconds
            // msgsOut.AddHistogram("Msgs_Sent_Last_Hour", new EventHistogram(60, 60000));  // last hour in minutes
            // msgsOut.AddHistogram("Msgs_Sent_Last_Day", new EventHistogram(24, 3600000)); // last day in hours
            StatsManager.RegisterStat(msgsOut);
            m_registeredStats.Add(msgsOut);

            bytesIn = new SyncConnectorStat(
                "DSG_Bytes_Rcvd|" + description, // shortName
                "Bytes_Rcvd",                    // name
                "connector DSG bytes rcvd",      // description
                " bytes",                        // unit
                m_regionSyncModule.Scene.Name,   // region
                m_connectorNum,                  // connectornum
                m_regionSyncModule.ActorID,      // myActorID
                otherSideRegionName,             // otherSideRegionName
                otherSideActorID                 // otherSideActorID
                );
            // bytesIn.AddHistogram("Bytes_Rcvd_Last_Hour", new EventHistogram(60, 60000));  // last hour in minutes
            StatsManager.RegisterStat(bytesIn);
            m_registeredStats.Add(bytesIn);

            bytesOut = new SyncConnectorStat(
                "DSG_Bytes_Sent|" + description, // shortName
                "Bytes_Sent",                    // name
                "connector DSG bytes sent",      // description
                " bytes",                        // unit
                m_regionSyncModule.Scene.Name,   // region
                m_connectorNum,                  // connectornum
                m_regionSyncModule.ActorID,      // myActorID
                otherSideRegionName,             // otherSideRegionName
                otherSideActorID                 // otherSideActorID
                );
            // bytesOut.AddHistogram("Bytes_Sent_Last_Hour", new EventHistogram(60, 60000));  // last hour in minutes
            StatsManager.RegisterStat(bytesOut);
            m_registeredStats.Add(bytesOut);

            currentQueue = new SyncConnectorStat(
                "DSG_Queued_Msgs|" + description, // shortName
                "Queued_Msgs",                    // name
                "connector DSG queued updates",   // description
                " messages",                      // unit
                m_regionSyncModule.Scene.Name,    // region
                m_connectorNum,                   // connectornum
                m_regionSyncModule.ActorID,       // myActorID
                otherSideRegionName,              // otherSideRegionName
                otherSideActorID                  // otherSideActorID
                );
            // currentQueue.AddHistogram("Queue_Size_Last_5Minute", new EventHistogram(300, 1000)); // last 5 minutes in seconds
            StatsManager.RegisterStat(currentQueue);
            m_registeredStats.Add(currentQueue);

            m_collectingStats = true;
        }
예제 #3
0
        private void StartCollectingStats()
        {
            // If stats not enabled or stats have already been initialized, just return.
            if (!m_regionSyncModule.StatCollector.Enabled || m_registeredStats.Count > 0)
                return;

            msgsIn = new SyncConnectorStat(
                "DSG_Msgs_Rcvd|" + description, // shortName
                "Msgs_Rcvd",                    // name
                "connector DSG messages rcvd",  // description
                " messages",                    // unit
                m_regionSyncModule.Scene.Name,  // region
                m_connectorNum,                 // connectornum
                m_regionSyncModule.ActorID,     // myActorID
                otherSideRegionName,            // otherSideRegionName
                otherSideActorID                // otherSideActorID
                );
            // msgsIn.AddHistogram("Msgs_Rcvd_Last_Minute", new EventHistogram(60, 1000)); // last minute in seconds
            // msgsIn.AddHistogram("Msgs_Rcvd_Last_Hour", new EventHistogram(60, 60000));  // last hour in minutes
            // msgsIn.AddHistogram("Msgs_Rcvd_Last_Day", new EventHistogram(24, 3600000)); // last day in hours
            StatsManager.RegisterStat(msgsIn);
            m_registeredStats.Add(msgsIn);

            msgsOut = new SyncConnectorStat(
                "DSG_Msgs_Sent|" + description, // shortName
                "Msgs_Sent",                    // name
                "connector DSG messages sent",  // description
                " messages",                    // unit
                m_regionSyncModule.Scene.Name,  // region
                m_connectorNum,                 // connectornum
                m_regionSyncModule.ActorID,     // myActorID
                otherSideRegionName,            // otherSideRegionName
                otherSideActorID                // otherSideActorID
                );
            // msgsOut.AddHistogram("Msgs_Sent_Last_Minute", new EventHistogram(60, 1000)); // last minute in seconds
            // msgsOut.AddHistogram("Msgs_Sent_Last_Hour", new EventHistogram(60, 60000));  // last hour in minutes
            // msgsOut.AddHistogram("Msgs_Sent_Last_Day", new EventHistogram(24, 3600000)); // last day in hours
            StatsManager.RegisterStat(msgsOut);
            m_registeredStats.Add(msgsOut);

            bytesIn = new SyncConnectorStat(
                "DSG_Bytes_Rcvd|" + description,    // shortName
                "Bytes_Rcvd",                   // name
                "connector DSG bytes rcvd",     // description
                " bytes",                       // unit
                m_regionSyncModule.Scene.Name,  // region
                m_connectorNum,                 // connectornum
                m_regionSyncModule.ActorID,     // myActorID
                otherSideRegionName,            // otherSideRegionName
                otherSideActorID                // otherSideActorID
                );
            // bytesIn.AddHistogram("Bytes_Rcvd_Last_Hour", new EventHistogram(60, 60000));  // last hour in minutes
            StatsManager.RegisterStat(bytesIn);
            m_registeredStats.Add(bytesIn);

            bytesOut = new SyncConnectorStat(
                "DSG_Bytes_Sent|" + description,    // shortName
                "Bytes_Sent",                   // name
                "connector DSG bytes sent",     // description
                " bytes",                       // unit
                m_regionSyncModule.Scene.Name,  // region
                m_connectorNum,                 // connectornum
                m_regionSyncModule.ActorID,     // myActorID
                otherSideRegionName,            // otherSideRegionName
                otherSideActorID                // otherSideActorID
                );
            // bytesOut.AddHistogram("Bytes_Sent_Last_Hour", new EventHistogram(60, 60000));  // last hour in minutes
            StatsManager.RegisterStat(bytesOut);
            m_registeredStats.Add(bytesOut);

            currentQueue = new SyncConnectorStat(
                "DSG_Queued_Msgs|" + description,   // shortName
                "Queued_Msgs",                  // name
                "connector DSG queued updates", // description
                " messages",                    // unit
                m_regionSyncModule.Scene.Name,  // region
                m_connectorNum,                 // connectornum
                m_regionSyncModule.ActorID,     // myActorID
                otherSideRegionName,            // otherSideRegionName
                otherSideActorID                // otherSideActorID
                );
            // currentQueue.AddHistogram("Queue_Size_Last_5Minute", new EventHistogram(300, 1000)); // last 5 minutes in seconds
            StatsManager.RegisterStat(currentQueue);
            m_registeredStats.Add(currentQueue);

            m_collectingStats = true;
        }
예제 #4
0
 private void CollectSendStat(string type, int length)
 {
     if (m_collectingStats)
     {
         lock (stats)
         {
             msgsOut.Event();
             bytesOut.Event(length);
             SyncConnectorStat msgStat;
             if (!m_packetTypesSent.TryGetValue(type, out msgStat))
             {
                 msgStat = new SyncConnectorStat(
                     "DSG_Msgs_Typ_Sent|" + description + "|" + type,    // shortName
                     type + "_Sent",                 // name
                     "connector DSG messages sent of type " + type,      // description
                     " messages",                    // unit
                     m_regionSyncModule.Scene.Name,  // region
                     m_connectorNum,                 // connectornum
                     m_regionSyncModule.ActorID,     // myActorID
                     otherSideRegionName,            // otherSideRegionName
                     otherSideActorID,               // otherSideActorID
                     type                            // messageType
                     );
                 StatsManager.RegisterStat(msgStat);
                 m_packetTypesSent.Add(type, msgStat);
             }
             msgStat.Event();
         }
     }
 }
예제 #5
0
        private void LogConnectorStats()
        {
            List <string> fields = new List <string>
            {
                "Msgs_Sent", "Msgs_Rcvd", "Bytes_Sent", "Bytes_Rcvd",
                "Msgs_Sent_Per_Sec", "Msgs_Rcvd_Per_Sec", "Bytes_Sent_Per_Sec", "Bytes_Rcvd_Per_Sec",
                "Queued_Msgs",
                "UpdatedProperties_Sent", "UpdatedProperties_Rcvd",
                "NewObject_Sent", "NewObject_Rcvd", "NewPresence_Sent", "NewPresence_Rcvd"
            };

            // Milliseconds since the last time we collected statistics
            int msSinceLast = Util.EnvironmentTickCountSubtract(lastStatTime);

            SortedDictionary <string, SortedDictionary <string, Stat> > DSGStats;

            if (StatsManager.TryGetStatsForCategory(DSGDetailCategory, out DSGStats))
            {
                foreach (string container in DSGStats.Keys)
                {
                    LogWriter                   connWriter   = null;
                    SyncConnectorStat           lastStat     = null;
                    Dictionary <string, double> outputValues = new Dictionary <string, double>();

                    SortedDictionary <string, Stat> containerStats = DSGStats[container];
                    foreach (Stat aStat in containerStats.Values)
                    {
                        // Select out only the SyncConnector stats.
                        SyncConnectorStat connStat = aStat as SyncConnectorStat;
                        if (connStat != null)
                        {
                            lastStat = connStat;    // remember one of the stats for line output info
                            outputValues.Add(connStat.Name, connStat.Value);
                        }
                    }

                    // Get the log file writer for this connection and create one if necessary.
                    if (lastStat != null)
                    {
                        if (!ConnectionLoggers.TryGetValue(container, out connWriter))
                        {
                            string headr = LogSyncConnectorFilenamePrefix;
                            headr      = headr.Replace("%CONTAINER%", container);
                            headr      = headr.Replace("%REGIONNAME%", lastStat.RegionName);
                            headr      = headr.Replace("%CONNECTIONNUMBER%", lastStat.ConnectorNum.ToString());
                            headr      = headr.Replace("%THISACTOR%", lastStat.MyActorID);
                            headr      = headr.Replace("%OTHERSIDEACTOR%", lastStat.OtherSideActorID);
                            headr      = headr.Replace("%OTHERSIDEREGION%", lastStat.OtherSideRegionName);
                            headr      = headr.Replace("%MESSAGETYPE%", lastStat.MessageType);
                            connWriter = new LogWriter(LogSyncConnectorDirectory, headr, LogSyncConnectorFileTimeMinutes, LogSyncConnectorFlushWrites);
                            ConnectionLoggers.Add(container, connWriter);

                            if (LogSyncConnectorIncludeTitleLine)
                            {
                                StringBuilder bufft = new StringBuilder();
                                bufft.Append("Region");
                                bufft.Append(",");
                                bufft.Append("SyncConnNum");
                                bufft.Append(",");
                                bufft.Append("ActorID");
                                bufft.Append(",");
                                bufft.Append("OtherSideActorID");
                                bufft.Append(",");
                                bufft.Append("OtherSideRegionName");
                                foreach (string fld in fields)
                                {
                                    bufft.Append(",");
                                    bufft.Append(fld);
                                }

                                connWriter.Write(bufft.ToString());
                            }
                        }

                        LastStatValues lastValues;
                        if (!m_lastStatValues.TryGetValue(container, out lastValues))
                        {
                            lastValues = new LastStatValues();
                            m_lastStatValues.Add(container, lastValues);
                        }
                        // Compute some useful values
                        ComputePerSecond("Msgs_Sent", "Msgs_Sent_Per_Sec", ref outputValues, ref lastValues.lastMsgs_Sent, msSinceLast);
                        ComputePerSecond("Msgs_Rcvd", "Msgs_Rcvd_Per_Sec", ref outputValues, ref lastValues.lastMsgs_Rcvd, msSinceLast);
                        ComputePerSecond("Bytes_Sent", "Bytes_Sent_Per_Sec", ref outputValues, ref lastValues.lastBytes_Sent, msSinceLast);
                        ComputePerSecond("Bytes_Rcvd", "Bytes_Rcvd_Per_Sec", ref outputValues, ref lastValues.lastBytes_Rcvd, msSinceLast);

                        StringBuilder buff = new StringBuilder();
                        buff.Append(lastStat.RegionName);
                        buff.Append(",");
                        buff.Append(lastStat.ConnectorNum.ToString());
                        buff.Append(",");
                        buff.Append(lastStat.MyActorID);
                        buff.Append(",");
                        buff.Append(lastStat.OtherSideActorID);
                        buff.Append(",");
                        buff.Append(lastStat.OtherSideRegionName);
                        foreach (string fld in fields)
                        {
                            buff.Append(",");
                            buff.Append(outputValues.ContainsKey(fld) ? outputValues[fld].ToString() : "");
                        }

                        // buff.Append(outputValues.ContainsKey("NewScript_Sent") ? outputValues["NewScript_Sent"] : "");
                        // buff.Append(outputValues.ContainsKey("NewScript_Rcvd") ? outputValues["NewScript_Rcvd"] : "");
                        // buff.Append(outputValues.ContainsKey("UpdateScript_Sent") ? outputValues["UpdateScript_Sent"] : "");
                        // buff.Append(outputValues.ContainsKey("UpdateScript_Rcvd") ? outputValues["UpdateScript_Rcvd"] : "");
                        // buff.Append(outputValues.ContainsKey("Terrain") ? outputValues["Terrain"] : "");
                        // buff.Append(outputValues.ContainsKey("GetObjects") ? outputValues["GetObjects"] : "");
                        // buff.Append(outputValues.ContainsKey("GetPresences") ? outputValues["GetPresences"] : "");
                        // buff.Append(outputValues.ContainsKey("GetTerrain") ? outputValues["GetTerrain"] : "");
                        connWriter.Write(buff.ToString());
                    }
                }
            }
            lastStatTime = Util.EnvironmentTickCount();
        }
예제 #6
0
        // Build an OSDMap of the DSG sync connector info. Returned map is of the form:
        //   { regionName: {
        //           containerName: {
        //                "ConnectorNum": connectorNumber,
        //                "RegionName": reportingRegionName,
        //                "MyActorID": name,
        //                "OtherSideRegion": name,
        //                "OtherSideActor": name,
        //                "Bytes_Sent": num,
        //                "Bytes_Rcvd": num,
        //                "Msgs_Sent": num,
        //                "Msgs_Rcvd": num,
        //                "Queued_Msgs": num,
        //                "MessagesByType": {
        //                      typeName: {
        //                           "DSG_Msgs_Typ_Rcvd": num,
        //                           "DSG_Msgs_Typ_Sent": num,
        //                      },
        //                      ...
        //                },
        //                "Histograms": {
        //                    histogramName: {
        //                         "Buckets": numberOfBuckets,
        //                         "BucketMilliseconds": millisecondsOfEachBucket,
        //                         "TotalMilliseconds": totalMillisecondsSpannedByHistogram,
        //                         "BaseNumber": numberOfFirstBucket,
        //                         "Values": [ arrayOfBucketValues ]
        //                    }
        //                    ...
        //                },
        //           },
        //           ...
        //     },
        //     ...
        //   }
        public override OSDMap ToOSDMap()
        {
            OSDMap ret = new OSDMap();

            // Fetch all the DSG stats. Extract connectors and then organize the stats.
            // The top dictionary is the containers (region name)
            SortedDictionary <string, SortedDictionary <string, Stat> > DSGStats;

            if (StatsManager.TryGetStatsForCategory(SyncStatisticCollector.DSGDetailCategory, out DSGStats))
            {
                foreach (string container in DSGStats.Keys)
                {
                    OSDMap containerMap = new OSDMap();
                    foreach (KeyValuePair <string, Stat> aStat in DSGStats[container])
                    {
                        SyncConnectorStat connStat = aStat.Value as SyncConnectorStat;
                        if (connStat != null)
                        {
                            try
                            {
                                // If the first entry for this container, initialize the container block
                                if (!containerMap.ContainsKey(container))
                                {
                                    OSDMap connectorNew = new OSDMap();
                                    connectorNew.Add("ConnectorNum", OSD.FromInteger(connStat.ConnectorNum));
                                    connectorNew.Add("RegionName", connStat.RegionName);
                                    connectorNew.Add("MyActorID", connStat.MyActorID);
                                    connectorNew.Add("OtherSideActor", connStat.OtherSideActorID);
                                    connectorNew.Add("OtherSideRegion", connStat.OtherSideRegionName);
                                    connectorNew.Add("MessagesByType", new OSDMap());
                                    connectorNew.Add("Histograms", new OSDMap());

                                    containerMap.Add(container, connectorNew);
                                }
                                // Get the structure being built for this container
                                OSDMap connectorMap = (OSDMap)containerMap[container];

                                // Add this statistic value
                                float val = (float)connStat.Value;
                                connectorMap.Add(connStat.Name, OSD.FromReal(val));

                                // If this value is a message type entry, add the info to the by message type table
                                if (!string.IsNullOrEmpty(connStat.MessageType))
                                {
                                    OSDMap messagesMap = (OSDMap)connectorMap["MessagesByType"];
                                    messagesMap.Add(connStat.Name, OSD.FromReal(val));
                                }

                                // If there are histograms on the statistics, add them to the structure
                                OSDMap histogramMap = (OSDMap)connectorMap["Histograms"];
                                connStat.ForEachHistogram((histoName, histo) =>
                                {
                                    histogramMap.Add(histoName, histo.GetHistogramAsOSDMap());
                                });
                            }
                            catch
                            {
                                // m_log.ErrorFormat("{0} Exception adding stat to block. name={1}, block={2}, e={3}",
                                //             LogHeader, aStat.Value.ShortName, OSDParser.SerializeJsonString(containerMap), e);
                            }
                        }
                    }
                    ret.Add(container, containerMap);
                }
            }
            return(ret);
        }
예제 #7
0
        public override string ToConsoleString()
        {
            // Message types that are not reported. There should be only one of these messages anyway.
            string leaveOutMsgs = "GetObjec,GetPrese,GetTerra,Terrain,GetRegio,RegionIn,";
            // Remembers the name of the actor on the other side of a connector
            Dictionary <string, string> otherActor = new Dictionary <string, string>();

            ConsoleDisplayTable cdt = new ConsoleDisplayTable();

            SortedDictionary <string, SortedDictionary <string, Stat> > DSGStats;

            if (StatsManager.TryGetStatsForCategory(SyncStatisticCollector.DSGDetailCategory, out DSGStats))
            {
                // Find all the column names
                Dictionary <string, int> cols = new Dictionary <string, int>();
                int maxColumn = 2;  // two extra columns at beginning
                foreach (string container in DSGStats.Keys)
                {
                    foreach (KeyValuePair <string, Stat> aStat in DSGStats[container])
                    {
                        string colName = ExtractColumnNameFromStatShortname(aStat.Value.ShortName);
                        if (!leaveOutMsgs.Contains(colName + ",") && !cols.ContainsKey(colName))
                        {
                            cols.Add(colName, maxColumn++);
                        }
                        if (!otherActor.ContainsKey(container))
                        {
                            SyncConnectorStat conStat = aStat.Value as SyncConnectorStat;
                            if (conStat != null)
                            {
                                otherActor[container] = conStat.OtherSideActorID;
                            }
                        }
                    }
                }

                // Add all the columns to the table
                cdt.AddColumn("Connection", 22);
                cdt.AddColumn("OtherActor", 10);
                foreach (KeyValuePair <string, int> kvp in cols)
                {
                    cdt.AddColumn(kvp.Key, 8);
                }

                // Add a row for each of the containers
                foreach (string container in DSGStats.Keys)
                {
                    string[] values = new string[maxColumn];
                    values.Initialize();

                    values[0] = container;
                    if (otherActor.ContainsKey(container))
                    {
                        values[1] = otherActor[container];
                    }

                    foreach (KeyValuePair <string, Stat> aStat in DSGStats[container])
                    {
                        string colName = ExtractColumnNameFromStatShortname(aStat.Value.ShortName);
                        if (cols.ContainsKey(colName))
                        {
                            values[cols[colName]] = aStat.Value.Value.ToString();
                        }
                    }

                    cdt.AddRow(values);
                }
            }
            return(cdt.ToString());
        }