当前位置: 首页>>代码示例>>C#>>正文


C# Monitoring.Stat类代码示例

本文整理汇总了C#中OpenSim.Framework.Monitoring.Stat的典型用法代码示例。如果您正苦于以下问题:C# Stat类的具体用法?C# Stat怎么用?C# Stat使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Stat类属于OpenSim.Framework.Monitoring命名空间,在下文中一共展示了Stat类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MakeStat

 private void MakeStat(string pName, string pUnitName, Action<Stat> act)
 {
     Stat tempStat = new Stat(pName, pName, pName, pUnitName, "scene", m_scene.RegionInfo.RegionName, StatType.Pull, act, StatVerbosity.Info);
     StatsManager.RegisterStat(tempStat);
     registeredStats.Add(tempStat);
 }
开发者ID:CassieEllen,项目名称:opensim,代码行数:6,代码来源:MonitorModule.cs

示例2: AddRegion

        public virtual void AddRegion(Scene scene)
        {
            if (!m_Enabled)
                return;

            Scene = scene;

            m_interRegionTeleportAttempts = 
                new Stat(
                    "InterRegionTeleportAttempts",
                    "Number of inter-region teleports attempted.",
                    "This does not count attempts which failed due to pre-conditions (e.g. target simulator refused access).\n"
                        + "You can get successfully teleports by subtracting aborts, cancels and teleport failures from this figure.",
                    "",
                    "entitytransfer",
                    Scene.Name,
                    StatType.Push,
                    null,
                    StatVerbosity.Debug);

            m_interRegionTeleportAborts = 
                new Stat(
                    "InterRegionTeleportAborts",
                    "Number of inter-region teleports aborted due to client actions.",
                    "The chief action is simultaneous logout whilst teleporting.",
                    "",
                    "entitytransfer",
                    Scene.Name,
                    StatType.Push,
                    null,
                    StatVerbosity.Debug);

            m_interRegionTeleportCancels = 
                new Stat(
                    "InterRegionTeleportCancels",
                    "Number of inter-region teleports cancelled by the client.",
                    null,
                    "",
                    "entitytransfer",
                    Scene.Name,
                    StatType.Push,
                    null,
                    StatVerbosity.Debug);

            m_interRegionTeleportFailures = 
                new Stat(
                    "InterRegionTeleportFailures",
                    "Number of inter-region teleports that failed due to server/client/network issues.",
                    "This number may not be very helpful in open-grid/hg situations as the network connectivity/quality of destinations is uncontrollable.",
                    "",
                    "entitytransfer",
                    Scene.Name,
                    StatType.Push,
                    null,
                    StatVerbosity.Debug);

            StatsManager.RegisterStat(m_interRegionTeleportAttempts);
            StatsManager.RegisterStat(m_interRegionTeleportAborts);
            StatsManager.RegisterStat(m_interRegionTeleportCancels);
            StatsManager.RegisterStat(m_interRegionTeleportFailures);

            scene.RegisterModuleInterface<IEntityTransferModule>(this);
            scene.EventManager.OnNewClient += OnNewClient;
        }
开发者ID:Kubwa,项目名称:opensim,代码行数:64,代码来源:EntityTransferModule.cs

示例3: EnablePoolStats

        /// <summary>
        /// This is a seperate method so that it can be called once we have an m_scene to distinguish different scene
        /// stats.
        /// </summary>
        private void EnablePoolStats()
        {
            m_poolCountStat
                = new Stat(
                    "UDPPacketBufferPoolCount",
                    "Objects within the UDPPacketBuffer pool",
                    "The number of objects currently stored within the UDPPacketBuffer pool",
                    "",
                    "clientstack",
                    m_scene.Name,
                    StatType.Pull,
                    stat => stat.Value = Pool.Count,
                    StatVerbosity.Debug);

            StatsManager.RegisterStat(m_poolCountStat);

            m_incomingPacketPoolStat
                = new Stat(
                    "IncomingPacketPoolCount",
                    "Objects within incoming packet pool",
                    "The number of objects currently stored within the incoming packet pool",
                    "",
                    "clientstack",
                    m_scene.Name,
                    StatType.Pull,
                    stat => stat.Value = m_incomingPacketPool.Count,
                    StatVerbosity.Debug);

            StatsManager.RegisterStat(m_incomingPacketPoolStat);
        }
开发者ID:JeffCost,项目名称:opensim,代码行数:34,代码来源:LLUDPServer.cs

示例4: SimStatsReporter

        public SimStatsReporter(Scene scene)
        {
            m_scene = scene;
            m_reportedFpsCorrectionFactor = scene.MinFrameTime * m_nominalReportedFps;
            m_statsUpdateFactor = (float)(m_statsUpdatesEveryMS / 1000);
            ReportingRegion = scene.RegionInfo;

            m_objectCapacity = scene.RegionInfo.ObjectCapacity;
            m_report.AutoReset = true;
            m_report.Interval = m_statsUpdatesEveryMS;
            m_report.Elapsed += TriggerStatsHeartbeat;
            m_report.Enabled = true;

            if (StatsManager.SimExtraStats != null)
                OnSendStatsResult += StatsManager.SimExtraStats.ReceiveClassicSimStatsPacket;

            /// At the moment, we'll only report if a frame is over 120% of target, since commonly frames are a bit
            /// longer than ideal (which in itself is a concern).
            SlowFramesStatReportThreshold = (int)Math.Ceiling(m_scene.MinFrameTime * 1000 * 1.2);

            SlowFramesStat
                = new Stat(
                    "SlowFrames",
                    "Slow Frames",
                    "Number of frames where frame time has been significantly longer than the desired frame time.",
                    " frames",
                    "scene",
                    m_scene.Name,
                    StatType.Push,
                    null,
                    StatVerbosity.Info);

            StatsManager.RegisterStat(SlowFramesStat);
        }
开发者ID:CCIR,项目名称:opensim,代码行数:34,代码来源:SimStatsReporter.cs

示例5: DisablePoolStats

        /// <summary>
        /// Disables pool stats.
        /// </summary>
        protected internal void DisablePoolStats()
        {
            StatsManager.DeregisterStat(m_poolCountStat);
            m_poolCountStat = null;

            StatsManager.DeregisterStat(m_incomingPacketPoolStat);
            m_incomingPacketPoolStat = null;
        }
开发者ID:Kubwa,项目名称:opensim,代码行数:11,代码来源:LLUDPServer.cs

示例6: RegisterStat

        /// <summary>
        /// Registers a statistic.
        /// </summary>
        /// <param name='stat'></param>
        /// <returns></returns>
        public static bool RegisterStat(Stat stat)
        {
            SortedDictionary<string, SortedDictionary<string, Stat>> category = null, newCategory;
            SortedDictionary<string, Stat> container = null, newContainer;

            lock (RegisteredStats)
            {
                // Stat name is not unique across category/container/shortname key.
                // XXX: For now just return false.  This is to avoid problems in regression tests where all tests
                // in a class are run in the same instance of the VM.
                if (TryGetStat(stat, out category, out container))
                    return false;

                // We take a copy-on-write approach here of replacing dictionaries when keys are added or removed.
                // This means that we don't need to lock or copy them on iteration, which will be a much more
                // common operation after startup.
                if (container != null)
                    newContainer = new SortedDictionary<string, Stat>(container);
                else
                    newContainer = new SortedDictionary<string, Stat>();

                if (category != null)
                    newCategory = new SortedDictionary<string, SortedDictionary<string, Stat>>(category);
                else
                    newCategory = new SortedDictionary<string, SortedDictionary<string, Stat>>();

                newContainer[stat.ShortName] = stat;
                newCategory[stat.Container] = newContainer;
                RegisteredStats[stat.Category] = newCategory;
            }

            return true;
        }
开发者ID:rryk,项目名称:omp-server,代码行数:38,代码来源:StatsManager.cs

示例7: TryGetStat

        public static bool TryGetStat(
            Stat stat,
            out SortedDictionary<string, SortedDictionary<string, Stat>> category,
            out SortedDictionary<string, Stat> container)
        {
            category = null;
            container = null;

            lock (RegisteredStats)
            {
                if (RegisteredStats.TryGetValue(stat.Category, out category))
                {
                    if (category.TryGetValue(stat.Container, out container))
                    {
                        if (container.ContainsKey(stat.ShortName))
                            return true;
                    }
                }
            }

            return false;
        }
开发者ID:rryk,项目名称:omp-server,代码行数:22,代码来源:StatsManager.cs

示例8: GetNextValue

 private void GetNextValue(Stat stat, PerfCounterControl perfControl)
 {
     GetNextValue(stat, perfControl, 1.0);
 }
开发者ID:AkiraSonoda,项目名称:akisim,代码行数:4,代码来源:ServerStatsCollector.cs

示例9: MakeStat

 private void MakeStat(string pName, string pUnit, string pContainer, Action<Stat> act)
 {
     Stat stat = new Stat(pName, pName, "", pUnit, CategoryServer, pContainer, StatType.Pull, act, StatVerbosity.Info);
     StatsManager.RegisterStat(stat);
     RegisteredStats.Add(pName, stat);
 }
开发者ID:rryk,项目名称:omp-server,代码行数:6,代码来源:ServerStats.cs

示例10: RegisterServerStats

    public void RegisterServerStats()
    {
        lastperformanceCounterSampleTime = Util.EnvironmentTickCount();
        PerformanceCounter tempPC;
        Stat tempStat;
        string tempName;

        try
        {
            tempName = "CPUPercent";
            tempPC = new PerformanceCounter("Processor", "% Processor Time", "_Total");
            processorPercentPerfCounter = new PerfCounterControl(tempPC);
            // A long time bug in mono is that CPU percent is reported as CPU percent idle. Windows reports CPU percent busy.
            tempStat = new Stat(tempName, tempName, "", "percent", CategoryServer, ContainerProcessor,
                            StatType.Pull, (s) => { GetNextValue(s, processorPercentPerfCounter, Util.IsWindows() ? 1 : -1); },
                            StatVerbosity.Info);
            StatsManager.RegisterStat(tempStat);
            RegisteredStats.Add(tempName, tempStat);

            MakeStat("TotalProcessorTime", "sec", ContainerProcessor, 
                                (s) => { s.Value = Process.GetCurrentProcess().TotalProcessorTime.TotalSeconds; });

            MakeStat("UserProcessorTime", "sec", ContainerProcessor,
                                (s) => { s.Value = Process.GetCurrentProcess().UserProcessorTime.TotalSeconds; });

            MakeStat("PrivilegedProcessorTime", "sec", ContainerProcessor,
                                (s) => { s.Value = Process.GetCurrentProcess().PrivilegedProcessorTime.TotalSeconds; });

            MakeStat("Threads", "threads", ContainerProcessor,
                                (s) => { s.Value = Process.GetCurrentProcess().Threads.Count; });
        }
        catch (Exception e)
        {
            m_log.ErrorFormat("{0} Exception creating 'Process': {1}", LogHeader, e);
        }

        try
        {
            List<string> okInterfaceTypes = new List<string>(NetworkInterfaceTypes.Split(','));

            IEnumerable<NetworkInterface> nics = NetworkInterface.GetAllNetworkInterfaces();
            foreach (NetworkInterface nic in nics)
            {
                if (nic.OperationalStatus != OperationalStatus.Up)
                    continue;

                string nicInterfaceType = nic.NetworkInterfaceType.ToString();
                if (!okInterfaceTypes.Contains(nicInterfaceType))
                {
                    m_log.DebugFormat("{0} Not including stats for network interface '{1}' of type '{2}'. To include, add to [Monitoring]NetworkInterfaceTypes='Ethernet,Loopback'",
                                            LogHeader, nic.Name, nicInterfaceType);
                    continue;
                }

                if (nic.Supports(NetworkInterfaceComponent.IPv4))
                {
                    IPv4InterfaceStatistics nicStats = nic.GetIPv4Statistics();
                    if (nicStats != null)
                    {
                        MakeStat("BytesRcvd/" + nic.Name, "KB", ContainerNetwork,
                                        (s) => { LookupNic(s, (ns) => { return ns.BytesReceived; }, 1024.0); });
                        MakeStat("BytesSent/" + nic.Name, "KB", ContainerNetwork,
                                        (s) => { LookupNic(s, (ns) => { return ns.BytesSent; }, 1024.0); });
                        MakeStat("TotalBytes/" + nic.Name, "KB", ContainerNetwork,
                                        (s) => { LookupNic(s, (ns) => { return ns.BytesSent + ns.BytesReceived; }, 1024.0); });
                    }
                }
            }
        }
        catch (Exception e)
        {
            m_log.ErrorFormat("{0} Exception creating 'Network Interface': {1}", LogHeader, e);
        }

        MakeStat("ProcessMemory", "MB", ContainerMemory,
                            (s) => { s.Value = Process.GetCurrentProcess().WorkingSet64 / 1024d / 1024d; });
        MakeStat("ObjectMemory", "MB", ContainerMemory,
                            (s) => { s.Value = GC.GetTotalMemory(false) / 1024d / 1024d; });
        MakeStat("LastMemoryChurn", "MB/sec", ContainerMemory,
                            (s) => { s.Value = Math.Round(MemoryWatchdog.LastMemoryChurn * 1000d / 1024d / 1024d, 3); });
        MakeStat("AverageMemoryChurn", "MB/sec", ContainerMemory,
                            (s) => { s.Value = Math.Round(MemoryWatchdog.AverageMemoryChurn * 1000d / 1024d / 1024d, 3); });
    }
开发者ID:rryk,项目名称:omp-server,代码行数:83,代码来源:ServerStats.cs

示例11: EnablePools

        protected virtual bool EnablePools()
        {
            if (!UsePools)
            {
                m_pool = new Pool<UDPPacketBuffer>(() => new UDPPacketBuffer(), 500);

                m_poolCountStat
                    = new Stat(
                        "UDPPacketBufferPoolCount",
                        "Objects within the UDPPacketBuffer pool",
                        "The number of objects currently stored within the UDPPacketBuffer pool",
                        "",
                        "clientstack",
                        "packetpool",
                        StatType.Pull,
                        stat => stat.Value = m_pool.Count,
                        StatVerbosity.Debug);

                StatsManager.RegisterStat(m_poolCountStat);

                UsePools = true;

                return true;
            }

            return false;
        }
开发者ID:CCIR,项目名称:opensim,代码行数:27,代码来源:OpenSimUDPBase.cs

示例12: Start

        public void Start()
        {
            lock (this)
            {
                if (IsRunning)
                    return;

                IsRunning = true;

                m_finishedProcessingAfterStop.Reset();

                m_requestQueue = new BlockingCollection<RefillRequest>(new ConcurrentQueue<RefillRequest>(), 5000);

                m_oqreRequestsWaitingStat = 
                    new Stat(
                        "OQRERequestsWaiting",
                        "Number of outgong queue refill requests waiting for processing.",
                        "",
                        "",
                        "clientstack",
                        m_udpServer.Scene.Name,
                        StatType.Pull,
                        MeasuresOfInterest.None,
                        stat => stat.Value = m_requestQueue.Count,
                        StatVerbosity.Debug);

                StatsManager.RegisterStat(m_oqreRequestsWaitingStat);

                Watchdog.StartThread(
                    ProcessRequests,
                    String.Format("OutgoingQueueRefillEngineThread ({0})", m_udpServer.Scene.Name),
                    ThreadPriority.Normal,
                    false,
                    true,
                    null,
                    int.MaxValue);
            }
        }
开发者ID:ffoliveira,项目名称:opensimulator,代码行数:38,代码来源:OutgoingQueueRefillEngine.cs

示例13: Stop

        public void Stop()
        {   
            lock (this)
            {
                try
                {
                    if (!IsRunning)
                        return;

                    IsRunning = false;

                    int requestsLeft = m_requestQueue.Count;

                    if (requestsLeft <= 0)
                    {
                        m_cancelSource.Cancel();
                    }
                    else 
                    {
                        m_log.InfoFormat("[OUTGOING QUEUE REFILL ENGINE]: Waiting to write {0} events after stop.", requestsLeft);

                        while (requestsLeft > 0)
                        {
                            if (!m_finishedProcessingAfterStop.WaitOne(RequestProcessTimeoutOnStop))
                            {
                                // After timeout no events have been written
                                if (requestsLeft == m_requestQueue.Count)
                                {
                                    m_log.WarnFormat(
                                        "[OUTGOING QUEUE REFILL ENGINE]: No requests processed after {0} ms wait.  Discarding remaining {1} requests", 
                                        RequestProcessTimeoutOnStop, requestsLeft);

                                    break;
                                }
                            }

                            requestsLeft = m_requestQueue.Count;
                        }
                    }
                }
                finally
                {
                    m_cancelSource.Dispose();
                    StatsManager.DeregisterStat(m_oqreRequestsWaitingStat);
                    m_oqreRequestsWaitingStat = null;
                    m_requestQueue = null;
                }
            }
        }
开发者ID:ffoliveira,项目名称:opensimulator,代码行数:49,代码来源:OutgoingQueueRefillEngine.cs

示例14: OutputStatToConsole

 private static void OutputStatToConsole(ICommandConsole con, Stat stat)
 {
     con.Output(stat.ToConsoleString());
 }
开发者ID:ffoliveira,项目名称:opensimulator,代码行数:4,代码来源:StatsManager.cs

示例15: DeregisterStat

        /// <summary>
        /// Deregister a statistic
        /// </summary>>
        /// <param name='stat'></param>
        /// <returns></returns>
        public static bool DeregisterStat(Stat stat)
        {
            SortedDictionary<string, SortedDictionary<string, Stat>> category = null, newCategory;
            SortedDictionary<string, Stat> container = null, newContainer;

            RegisteredStatsRwLock.AcquireWriterLock(-1);
            try
            {
                if (!TryGetStatParents(stat, out category, out container))
                    return false;

                newContainer = new SortedDictionary<string, Stat>(container);
                newContainer.Remove(stat.ShortName);

                newCategory = new SortedDictionary<string, SortedDictionary<string, Stat>>(category);
                newCategory.Remove(stat.Container);

                newCategory[stat.Container] = newContainer;
                RegisteredStats[stat.Category] = newCategory;

                return true;
            }
            finally
            {
                RegisteredStatsRwLock.ReleaseWriterLock();
            }
        }
开发者ID:emperorstarfinder,项目名称:arribasim-dev-extras,代码行数:32,代码来源:StatsManager.cs


注:本文中的OpenSim.Framework.Monitoring.Stat类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。