public override StatusInfoCollection CollectServerStatus(StatusInfoCollection nodeStatus)
        {
            var status = base.CollectServerStatus(nodeStatus);

            status.Tag = m_ServerTag;

            if (m_PerformanceCounterHelper != null)
            {
                m_PerformanceCounterHelper.Collect(status);
            }

            return(status);
        }
        private void OnPerformanceTimerCallback(object state)
        {
            var nodeStatus = new NodeStatus();

            StatusInfoCollection bootstrapStatus = new StatusInfoCollection();

            m_Helper.Collect(bootstrapStatus);

            nodeStatus.BootstrapStatus = bootstrapStatus;

            var instancesStatus = new List <StatusInfoCollection>(m_AppServers.Length);

            var perfBuilder = new StringBuilder();

            perfBuilder.AppendLine("---------------------------------------------------");
            perfBuilder.AppendLine(string.Format("CPU Usage: {0:0.00}%, Physical Memory Usage: {1:N}, Total Thread Count: {2}", bootstrapStatus[StatusInfoKeys.CpuUsage], bootstrapStatus[StatusInfoKeys.MemoryUsage], bootstrapStatus[StatusInfoKeys.TotalThreadCount]));
            perfBuilder.AppendLine(string.Format("AvailableWorkingThreads: {0}, AvailableCompletionPortThreads: {1}", bootstrapStatus[StatusInfoKeys.AvailableWorkingThreads], bootstrapStatus[StatusInfoKeys.AvailableCompletionPortThreads]));
            perfBuilder.AppendLine(string.Format("MaxWorkingThreads: {0}, MaxCompletionPortThreads: {1}", bootstrapStatus[StatusInfoKeys.MaxWorkingThreads], bootstrapStatus[StatusInfoKeys.MaxCompletionPortThreads]));

            for (var i = 0; i < m_AppServers.Length; i++)
            {
                var s = m_AppServers[i];

                var metadata = m_ServerStatusMetadataSource[i + 1].Value;

                if (metadata == null)
                {
                    perfBuilder.AppendLine(string.Format("{0} ----------------------------------", s.Name));
                    perfBuilder.AppendLine(string.Format("{0}: {1}", "State", s.State));
                }
                else
                {
                    var serverStatus = s.CollectServerStatus(bootstrapStatus);

                    instancesStatus.Add(serverStatus);

                    perfBuilder.AppendLine(string.Format("{0} ----------------------------------", serverStatus.Tag));

                    for (var j = 0; j < metadata.Length; j++)
                    {
                        var statusInfoAtt = metadata[j];

                        if (!statusInfoAtt.OutputInPerfLog)
                        {
                            continue;
                        }

                        var statusValue = serverStatus[statusInfoAtt.Key];

                        if (statusValue == null)
                        {
                            continue;
                        }

                        perfBuilder.AppendLine(
                            string.Format("{0}: {1}", statusInfoAtt.Name,
                                          string.IsNullOrEmpty(statusInfoAtt.Format) ? statusValue : string.Format(statusInfoAtt.Format, statusValue)));
                    }
                }
            }

            m_PerfLog.Info(perfBuilder.ToString());

            nodeStatus.InstancesStatus = instancesStatus.ToArray();

            if (OnStatusUpdate != null)
            {
                OnStatusUpdate(nodeStatus);
            }

            if (m_ServerManager != null && m_ServerManager.State == ServerState.Running)
            {
                m_ServerManager.TransferSystemMessage("ServerStatusCollected", nodeStatus);
            }
        }